[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#983107: os-prober: generic subvolume support for btrfs



Hi,

Knowing bulleseye 11 release is near and this issue may stay, people
may need to work around this issue of btrfs subvolume as root
partition.  Here is my WORKAROUND suggestion.

(Please note that my patch proposal in my original bug report is not-
yet tested well.)

The current Debian Grub2 code at /etc/grub.d/30_os-prober requires to
access some root partion contents from the btrfs ID 5 (FS_TREE) to
function well.  (subvol=/)  

If you want to use timeshift (Ubuntu origin?) or snapper (Suse origin
?), they seem to use non-ID-5 subvol for the system install, i.e.,
root-FS.  People use these tools on Debian too.

https://qa.debian.org/popcon-graph.php?packages=timeshift+snapper+snapper-gui+btrbk+btrfsmaintenance+duperemove&show_installed=on&want_legend=on&want_ticks=on&from_date=&to_date=&hlght_date=&date_fmt=%25Y-%25m&beenhere=1


=== WORKAROUND ===

Let's suppose your another linux installation on another formatted in
btrfs at partion "/dev/nvme1n1p1" has its root-FS content in
"subvol=@", please perform followings:

-----
$ sudo mount -t btrfs -o subvol=/,defaults /dev/nvme1n1p1 /mnt
$ cd /mnt
$ sudo ln -sf @/boot boot
$ sudo ln -sf @/etc  etc
$ sudo ln -sf @/usr  usr
$ sudo ln -sf @/lib  lib
$ sudo ln -sf @/initrd.img initrd.img
$ sudo ln -sf @/vmlinuz    vmlinuz
$ sudo ln -sf @/initrd.img.old initrd.img.old
$ sudo ln -sf @/vmlinuz.old    vmlinuz.old
$ sudo btrfs subvol set-default /mnt/@
$ cd /
$ sudo umount /mnt
-----

This assumes you do not have conflicting contents in subvol=/.

If you happen to use other subvol for the root-FS content, replace its
subvol name in place of "@".


=== Additional Tips ===

You can convert a system from EXT2/3/4 to btrfs as follows by booting
system from another system on the multiboot set-up.

File system conversion is trivial as described in
https://btrfs.wiki.kernel.org/index.php/Conversion_from_Ext3

-----
$ sudo fsck.ext3 -f /dev/xxx
$ sudo btrfs-convert /dev/xxx
$ sudo mount -t btrfs /dev/xxx /mnt
-----

You need to make some adjustment to cope with new filesystem ant its
new blkid by adjustng at least /etc/fstab and /boot/grub/grub.cfg .

Please note UUID of partition changes after btrfs-convert.
Please check 

-----
--- fstab.orig  2021-02-19 14:49:32.768895933 +0900
+++ fstab       2021-02-19 14:49:19.860921576 +0900
@@ -6,6 +6,6 @@
 #
 # <file system> <mount point>   <type>  <options>       <dump>  <pass>
 # / was on /dev/nvme1n1p1 during installation
-UUID=491a357c-822f-4f38-b56e-b998baea81a5      /       ext4 
errors=remount-ro 0       1
+UUID=9be0d928-5892-4cdd-a647-1e8cce937b2e      /       btrfs defaults
0       1
 # /boot/efi was on /dev/nvme0n1p1 during installation
-----


Also, you need to update many relevant parts of grub.cfg, too.  Roughly
as ...
-----
--- grub.cfg-orig       2021-02-17 09:32:35.855910912 +0900
+++ grub.cfg    2021-02-19 14:26:12.728005239 +0900
...
-insmod ext2
+insmod btrfs
...
-  search --no-floppy --fs-uuid --set=root  491a357c-822f-4f38-b56e-
b998baea81a5
+  search --no-floppy --fs-uuid --set=root  9be0d928-5892-4cdd-a647-
1e8cce937b2e
...
-       linux   /boot/vmlinuz-5.10.0-3-amd64 root=UUID=491a357c-822f-
4f38-b56e-b998baea81a5 ro  quiet
+       linux   /boot/vmlinuz-5.10.0-3-amd64 root=UUID=9be0d928-5892-
4cdd-a647-1e8cce937b2e ro  quiet
...
-----

The UUID change to the "linux ..." line is important since it will
affect how this alternative partion update is grub configuration.

If you wish to move all this nely migrated system to a subvolume, just
snapshot it to "@" or anything you like using "btrfs subvolume snapshot
/mnt /@" command.

Of course, if your new system is at subvol=@, you need to adjust
/etc/fstab as;

-----
--- fstab.orig  2021-02-19 14:49:32.768895933 +0900
+++ fstab       2021-02-19 14:49:19.860921576 +0900
@@ -6,6 +6,6 @@
 #
 # <file system> <mount point>   <type>  <options>       <dump>  <pass>
 # / was on /dev/nvme1n1p1 during installation
-UUID=491a357c-822f-4f38-b56e-b998baea81a5      /       ext4 
errors=remount-ro 0       1
+UUID=9be0d928-5892-4cdd-a647-1e8cce937b2e      /       btrfs
subvol=@,defaults 0       1
 # /boot/efi was on /dev/nvme0n1p1 during installation
-----

And then move on to use WORKAROUND as described in the above.

On Fri, 2021-02-19 at 14:12 +0000, Debian Bug Tracking System wrote:
> ...
> You can follow progress on this Bug here: 983107:
> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=983107.


Reply to: