Using btrfs subvolumes

I would like to move individual subfolders (e.g. “Videos”) of my /home directory to another partition (but not the complete home directory!). I thought that the best way to do this would be to format the new partition with btrfs and then mount the individual folders (“Videos”, “Documents”, …) as subvolumes, which I then mount in the corresponding “original” folders (“/home/Videos”, …). As I have no experience with the functionality and mounting of subvolumes, I would like to know how this should look like in “fstab”!
For example, to mount the “Videos” folder of the new partition as a subvolume, I would use the following line (based on existing entries in fstab, but maybe not correct for my purpose?):

UUID=13141c0b-6ccc-425c-adf5-1303cb118021 /Videos btrfs subvol=/@/Videos 0 0

(“13141c0b-6ccc-425c-adf5-1303cb118021” is the UUID of the extra partition with the “Videos”, “Documents”, … folders)
What should the line look like with which I can then mount this subvolume under “/home/Videos”?

If you are using KDE Plasma, simply point the file path to the directory/drive/partition you want. It is under systemsettings.

Oh, that simple, THANKS!

Does not wok, because the extra partition was only mounted temporarily in “/run/media/micha/home/” and no fstab-entry for a static mount was created. I could now create a static mount for the extra partition (to /mnt) manually, and then use the redirection of Plasma, but I also need to use the folders of the extra partition in Ubuntu (installed on a separate ssd), so a fstab-solution would be best!

If you’re creating a new btrfs filesystem on the extra partition/device, then its subvolumes will have to created manually but it’s quite easy:

# Create btrfs subvolumes
mount /dev/path-to-your-device /mnt
cd /mnt
btrfs sub cr @videos
btrfs sub list /mnt
cd ~
umount /mnt

To mount using fstab:

UUID=your-device-uuid /home/Videos  btrfs  subvol=@videos,defaults,noatime  0  0
1 Like

Thanks, so I missunderstood how subvolumes are created, not via mount in fstab!
Although the steps for creating subvolumes are easy to understand, I have to memorize/notate them. For example, if I delete the “Videos” folder (from the extra partition) and then create it again, everything looks the same as before, but I have to remember that I have to make this folder a subvolume again so that mounting this subvolume using fstab works.
I have now done a bit of googling and came across bind-mounts. I could then format the partition with ext4 again and mount it to /mnt/home and bind-mount /mnt/home/Videos to /home/Videos (both via fstab). This would document all the necessary steps in fstab! Are there any objections to this method?

You are making it to complicated. You only need another partition. E.g. on /dev/sdb1. This partition needs to be mounted via fstab (details like filesystem doesn’t matter here). Create the wanted directorys (Videos, Documents,…): e.g. (/dev/sdb1)/datapartition/Videos/ on this partition.

Now you only need to set the file path (as shown in my first comment in systemsettings) to these directorys on the new partition. After that you can delete the “original” directorys which you have under your (/dev/sda1)/home. Done! A job of 2 minutes.

P.S.: sdb1 and sda1 are only device examples to show you the concept. Adapt to your need.

Thanks for the help, but I want to keep the original folder structure, otherwise I could simply mount the external partition in a subdirectory of home! I did it now like this (example for the “Videos”-folder), which works as expected:

fstab:
UUID=ba8585ac-e078-4877-bfaf-3deea1be167e /mnt/home_all ext4 defaults,nofail
/mnt/home_all/Videos /home/micha/Videos none bind

I’m just wondering whether the

/mnt/home_all/Videos /home/micha/Videos none bind

also needs a “nofail” to not stop the boot process if the bind-mount fails?

If anyone is interested, I have now added “nofail” to the bind-mount!
The whole thing looks like this now:

UUID=ba8585ac-e078-4877-bfaf-3deea1be167e /mnt/home_all ext4 defaults,nofail
/mnt/home_all/Videos /home/micha/Videos none bind,nofail
/mnt/home_all/Documents /home/micha/Documents none bind,nofail
/mnt/home_all/Music /home/micha/Music none bind,nofail
/mnt/home_all/Pictures /home/micha/Pictures none bind,nofail
/mnt/home_all/programs /home/micha/programs none bind,nofail
1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.