LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 10-01-2016, 05:18 PM   #1
moesasji
Member
 
Registered: May 2008
Distribution: Slackware Current / OpenBSD
Posts: 322

Rep: Reputation: 104Reputation: 104
[bug?] Using generic kernel fails when using btrfs subvolumes in 14.2


Installing a Slackware 14.2 system using btrfs subvolumes similar to the guide available here http://www.yodaconditions.com/dokuwi....install.btrfs doesn't work on 14.2. It fails to boot with a "No /sbin/init found on rootdev" error.

The reason this happens is that the mkinitrd script ignores the rootflags that are needed to mount the correct subvolume. The patch given in the following topic appears correct and fixes this problem for me: http://www.linuxquestions.org/questi...en-4175553213/

Could this fix be applied please as all guides for using btrfs as root for Slackware recommend the generic kernel, which doesn't work for 14.2 and the solution isn't that obvious.

Last edited by moesasji; 10-01-2016 at 05:21 PM.
 
Old 10-02-2016, 06:15 PM   #2
atelszewski
Member
 
Registered: Aug 2007
Distribution: Slackware
Posts: 948

Rep: Reputation: Disabled
Hi,

Per kernel-parameters.txt, rootflags is a kernel parameter and so should be handled by the kernel and not init.

Did you try appending rootflags= to the kernel command line?

Grepping the kernel source indicates that the parameter is actually used:
Code:
Documentation/kernel-parameters.txt:	rootflags=	[KNL] Set root filesystem mount option string
fs/hfsplus/inode.c:	if (perms->rootflags & HFSPLUS_FLG_IMMUTABLE)
fs/hfsplus/inode.c:	if (perms->rootflags & HFSPLUS_FLG_APPEND)
fs/hfsplus/inode.c:				(file->permissions.rootflags |
fs/hfsplus/hfsplus_raw.h:	u8  rootflags;
fs/hfsplus/catalog.c:		perms->rootflags |= HFSPLUS_FLG_IMMUTABLE;
fs/hfsplus/catalog.c:		perms->rootflags &= ~HFSPLUS_FLG_IMMUTABLE;
fs/hfsplus/catalog.c:		perms->rootflags |= HFSPLUS_FLG_APPEND;
fs/hfsplus/catalog.c:		perms->rootflags &= ~HFSPLUS_FLG_APPEND;
fs/hfsplus/catalog.c:					(file->permissions.rootflags |
fs/ubifs/super.c: * flags. However, when a "rootflags=" kernel boot parameter is used, they may
init/do_mounts.c:__setup("rootflags=", root_data_setup);
and having a really quick look at init/do_mounts.c shows that rootflags= seems to be handled (i.e. it is passed to sys_mount()).

--
Best regards,
Andrzej Telszewski
 
2 members found this post helpful.
Old 01-05-2017, 05:52 AM   #3
moesasji
Member
 
Registered: May 2008
Distribution: Slackware Current / OpenBSD
Posts: 322

Original Poster
Rep: Reputation: 104Reputation: 104
Quote:
Originally Posted by atelszewski View Post
Hi,
Did you try appending rootflags= to the kernel command line?
I had forgotten about this topic until it bit me once again today on another btrfs on root install. I actually have those rootflags in my lilo config, but doing that doesn't help as also reported in the topic I linked to in my first post: http://www.linuxquestions.org/questi...en-4175553213/

I'm pretty sure it is a bug if I look at /boot/init-tree/init itself. The mount command used in that file is

Code:
 mount -o ro -t $ROOTFS $ROOTDEV /dev
.

From that you can see that the information needed to select the correct btrfs subvolume isn't included as in my case the mount command would have to be

Code:
 mount -o ro,subvol=system -t $ROOFTS $ROOTDEV /dev
. The patch I linked to should fix it, but I tend to be lazy and just fix that mount command after a clean run of mkinitrd. With that fix the system boot as expected.

In other words just passing the rootfs and rootdevice isn't enough for a btrfs drive with volumes as rootflags don't get passed on.
 
1 members found this post helpful.
Old 01-05-2017, 12:45 PM   #4
chemfire
Member
 
Registered: Sep 2012
Posts: 426

Rep: Reputation: Disabled
I'll second what moesasji said. I to use a btrfs subvolume as root and the only dependable fix I have found is to fix the mount statement in the initrd's init script. Its pain, would be nice if these patch which looks good and I will test next time I update my kernel could get rolled into the mainline!
 
Old 05-29-2017, 01:40 AM   #5
rbn14
LQ Newbie
 
Registered: Mar 2009
Posts: 9

Rep: Reputation: 1
I've patched the init script and I'm still getting
Code:
modprobe: ERROR: could not insert 'btrfs' : Cannot allocate memory
Code:
mount: can't find /mnt in /etc/fstab
ERROR: No /sbin/init found on rootdev (or not mounted). Trouble ahead.
 
Old 05-29-2017, 05:01 AM   #6
moesasji
Member
 
Registered: May 2008
Distribution: Slackware Current / OpenBSD
Posts: 322

Original Poster
Rep: Reputation: 104Reputation: 104
Quote:
Originally Posted by rbn14 View Post
I've patched the init script and I'm still getting
Code:
modprobe: ERROR: could not insert 'btrfs' : Cannot allocate memory
Your problem here is that it fails to load the btrfs module, which I haven't seen before. Are you booting of a generic kernel** that includes the btrfs module in initrd?

**) The huge kernel doesn't work in my experience. The steps to follow are pretty much as described here: https://saivnoba.wordpress.com/2012/...th-btrfs-root/ with the patch applied to the init script.
 
Old 05-29-2017, 10:36 AM   #7
rbn14
LQ Newbie
 
Registered: Mar 2009
Posts: 9

Rep: Reputation: 1
Yes, I saw that blog in my searches and it is very close to what I did. My steps were:
Format /dev/sda1 with mkfs.btfs
mount /dev/sda1 and create subolumes
unmount and mount the root subvolume
install Slackware
create initrd-tree by running
Code:
mkinitrd
patch the init script
then run mkinitrd with my options
Code:
mkinitrd -k 4.4.14 -f btrfs -r /dev/sda1 -m btrfs -u -o /boot/initrd.gz
install grub and generate grub.cnf
edit /etc/fstab
reboot
 
Old 05-29-2017, 10:58 AM   #8
moesasji
Member
 
Registered: May 2008
Distribution: Slackware Current / OpenBSD
Posts: 322

Original Poster
Rep: Reputation: 104Reputation: 104
I always run the mkinitrd both times with the options included, i.e. first

Code:
mkinitrd -c -k 4.4.14 -f btrfs -r /dev/sda1 -m btrfs -u -o /boot/initrd.gz
edit or patch and then run it again using

Code:
mkinitrd -k 4.4.14 -f btrfs -r /dev/sda1 -m btrfs -u -o /boot/initrd.gz
I have many more modules included if I run the mkinitrd_command_generator.sh, but that shouldn't impact on this.

btw) I use lilo so I am using a separate /boot partition that isn't on the btrfs volume. That might indeed not be needed for grub, but I've never tried.
 
