btrbk icon indicating copy to clipboard operation
btrbk copied to clipboard

btrbk-FAQ / How do I convert '/' (subvolid=5) into a subvolume? : How to get Grub2 to find the correct boot dir?

Open LittleAlf opened this issue 5 years ago • 2 comments

As a beginner I used the procedure described in btrbk-FAQ: How do I convert '/' (subvolid=5) into a subvolume? to convert my Debian stretch installation into a subvolume.

Since I was afraid to break the boot process I did not touch 'grub.cfg', but instead used the command described in the FAQ # btrfs subvolume set-default 330 / where 330 is the subvolid of '/rootfs

Everything worked:

  • '/' is now mounted on '/rootfs'
  • The top level '/' is now mounted on 'mnt/baseroot' using subvolid=5 in 'fstab'.

Everything was working as described in the FAQ procedure until I started moving the /boot directory in the top level '/' (via 'mnt/baseroot') into the directory 'TO_BE_REMOVED' as described in the btrbk-FAQ: After I moved this directory, the boot process failed with /boot/grub/ not found! It seems like Grub2 is accessing the boot files in /boot and not in /rootfs/boot! Even though I used 'btrfs subvolume set-default' as mentioned above. I think this is being followed only, once the Stretch image was started.

I then used a live-CD of Ubuntu to copy the /boot directory from my new '/' (= '/rootfs') aditionally into the top level '/'. Then Debian started again.

This is unfortunate, because I eventually want to do an upgrade to 'Buster'. I believe this upgrade will touch the Grub2 files as well as the boot sector. If I cannot correct this, the boot process might fail after the Buster upgrade.

How do I tell Grub2 that the correct boot directory is now in /rootfs/boot? I believe the proper entry in the EFI section must have this modified. And it should be reflected in the 'grub.cfg' too. Can I just use a 'grub-install' in the current system? (I have an UEFI boot, Debian only)? Do I need to prepare something else?

Any help is very much apprechiated. Maybe this point could be clarified in the corresponding FAQ as well.

LittleAlf

Apart from the described problem 'btrbk' is working as expected and the snapshots are properly created and copied. Thanks for this great tool. :)

LittleAlf avatar Jul 13 '20 20:07 LittleAlf

I could solve it myself! :)

Since the system was booting fine and after Boot everything was set up correctly, I just followed the procedure described in GrubEFIReinstall under Reinstalling grub-efi on your hard drive. Everything went smoothly.

After the restart I checked the newly created grub.cfg. The decisive difference to the previous grub.cfg was:

Old: linux /boot/vmlinuz-4.19.0-0.bpo.9-amd64 root=UUID=5d6d56d3-ae0b-45c3-a309-4878c913c3fa ro

New: linux /rootfs/boot/vmlinuz-4.19.0-0.bpo.9-amd64 root=UUID=5d6d56d3-ae0b-45c3-a309-4878c913c3fa ro single rootflags=subvol=rootfs

The /rootfs is now the preceeding directory for the 'vmlinuz-4.19...' file, and the rootflags=subvol=rootfs parameter is set.

It appears, that you have to follow this procedure if you use the # btrfs subvolume set-default <subvolid> / command as described in How do I convert '/' (subvolid=5) into a subvolume? section of the btrfk FAQ.

This issue can now be closed!

LittleAlf avatar Aug 06 '20 20:08 LittleAlf

Thanks for the insight! It might be worth mentioning in the FAQ, but if I understand it correctly what you are describing here is: "if you follow the grub docs, the grub.cfg is created correctly". (one reason why I don't auto-generate grub.cfg on my systems...)

digint avatar Aug 20 '20 16:08 digint