FS#38566 - [grub] cannot boot a btrfs root partition (EFI system)

Attached to Project: Arch Linux
Opened by John (graysky) - Saturday, 18 January 2014, 17:39 GMT
Last edited by Gerardo Exequiel Pozzi (djgera) - Thursday, 01 May 2014, 19:38 GMT
Task Type Bug Report
Category Packages: Core
Status Closed
Assigned To Tobias Powalowski (tpowa)
Ronald van Haren (pressh)
Architecture All
Severity High
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 3
Private No

Details

Using the autogenerated grub.cfg renders the system unable to boot to a btrfs root partition. Downgrading to 1:2.00.1282.g5ae5c54-1 and regenerating grub.cfg restores the functionality. The functional grub.cfg is attached for comparison. I believe this flyspray differs from #38447 in that I do not boot to a kernel panic.

Message displayed when attempting to boot to the autogenerated entry (either primary or fallback):

ERROR: Boot device mounted successfully but /sbin/init does not exist.
Bailling out, you are on your own. Good luck.

sh: can't access tty: job control turned off
[rootfs /]#

Additional info:
* package version(s) grub 1:2.02.beta2-1

Steps to reproduce:
1) Install package on an EFI system that uses a btrfs root partition (I cannot try on an non-EFI system as I do not own one).
2) Mount /boot/efi to $esp.
3) grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=grub --recheck
4) chmod -x /etc/grub.d/10_linux ### this is known to produce bogus entries, see flyspray #38455
5) grub-mkconfig -o /boot/grub/grub.cfg
6) Reboot and try to boot the system
This task depends upon

Closed by  Gerardo Exequiel Pozzi (djgera)
Thursday, 01 May 2014, 19:38 GMT
Reason for closing:  Fixed
Additional comments about closing:  grub-1:2.02.beta2-3
Comment by Jonathan Charest (jcharest) - Tuesday, 21 January 2014, 16:40 GMT
I have a similar issue but on a bios system. The generated config file is:

echo 'Loading Arch Linux pkg-linux kernel ...'
linux /boot/vmlinuz-linux root=UUID=3fa3d65b-9541-4081-ada2-0b3b6fda695d rw quiet radeon.dpm=1
echo 'Loading Arch Linux pkg-linux kernel initramfs ...'
initrd /boot/initramfs-linux.img

But it is missing the subvol from the image paths. So If I modify to this is boots correctly:
echo 'Loading Arch Linux pkg-linux kernel ...'
linux /__active/boot/vmlinuz-linux root=UUID=3fa3d65b-9541-4081-ada2-0b3b6fda695d rw quiet radeon.dpm=1
echo 'Loading Arch Linux pkg-linux kernel initramfs ...'
initrd /__active/boot/initramfs-linux.img

Just to mention, I do not need rootflags=subvol=__active since it is the default subvol.
Comment by John (graysky) - Wednesday, 22 January 2014, 11:59 GMT Comment by Jonathan Charest (jcharest) - Wednesday, 22 January 2014, 14:45 GMT
For me this patch on 10_archlinux fixed the issue. I took the fix from 10_linux.
Comment by John (graysky) - Wednesday, 22 January 2014, 21:24 GMT
For the, the patch breaks grub-mkconfig:
Generating grub configuration file ...
/usr/bin/grub-mkrelpath: error: failed to get canonical path of `'.
Comment by Jonathan Charest (jcharest) - Wednesday, 22 January 2014, 21:32 GMT
Ok, that must be the case of /boot on its own partition ? I have /boot in the root fs so it calls:
/usr/bin/grub-mkrelpath '/boot'

Maybe the fix could be to put '.' instead of '' in the case of rootfs!=bootfs but I can't test this on my current setup:
else
SUBDIR="."
fi

Comment by Jonathan Charest (jcharest) - Monday, 27 January 2014, 18:18 GMT
The 10_archlinux file was added recently, it needs to be corrected for it to support btrfs subvolumes. I think this important since a grub failure is always a pain even though it can be fixed by editing the entry manually and adding the subvolume name in the image path.
Comment by Barry Price (barryprice) - Tuesday, 28 January 2014, 19:03 GMT
Here's a very simple patch for /etc/grub.d/10_archlinux that works for me.

Code is more or less copied from /etc/grub.d/10_linux

I have my root partition formatted as btrfs, on a non-default subvolume.

/boot is on a separate ext2 partition.
Comment by Jonathan Charest (jcharest) - Tuesday, 28 January 2014, 19:24 GMT
If I understand the subvol_fix patch, it adds the rootflags=subvol=xxxxx parameter so that the correct subvolume is mounted as root. But the current issue is not that, the issue is about the image path in the boot partition (which in my case is also the root partition):

linux /__active/boot/vmlinuz-linux
initrd /__active/boot/initramfs-linux.img

The /__active or any subvolume name must be added before /boot.

10_archlinux does not prepend the subvolume name but 10_linux does. My initial patch added this prepend but it did not handle the case where SUBDIR was set to ''. I also wonder if the subvol_fix path would add the rootflags=subvol even when a default subvolume is set (it should probably not set it in that case).


Comment by Barry Price (barryprice) - Wednesday, 29 January 2014, 05:04 GMT
It fixes the issue as initially reported by graysky (i.e. the actual bug - "rootvol" not being set).

It seems like your issue is a different one.
Comment by John (graysky) - Wednesday, 29 January 2014, 10:37 GMT
Excellent job, Barry. Your patch fixes this flyspray. As soon as someone gets assigned to it, I recommend that he or she patch using your fix and close the ticket. Can someone test Barry's patch using a non-BTRFS root to see that it doesn't break it?
Comment by Jonathan Charest (jcharest) - Wednesday, 29 January 2014, 14:32 GMT
Ok, I'll open another issue.
Comment by Barry Price (barryprice) - Thursday, 30 January 2014, 18:11 GMT
Tested my patch on a VM with an ext4 root, no problems.
Comment by Keshav Amburay (the.ridikulus.rat) - Sunday, 09 February 2014, 01:06 GMT
Please test updated 10_archlinux script at http://ix.io/ap6 .
Comment by Yama (YamashitaRen) - Saturday, 15 February 2014, 00:57 GMT
I did a fresh install this afternoon. I can confirm this bug.
10_linux doesn't detect initramfs but append subvolume's name before /boot and add the subvol parameter.
10_archlinux detect initramfs but doesn't append subvolume's name and doesn't add the subvol parameter.
Keshav's updated script detect initramfs, append subvolume's name but doesn't add the subvol parameter.

I'm currently using Keshav's updated script and registered my "root subvolume" as default subvolume. Works well so far.
Comment by Tobias Powalowski (tpowa) - Tuesday, 25 February 2014, 11:34 GMT
Please try 2.02.beta2-2 package from testing repository.
Comment by Yama (YamashitaRen) - Tuesday, 25 February 2014, 16:22 GMT
New 10_linux still buggy.
New 10_Archlinux detect initramfs, append subvolume's name before /boot but still doesn't add the subvol parameter.
Comment by Keshav Amburay (the.ridikulus.rat) - Wednesday, 26 March 2014, 22:50 GMT
Please try 10_archlinux from https://aur.archlinux.org/packages/grub-git/ .
Comment by Tobias Powalowski (tpowa) - Monday, 07 April 2014, 14:56 GMT
Please try latest grub from testing.
Comment by Just Me (nilux) - Thursday, 10 April 2014, 04:47 GMT
Works for me with latest grub-git, only that a new error message appeared right after grub; "sparse file not allowed". However the system boots up fine.

Loading...