# [S] btrfs rootfs fails to mount when kernel loads

## zhMFe3

Hello everyone,

 so it seems, that i fail at kernel configuration now. I did it manually in the past but this time, I had to use genkernel and its initramfs, otherwise i got nothing (See my other posts, perhaps, or don't).

I have a btrfs raid1 (not mdraid or similar) filesystem to mount during boot. But this fails and i am prompted to suggest a new root device during boot.

Entering the same device (sdc4) as indicated by uuid in grub2 configuration and fstab at this point works and everything else initiates fine.

This is what i see during boot:

```

>> Hint: Use parameter scandelay[=seconds] if you need waiting here

>> Determining root device...

>> Detected real_root=/dev/sdd4

>> Mounting /dev/sdd4 as root...

>> Using mount -t auto -o ro

mount: mounting /dev/sdd4 on /newroot failed: Invalid argument

```

Can somebody explain the above messages? (taking my fstab and grub2 cfg into account)

It is at this point that I am asked to try again and enter the root block device; not sure where the /dev/sdd4 comes from (how was that "determined"?), but it isn't entirely wrong, because sdc4 and sdd4 are mirrors of each other. The language is weird: why does the root device need to be "determined" at all? The root device is passed as an argument to the kernel, is it not? grub2-mkconfig figured it out correctly, I'd say.

my fstab

```

# /etc/fstab: static file system information.

#

# <fs>         <mountpoint>   <type>      <opts>      <dump/pass>

UUID=ca9be372-d3be-4371-9f40-e633ebba24fd /boot   btrfs   discard,autodefrag,noatime,device=PARTUUID=5d144593-b996-48dc-933f-1f5f7e3a89bd,device=PARTUUID=6d978f92-1f98-4bb3-b2a2-5de47448cad8    0 0

UUID=bbff716c-23ef-4892-9938-17b76308c3de / btrfs   discard,autodefrag,noatime,device=PARTUUID=befcb301-607a-4001-a7c8-3bd1df70972e,device=PARTUUID=0e294f20-8e9d-4753-af4d-6ce95ab26ec7   0 0

UUID=28ea856a-d113-4015-b8de-30aa5718ab04 none   swap   sw         0 0

UUID=27a2d6d5-094e-4365-b54b-21cd98df680f none   swap   sw         0 0

tmpfs         /tmp      tmpfs      nodev,nosuid,size=8G    0 0

/dev/cdrom      /mnt/cdrom   auto      noauto,user              0 0

#PARTUUIDs

# 0e294f20-8e9d-4753-af4d-6ce95ab26ec7 -> ../../sdd4

# 48412b25-5a0e-44d3-8e0f-fb17b561a8ea -> ../../sdc3

# 5d144593-b996-48dc-933f-1f5f7e3a89bd -> ../../sdc2

# 5f88f71f-a9aa-4231-9649-2996d19d36a6 -> ../../sdd1

# 6d978f92-1f98-4bb3-b2a2-5de47448cad8 -> ../../sdd2

# a6af9057-2972-4846-87e4-8c8a870342f0 -> ../../sdd3

# bdf3a805-5442-4650-a72b-1321810230f6 -> ../../sdc1

# befcb301-607a-4001-a7c8-3bd1df70972e -> ../../sdc4

# f06e3fa0-5dbb-4e74-a47e-b6907696b30b -> ../../sdb1

#FS UUIDs

# 27a2d6d5-094e-4365-b54b-21cd98df680f -> ../../sdd3

# 28ea856a-d113-4015-b8de-30aa5718ab04 -> ../../sdc3

# 327e87ed-d8ce-42c5-a36e-a1fce228bc75 -> ../../sda2

# 43fb5b4c-049a-4162-8c00-9475cf3ca364 -> ../../sdb1

# 65c1e013-6f97-4246-a14c-3e3e3f4381c3 -> ../../sda1

# bbff716c-23ef-4892-9938-17b76308c3de -> ../../sdd4

# ca9be372-d3be-4371-9f40-e633ebba24fd -> ../../sdd2

```

.. maybe this is overkill, with the PARTUUIDs in the device option, but better safe than sorry.

Which filesystem UUID is assigned to which device name is not fixed, i think. When i repeat the ls -l command now I get 

```

# bbff716c-23ef-4892-9938-17b76308c3de -> ../../sdc4

```

Replacing the UUIDs with device names in fstab isn't helping though.

The swaps mount without problems.

Update: removing the «device=PARTUUID=[...],device=PARTUUID=[...]» option makes sd[cd]2, i.e. the /boot partition mount correctly.

This guide: https://wiki.gentoo.org/wiki/Btrfs_system_root

I find it not very helpful. It is very specific and deviates a lot from my setup (GRUB not GRUB2, migration from one setup to another, etc.). It makes many assumptions and I think it is targeted at experienced server admins (building my own initramfs seems a bit much when it almost works, so i think it might work without). 

I am using GRUB2, my boot partition is btrfs with -d raid1 -m raid1 as well (which is no problem, it seems, as the kernel and initramfs can be loaded). When OpenRC takes over and I am asked for a different root filesystem I manually type in /dev/sdc4 and everything works out fine. 

I did try dracut, because it was mentioned in the other threads concerning btrfs, but the resulting initramfs did not boot at all (it did include the btrfs module).

This looks fine to me:

```

menuentry 'Gentoo GNU/Linux' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-bbff716c-23ef-4892-9938-17b76308c3de' {

   load_video

   set gfxpayload=keep

   insmod gzio

   insmod part_gpt 

   insmod part_gpt 

   insmod btrfs

   set root='hd2,gpt2'

   if [ x$feature_platform_search_hint = xy ]; then

     search --no-floppy --fs-uuid --set=root --hint-bios=hd2,gpt2 --hint-efi=hd2,gpt2 --hint-baremetal=ahci2,gpt2  --hint-bios=hd3,gpt2 --hint-efi=hd3,gpt2 --hint-baremetal=ahci3,gpt2  ca9be372-d3be-4371-9f40-e633ebba24fd

   else

     search --no-floppy --fs-uuid --set=root ca9be372-d3be-4371-9f40-e633ebba24fd

   fi

   echo   'Loading Linux x86_64-3.10.25-gentoo ...'

   linux   /kernel-genkernel-x86_64-3.10.25-gentoo root=UUID=bbff716c-23ef-4892-9938-17b76308c3de ro  

   echo   'Loading initial ramdisk ...'

   initrd   /initramfs-genkernel-x86_64-3.10.25-gentoo

}

```

Update 2: I tried fiddling around with grub.cfg: 

```

linux   /kernel-genkernel-x86_64-3.10.25-gentoo root=UUID=bbff716c-23ef-4892-9938-17b76308c3de ro rootfstype=btrfs

linux   /kernel-genkernel-x86_64-3.10.25-gentoo root=/dev/sdc4 ro rootfstype=btrfs

```

the first line doesn't change anything, the second line reverses the roles of /dev/sdc4 and /dev/sdd4 in this sad story. sdc4 cannot be mounted by «mount -t btrfs -o ro» and i am prompted (once again) to provide a root device: but this time only /dev/sdd4 is accepted.

Update 3: the following doesn't change anything (when i append it to the appropriate /etc/defaults/grub variable (and, by doing so, to the kernel line)

```
rootflags=device=PARTUUID=[...],device=PARTUUID=[...]
```

not even the output on screen (I see only «-o ro»)

So, what's up with that? Btw. what is genkernel-next? its github page says that it is a modern remake of genkernel, but otherwise it is not mentioned anywhere at all, not in the handbook, not in the wiki. I was wondering if it might improve things for my case. (and what your opinions are about it)

I know that btrfs is not officially supported or encouraged, but maybe I am missing something very simple and this problem doesn't cost anyone much time. I would have expected gentoo users to be enthusiastic about it (btrfs), instead of ....wary. Have so few people tried it?

kind regardsLast edited by zhMFe3 on Mon Feb 24, 2014 1:50 pm; edited 1 time in total

----------

## vaxbrat

Hi.

I wrote that wiki page and just updated the original setup to something that will probably be much more to your liking  :Smile: 

http://wiki.gentoo.org/wiki/Btrfs_native_system_root

I think you are probably running into a limitation I encountered with grub2 and the kernel.  They can find a btrfs filesystem by uuid for the /boot partition when it is a raid1 living in the default volume but appear to have trouble with my more complicated root setup.  I just posted in the forums, so this is still very much a work in progress

----------

## zhMFe3

Your post and the guide made me very happy  :Smile: 

I can follow and will try it out tomorrow.

Thank you very much.

----------

## katfish

I also tried to boot from a btrfs / and ended up here as it seems not possible with a initramfs generated with genkernel. 

Is there a way without creating a custom initramfs to boot from a btrfs root fs?

----------

## katfish

I had a typo in my grub config. It works now.

----------

