You are not logged in.

#1 2019-04-15 15:12:39

renordw
Member
From: New Mexico
Registered: 2018-03-04
Posts: 56

[SOLVED] How can I rename a BTRFS subvolume?

I am working on setting up Timeshift, and one of the requirements is for one of the subvolumes to be called @, instead right now mine is called @root.

It seems like it should be trivial to rename it, but I can't seem to figure out how to do it.

Last edited by renordw (2019-04-15 18:33:51)

Offline

#2 2019-04-15 16:22:37

WorMzy
Forum Moderator
From: Scotland
Registered: 2010-06-16
Posts: 11,844
Website

Re: [SOLVED] How can I rename a BTRFS subvolume?

You can just use mv. Remember to update any references to the old name in e.g. fstab/boot configs/scripts/etc.


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Online

#3 2019-04-15 17:18:59

renordw
Member
From: New Mexico
Registered: 2018-03-04
Posts: 56

Re: [SOLVED] How can I rename a BTRFS subvolume?

WorMzy wrote:

You can just use mv. Remember to update any references to the old name in e.g. fstab/boot configs/scripts/etc.

Thank you for the reply, but I am still confused... What exactly do I mv?

$ btrfs sub list /

ID 257 gen 36711 top level 5 path @root
ID 258 gen 36716 top level 5 path @var
ID 259 gen 36716 top level 5 path @home
ID 261 gen 36118 top level 258 path @var/lib/portables
ID 262 gen 36118 top level 258 path @var/lib/machines

$ cat /etc/fstab

UUID=6940ef85-e105-4090-9b7a-***  /                       btrfs             rw,noatime,compress=zstd,ssd,space_cache,commit=120,subvol=/@root                0  0
UUID=6940ef85-e105-4090-9b7a-***  /var                    btrfs             rw,noatime,compress=zstd,ssd,space_cache,commit=120,subvol=/@var                 0  0
UUID=6940ef85-e105-4090-9b7a-***  /home                   btrfs             rw,noatime,compress=zstd,ssd,space_cache,commit=120,subvol=/@home                0  0

I can't see that the name @root corresponds to an actual place in the file system...

Last edited by renordw (2019-04-15 17:21:07)

Offline

#4 2019-04-15 17:35:22

WorMzy
Forum Moderator
From: Scotland
Registered: 2010-06-16
Posts: 11,844
Website

Re: [SOLVED] How can I rename a BTRFS subvolume?

It's on the root of the btrfs filesystem (subvol=/). Since you're actively booted into @root, you'll need to boot a liveCD, mount the btrfs filesystem, and move the @root subvolume there (and update references, etc.)

Alternatively, you can just create a snapshot of @root called @ and boot that instead (again, updating refs.).


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Online

#5 2019-04-15 17:47:14

renordw
Member
From: New Mexico
Registered: 2018-03-04
Posts: 56

Re: [SOLVED] How can I rename a BTRFS subvolume?

WorMzy wrote:

It's on the root of the btrfs filesystem (subvol=/). Since you're actively booted into @root, you'll need to boot a liveCD, mount the btrfs filesystem, and move the @root subvolume there (and update references, etc.)

Alternatively, you can just create a snapshot of @root called @ and boot that instead (again, updating refs.).

Right. I like that second option way more! Thank you. I'll mark it solved after I don't fumble it up.

EDIT: Actually wound up doing the first...

For posterity's sake: just make sure to update fstab and your systemd-boot loader entry. (at least)

Last edited by renordw (2019-04-15 18:33:35)

Offline

#6 2019-09-06 16:21:02

cmurf
Member
Registered: 2019-09-06
Posts: 27

Re: [SOLVED] How can I rename a BTRFS subvolume?

It's possible to mount the top-level subvolume:

# mount -o subvolid=0 /dev/sda1 /mnt
# mount | grep btrfs
/dev/nvme0n1p7 on / type btrfs (rw,noatime,seclabel,compress=zstd:3,ssd,space_cache=v2,subvolid=274,subvol=/root)
/dev/nvme0n1p7 on /boot type btrfs (rw,noatime,seclabel,compress=zstd:3,ssd,space_cache=v2,subvolid=339,subvol=/boot)
/dev/nvme0n1p7 on /home type btrfs (rw,noatime,seclabel,compress=zstd:3,ssd,space_cache=v2,subvolid=258,subvol=/home)
/dev/nvme0n1p7 on /mnt type btrfs (rw,relatime,seclabel,compress=zstd:3,ssd,space_cache=v2,subvolid=5,subvol=/)

During btrfs development, the top-level subvolume was assigned ID 5, but ID 0 is aliased to 5, so take your pick, they can be used interchangeably. Some tools, e.g. snapper, make use of `btrfs subvolume set-default` which affects what subvolume is mounted with `mount` by default (if you omit subvol= or subvolid= options). At mkfs time, this is set to ID 5, so if it hasn't been changed, if you just mount with no options to /mnt, you'll see the top-level there.

It is possible to rename subvolumes while they're mounted, and `mount` will immediately show the change. It's not like you've just ripped out the subvolume from under your running system.

Last edited by cmurf (2019-09-06 16:23:09)

Offline

Board footer

Powered by FluxBB