Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Change root subvolume on btrfs

2,024 views
Skip to first unread message

piorunz

unread,
Oct 27, 2021, 11:20:04 PM10/27/21
to
Hello,

I have / partition on btrfs subvolume, default name @rootfs created by
Debian.

I'd like to use Timeshift for snapshots, but it only recognizes root on
@ subvolume, any other subvolume name is being ignored. Pretty stupid to
me, but I'd like to use it - I don't see other way to have snapshots.

Question:
How can I rename / subvolume on btrfs from @rootfs to @?
I tried:
rename folder name by hand from USB stick Linux Mint from @rootfs to @,
and then changing @rootfs to @ in /etc/fstab, but grub didn't booted, it
thrown me out to grub emergency console. I had to revert it back.

What else I need to do to make this change? Chroot to debian and do sudo
update-grub? If so, how? There is many conflicting tutorials how can I
chroot to do update-grub that I am lost. I will welcome any suggestions.

Some context:
$ sudo btrfs subvolume list /
ID 256 gen 176714 top level 5 path @rootfs
ID 265 gen 21191 top level 256 path var/lib/portables
ID 266 gen 21192 top level 256 path var/lib/machines

/etc/fstab lines:

UUID=77ba5989-5d64-4929-9145-ede6751a4102 /
btrfs
noatime,nodiratime,space_cache=v2,ssd,compress-force=zstd:6,subvol=@rootfs
0 1
(...)
UUID=9A94-D623 /boot/efi
vfat umask=0077 0 1

I use UEFI with GPT, no CSM, it that matters for anything.


--
With kindest regards, Piotr.

⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢠⠒⠀⣿⡁ Debian - The universal operating system
⢿⡄⠘⠷⠚⠋⠀ https://www.debian.org
⠈⠳⣄⠀⠀⠀⠀

Nito

unread,
Oct 29, 2021, 1:30:05 PM10/29/21
to
Disclaimer: I only have limited experience with btrfs
and never used it for root partition.

On Thu, Oct 28, 2021 at 04:10:08 +0100, piorunz wrote:
> I have / partition on btrfs subvolume, default name @rootfs created by
> Debian.
> [...]
>
> Question:
> How can I rename / subvolume on btrfs from @rootfs to @?

If it doesn't move to another parent folder,
just `mv`ing it is the correct approach afaik.

> I tried:
> rename folder name by hand from USB stick Linux Mint from @rootfs to @,
> and then changing @rootfs to @ in /etc/fstab, but grub didn't booted, it
> thrown me out to grub emergency console. I had to revert it back.

Maybe the grub command for booting also explicitly specifies the subvolume.
Can you take a look at the relevant line in /boot/grub/grub.cfg? (If you're
not sure what to look at, serach for the text of the netry you use in the
GRUB-menu, everything from there until a line starting with `initrd` could
possibly be relevant).
If yes, you'll need to change that in /etc/default/grub
and/or /etc/default/grub.d/* and then run update-grub as root.

> Some context:
> $ sudo btrfs subvolume list /
> ID 256 gen 176714 top level 5 path @rootfs
> ID 265 gen 21191 top level 256 path var/lib/portables
> ID 266 gen 21192 top level 256 path var/lib/machines

What does `sudo btrfs subvolume get-default /` tell you
before _and_ after you renamed the subvolume?
If it was @rootfs before but is not @ afterwards,
you'll need to set the default using
sudo btrfs subvolume set-default ...

piorunz

unread,
Nov 7, 2021, 7:10:04 AM11/7/21
to
Finally I have managed to do that!

Steps:

1. Find out what is the path to your root partition. You can use:
$ lsblk | grep "part /"
├─nvme0n1p1 259:1 0 512M 0 part /boot/efi
├─nvme0n1p2 259:2 0 37.3G 0 part /
└─nvme0n1p3 259:3 0 172G 0 part /mnt/ssd

So in my case / is on nvme0n1p2. Therefore, full path is /dev/nvme0n1p2.
Note that.

2. Boot to Linux USB stick. I used Linux Mint.

3. mount your / partition and navigate to it in terminal

4. Change btrfs subvolume name using sudo mv, in my example:
sudo mv @rootfs @

5. Edit /etc/fstab on your root partition, to tell it new name of
subvolume, like so: subvol=@, full line example here:
UUID=77ba5989-5d64-4929-9145-ede6751a4102 /
btrfs
noatime,nodiratime,space_cache=v2,ssd,compress-force=zstd:6,subvol=@ 0 1

6. sync && sudo reboot, remove USB stick

7. You will be greeted by grub emergency console of your system, as grub
don't know yet where is root partition now. Boot to your Linux using
following commands in grub console:

ls - use that to find where your root partition is in grub nomenclature.
You can do things like ls, then ls (hd5,gpt2)/@/ to browse contents to
btrfs partition to eventually find your root. Note that my root is on
(hd5,gpt2), which is similar to /dev/nvme0n1p2 (partition2 = gpt2).

Once you have your grub partition number, do:

set root=(hd5,gpt2)
linux /@/boot/vmlinuz/5.10.0-9-amd64 root=dev/nvme0n1p2 rootflags=subvol=@
initrd /@/boot/initrd.img-5.10.0-9-amd64
boot

As you see, set root=(hd5,gpt2) uses grub nomenclature and
root=dev/nvme0n1p2 uses normal nomenclature from lsblk.

8. So you are logged in to your system as normal. Generate new grub
config and install it into place:
sudo grub-mkconfig -o /boot/grub/grub.cfg

9. Reboot, grub will load as normal and you are fully in @ btrfs
subvolume and can use Timeshift now. Profit!
0 new messages