You are not logged in.

#1 2022-08-05 09:52:12

jfabernathy
Member
From: North Carolina
Registered: 2019-01-03
Posts: 123

btrfs differences between Distros?

I'm trying to get smarter on btrfs, snapper, and timeshift.  So like many, I watch a lot of Youtube videos and play with a lot of VMs to experiment.

I find one thing that is really confusing and that is how mounting a root subvolume for maintenance at the subvolume level is done differently between distros.

As an example, if I'm in Archlinux and want to move snapshots around I want access to the whole snapshots world so I mount this way.

mount -o subvolid=5 /dev/sda3 /mnt

That partition is mounted in fstab as:

UUID=klsdjfldkfjslkfj  /   btrfs  defaults,subvol=@,compress=zstd,......

So my root subvolume is mounted for normal use at / as normal, but after the first mount above I have the /mnt look like:

ls /mnt
@  @home  @snapshots

So my confusion comes when I watch or read a btrfs tutorial where they are using an ubuntu/debian distro, they don't need the subvolid=5 that I needed for Archlinux. They just use:

mount /dev/sda3 /mnt

to see the same subvolume structure.

Anyone know why the differences?

Offline

#2 2022-08-05 11:19:44

Scimmia
Fellow
Registered: 2012-09-01
Posts: 11,466

Re: btrfs differences between Distros?

If you don't specify a subvol, the default subvol is used.

Offline

#3 2022-08-05 12:05:06

jfabernathy
Member
From: North Carolina
Registered: 2019-01-03
Posts: 123

Re: btrfs differences between Distros?

Scimmia wrote:

If you don't specify a subvol, the default subvol is used.

Thanks for your help.  I'm still having issues really understanding this. They didn't have btrfs back in the '60s on IBM System 360. :-)

here is my fstab:

# <file system>             <mount point>  <type>  <options>  <dump>  <pass>
UUID=C173-C18E                            /boot/efi      vfat    defaults,noatime 0 2
UUID=09158dc0-4ab9-4401-9c3e-b3a3855a03c1 /              btrfs   subvol=/@,defaults,noatime,compress=zstd 0 0
UUID=09158dc0-4ab9-4401-9c3e-b3a3855a03c1 /home          btrfs   subvol=/@home,defaults,noatime,compress=zstd 0 0
UUID=09158dc0-4ab9-4401-9c3e-b3a3855a03c1 /.snapshots    btrfs   subvol=/@snapshots,defaults,noatime,compress=zstd 0 0
UUID=09158dc0-4ab9-4401-9c3e-b3a3855a03c1 /var           btrfs   subvol=/@var,defaults,noatime,compress=zstd 0 0

and here is my subvol list:

ID 257 gen 290 top level 5 path @home
ID 258 gen 272 top level 5 path @snapshots
ID 259 gen 290 top level 5 path @var
ID 260 gen 25 top level 259 path @var/lib/portables
ID 261 gen 26 top level 259 path @var/lib/machines
ID 263 gen 63 top level 258 path @snapshots/1/snapshot
ID 264 gen 64 top level 258 path @snapshots/2/snapshot
ID 265 gen 174 top level 258 path @snapshots/3/snapshot
ID 268 gen 113 top level 258 path @snapshots/6/snapshot
ID 269 gen 114 top level 258 path @snapshots/7/snapshot
ID 270 gen 115 top level 258 path @snapshots/8/snapshot
ID 271 gen 116 top level 258 path @snapshots/9/snapshot
ID 272 gen 126 top level 258 path @snapshots/10/snapshot
ID 273 gen 285 top level 5 path @
ID 274 gen 173 top level 258 path @snapshots/11/snapshot
ID 275 gen 186 top level 258 path @snapshots/12/snapshot
ID 276 gen 242 top level 258 path @snapshots/13/snapshot
ID 277 gen 269 top level 258 path @snapshots/14/snapshot
ID 278 gen 270 top level 258 path @snapshots/15/snapshot

Note that:

sudo btrfs su get-default /
ID 275 gen 186 top level 258 path @snapshots/12/snapshot

Drives look like this:

NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
sr0     11:0    1 1024M  0 rom  
vda    254:0    0   50G  0 disk 
├─vda1 254:1    0  300M  0 part /boot/efi
└─vda2 254:2    0 49.7G  0 part /home
                                /var
                                /.snapshots
                                /

So if I mount without the subvolid I set this:

sudo mount /dev/vda2 /mnt 
ls /mnt
bin  boot  dev  etc  home  lib  lib64  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var

However, if I switch to using subvolid I see this:

sudo umount /mnt
sudo mount -o subvolid=5 /dev/vda2 /mnt 
ls /mnt
@  @home  @snapshots  @var

This is what I see in Archlinux tutorials on working with subvols where subvolid=5 is like some god mode looking down above everything.  Whereas if I look at a newly install Linux Mint 21 with btrfs I see

sudo btrfs su get-default /
ID 5 (FS_TREE)

And the mounts without subvolid=5 shows this:

sudo mount /dev/nvme0n1p3 /mnt
ls /mnt
@  @home  snapshots  timeshift-btrfs

So maybe something about snapper's usage did a set-default to some id and was not 5 and that's why I needed to use ID 5 to get to god mode as I call it.

Offline

#4 2022-08-05 14:23:13

ratcheer
Member
Registered: 2011-10-09
Posts: 912

Re: btrfs differences between Distros?

I think you are confusing the btrfs root subvolume (ID=0 or 5) with the Linux /  (which is called the root directory). They can be, but don't have to be the same btrfs subvolume. For example, on my system:

UUID=20db1fe2-60a4-4eb7-87ac-1953a55dda16       /               btrfs           rw,relatime,ssd,space_cache,subvolid=460,subvol=/@              0 0

Note that the subvolume id is 460. It is a subvolume of the btrfs root subvolume. You have to make sure how your system has configured this, or manage it yourself.

As to different distros doing it differently, I don't think so. btrfs is now part of the kernel, and the package that provides the tools (btrfs-progs in Arch Linux) is also provided by the btrfs upstream developers.

PS - I would never put the Linux / in the btrfs root subvolume, but that is me. I also think most people do not.

Last edited by ratcheer (2022-08-05 14:25:44)

Offline

#5 2022-08-05 20:03:52

jfabernathy
Member
From: North Carolina
Registered: 2019-01-03
Posts: 123

Re: btrfs differences between Distros?

@ratcheer Thanks, it's getting a little clearer.

Offline

Board footer

Powered by FluxBB