1 members found this post helpful.
Old 05-29-2017, 11:22 AM   #9
rbn14
LQ Newbie
 
Registered: Mar 2009
Posts: 9

Rep: Reputation: 1
I was wondering if that could be the cause, running mkinitrd with no options first. I unfortunately don't have a good understanding of how mkinitrd works. I think I tried that in one iteration but I'll give it another shot and check back in.
As for a separate boot partition, that shouldn't be needed with grub and is why I have chosen to use it. I'll try an iteration using a separate boot partition and lilo as well just to see.
Thanks for the input thus far.
 
Old 05-29-2017, 06:06 PM   #10
rbn14
LQ Newbie
 
Registered: Mar 2009
Posts: 9

Rep: Reputation: 1
Okay, seems that grub was writing the config to default to the huge kernel. Once I switched it it the generic i seem to be good on the modprobe of btrfs. I still get this though:
Code:
mount: can't find /mnt in /etc/fstab
It seems to be unrelated to btrfs though. I may start a new thread for it.
 
1 members found this post helpful.
Old 05-30-2017, 06:48 AM   #11
chemfire
Member
 
Registered: Sep 2012
Posts: 426

Rep: Reputation: Disabled
I have had the same problem. I have to run mkinitrd and than edit init in the initrd-tree, than run mkinitrd or just use cpio directly to build the image with the edited file. Its an extra step but as rarely as I change kernels its not been a serious issue.

Thanks for the patch moesasji
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] which btrfs / subvolumes mixed with ext4 are needed? JZL240I-U Linux - Software 2 01-13-2015 01:22 AM
LXer: How to Manage Btrfs Storage Pools, Subvolumes And Snapshots on Linux (part 1) LXer Syndicated Linux News 0 03-21-2014 01:51 PM
[SOLVED] Slackware 13.37rc2 btrfs with generic kernel spudgunner Slackware 14 03-22-2013 09:46 PM
what is the best way to replace the generic modules when optimized kernel fails? Kristian2 Slackware 10 02-24-2009 07:25 PM
what is the best way to replace the generic modules when optimized kernel fails? Kristian2 Slackware 1 02-24-2009 03:16 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 05:13 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration