LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   rootdev not found by /sbin/init from initramfs (https://www.linuxquestions.org/questions/slackware-14/rootdev-not-found-by-sbin-init-from-initramfs-4175522403/)

Bourdieu 10-17-2014 04:25 AM

rootdev not found by /sbin/init from initramfs
 
Hi,

I experience a problem where the /sbin/init script from my initramfs doesn't find the root device (/dev/sda1) and hence stops at the rescue prompt.

A little context :
I am working on a vmware virtual machine, slackware version is 14.1 i686 (upgraded to current later but it didn't change anything). The partitioning is 1 virtual disk /dev/sda with /dev/sda1 as a btrfs filesystem mounted as / and /dev/sda2 as swap.

The kernel and initramfs are loaded by grub2, the kernel command line is :
Code:

linux /boot/vmlinuz-generic-smp-3.14.18-smp root=UUID=2f9934fd-f987-4903-b26a-e921532cfd1e ro debug
Initrd.gz correctly loads the needed modules, including btrfs, and after that the mounting of the root partition fails. The error reported is :
Code:

mount: can't find /mnt in /etc/fstab
The root cause being that findfs in the /sbin/init script doesn't find the /dev/sda1 partition by its uuid. The ROOTDEV variable is empty, and then the mount command looks like : mount -t btrfs -o ro /mnt

And indeed, when I am at the rescue prompt, the blkid command only return /dev/sda2 (swap partition), no /dev/sda1. Which could explain why findfs doesn't return it either. And yet, /dev/disk/by-uuid/2f9934fd-f987-4903-b26a-e921532cfd1e exists.

If I boot on the slackware DVD now, blkid correctly returns all the partitions including /dev/sda1.

I tried specifying / partition in /etc/fstab by UUID, device or /dev/disk/by-uuid/... but it didn't change anything.

Now I can boot the system without any problem by specifying the root device by its device path (/dev/sda1) in the kernel commandline parameters (root=/dev/sda1). So I am not stuck at all, but I would like to understand why it's failing with UUID and maybe fix a bug if it is one.

PS: It's complicated to provide full file content because copy/paste doesn't work from the VM.

Any help would be appreciated.

Didier Spaier 10-17-2014 05:07 AM

Lilo can't boot / on a BTRFS file system. Usual workaround is to make a small ext4 /boot partition, or use another bootloader.

Quote:

PS: It's complicated to provide full file content because copy/paste doesn't work from the VM.
TIP: write the output on an USB stick from the VM, then read it from the host.

J'espère que ça aide.

Richard Cranium 10-17-2014 05:10 AM

Perhaps waiting for udevd/mdev to finish may help. If you look in /boot/initrd-tree/init you will see that you can create a file in the initramfs to have the number of seconds to wait for udevd/mdev to finish work.

You set that value via the "-w <wait_time>" option to mkinitrd. You'd have to use the...
Code:

-a <"additional params">  Additional parameters to pass to mkinitrd.
...option to /usr/share/mkinitrd/mkinitrd_command_generator.sh to add it to the generated mkinitrd command line.

Richard Cranium 10-17-2014 05:12 AM

Quote:

Originally Posted by Didier Spaier (Post 5254996)
Lilo can't boot / on a BTRFS file system.

That's probably why he's using grub2.

Didier Spaier 10-17-2014 05:14 AM

Quote:

Originally Posted by Richard Cranium (Post 5255000)
That's probably why he's using grub2.

Hmm... I should clean my glasses more often. Thanks for the heads up ;)

Bourdieu 10-17-2014 05:57 AM

Quote:

Originally Posted by Richard Cranium (Post 5254998)
Perhaps waiting for udevd/mdev to finish may help. If you look in /boot/initrd-tree/init you will see that you can create a file in the initramfs to have the number of seconds to wait for udevd/mdev to finish work.

You set that value via the "-w <wait_time>" option to mkinitrd. You'd have to use the...
Code:

-a <"additional params">  Additional parameters to pass to mkinitrd.
...option to /usr/share/mkinitrd/mkinitrd_command_generator.sh to add it to the generated mkinitrd command line.

I already tried that with -w 10 but it didn't help.

Richard Cranium 10-17-2014 09:18 AM

You could have mentioned that. :-)

When you are at the rescue prompt, what does
Code:

ls -l /dev/disk/by-uuid/2f9934fd-f987-4903-b26a-e921532cfd1e
show?

Richard Cranium 10-17-2014 09:23 AM

Quote:

Originally Posted by Didier Spaier (Post 5255001)
Hmm... I should clean my glasses more often. Thanks for the heads up ;)

It happens to us all. At least you haven't posted a backwards symlink command on the forum like I have. :doh:

Bourdieu 10-17-2014 12:12 PM

Quote:

Originally Posted by Richard Cranium (Post 5255066)
You could have mentioned that. :-)

When you are at the rescue prompt, what does
Code:

ls -l /dev/disk/by-uuid/2f9934fd-f987-4903-b26a-e921532cfd1e
show?

It is a link to /dev/sda1 which is whats is expected.

Bourdieu 10-23-2014 07:37 AM

1 Attachment(s)
To illustrate the problem, I took the attached screen capture that include results from various diagnostic commands.

GazL 10-23-2014 10:39 AM

Could this be due to a difference between the findfs in busybox used in the initrd, and the one in util-linux?

Richard Cranium 10-24-2014 03:52 PM

Quote:

Originally Posted by Didier Spaier (Post 5255001)
Hmm... I should clean my glasses more often. Thanks for the heads up ;)

Now that I've tried to test what the OP is doing, I can say that grub2 can't boot from btrfs either. Or so grub-install tells me in my virtual machine.

So your advice is correct.

Bourdieu 10-29-2014 09:14 AM

Quote:

Originally Posted by Richard Cranium (Post 5259056)
Now that I've tried to test what the OP is doing, I can say that grub2 can't boot from btrfs either. Or so grub-install tells me in my virtual machine.

So your advice is correct.

I can confirm that Grub2 is able to boot from btrfs.

This is how my slackware VMs are booting up.

Richard Cranium 10-29-2014 09:43 AM

So how did you get it installed? I didn't see a way in my VM.

Bourdieu 10-29-2014 10:24 AM

The main caveat with booting on a btrfs filesystem is to leave enough free space between the MBR and the first partition as described on the archwiki.

https://wiki.archlinux.org/index.php...rtition_offset

Quote:

Partition offset
Note: The offset problem may happen when you try to embed core.img into a partitioned disk. It means that it is OK to embed grub's corg.img into a Btrfs pool on a partitionless disk (e.g. /dev/sdX) directly.

GRUB can boot Btrfs partitions however the module may be larger than other file systems. And the core.img file made by grub-install may not fit in the first 63 sectors (31.5KiB) of the drive between the MBR and the first partition. Up-to-date partitioning tools such as fdisk and gdisk avoid this issue by offsetting the first partition by roughly 1MiB or 2MiB.
Apart from that, just include the btrfs module in the initramfs and you are good to go.


All times are GMT -5. The time now is 02:20 AM.