Treatment of BTRFS-Subvolumes in

As this isn’t a bug per se, and I’‘m not sure where it would belong I am raising this here.

BTRFS has a feature called subvolumes, which is somewhat comparable to LVM, as it allows to have different sub-filesystems in one partition.

The way this is handled in KDE (and Dolphin, where I noticed that) is that subvolumes are treated in a way I do not quite understand.

Take the following lsblk:

NAME        MAJ:MIN RM  SIZE RO TYPE  MOUNTPOINTS
sda           8:0    0  1,9T  0 disk  
└─sda1        8:1    0  1,9T  0 part  /mnt/datafs
                                      /mnt/gamefs
nvme0n1     259:0    0  1,8T  0 disk  
├─nvme0n1p1 259:1    0    1G  0 part  /boot
└─nvme0n1p2 259:2    0  1,8T  0 part  
  └─root    253:0    0  1,8T  0 crypt /var/lib/libvirt/images
                                      /var/log
                                      /home
                                      /swap
                                      /.snapshots
                                      /

Mount points are configured like this:

/dev/mapper/root on / type btrfs (rw,relatime,ssd,space_cache=v2,subvolid=256,subvol=/@)
/dev/mapper/root on /.snapshots type btrfs (rw,relatime,ssd,space_cache=v2,subvolid=260,subvol=/@snapshots)
/dev/mapper/root on /swap type btrfs (rw,relatime,ssd,space_cache=v2,subvolid=261,subvol=/@swap)
/dev/mapper/root on /home type btrfs (rw,relatime,ssd,space_cache=v2,subvolid=257,subvol=/@home)
/dev/mapper/root on /var/log type btrfs (rw,relatime,ssd,space_cache=v2,subvolid=258,subvol=/@var_log)
/dev/mapper/root on /var/lib/libvirt/images type btrfs (rw,relatime,ssd,space_cache=v2,subvolid=259,subvol=/@libvirt)
/dev/nvme0n1p1 on /boot type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro)
/dev/sda1 on /mnt/gamefs type btrfs (rw,noatime,ssd,discard=async,space_cache=v2,subvolid=259,subvol=/@gamefs)
/dev/sda1 on /mnt/datafs type btrfs (rw,relatime,ssd,discard=async,space_cache=v2,subvolid=258,subvol=/@datafs)

The root-filesystem, which is a btrfs-subvolume called @ is treated as the root filesystem and shows up as it’s own device. The other subvolumes do no show up as their own device - which is in this situation actually what the user would expect.

However, for the seconds drive /dev/sda1 this does not quite work, as only the dataFS mount point is shown by dolphin. This may be due to it being mounted before gameFS in fstab. As their mountpoint is not hierarchical, i.e. they are both mounted in seperate dirs in /mnt in contrast to the root filesystems, which are all somewhere under /.

It could be that I do not understand how it is supposed to work, but I found it unreasonable to only show only one subvolume per partition

1 Like

That’s rightful place to raise this issue.

We don’t have have a good btrfs/cachefs support story in dolphin, at this moment.
We (dolphin contributors) are very much aware of it.

Firstly, because our libraries don’t support it well, in particular framework Solid which is the backend for the places panel.

Support is being worked on for the trash at this very moment. So that trash are kept within their subvolumes.

The end goal is not just support for subvolumes, but snapshots and the ability to mount them or restore individual files from dolphin.

But that will take a while…

3 Likes

This is super interesting, thanks for the background!

I finally put those into writing in an issue Improve Btrfs User story (#82) · Issues · System / Dolphin · GitLab

Hopefully we can divide the work against several contributors.

1 Like