So I installed Debian 12 with btrfs and apparently it only uses a single subvolume rootfs
. I would like to have my /home
in a separate subvolume (and possibly /var
too I guess) and with a flat subvolume structure. I started figuring out on how to do it and I feel like I’m not entirely sure yet so I need a sanity check.
Lots of comments online seem to use something like this method:
cd /
mv /home /home_old
btrfs subvolume create home
cp -a --reflink=always /home_old/* /home/
But this would NOT create a flat subvolume structure, right? And you woul NOT need to modify fstab
as the /home
would be automatically mounted because it resides under rootfs
actually because /
is rootfs
and not its parent?
If I want to actually have a flat structure, then I would first need to mount the actual parent subvolume (subvolumeid=5), cd into it, then create the home
subvolume, copy everything from the current home
directory into there, unmount, modify fstab
to mount home
, and delete the old stuff and reboot I guess.
Soo something like this:
mkdir /mnt/tmp
Make a folder for mount
mount -o subvolid=5 /dev/sdXX /mnt/tmp/
Mount the actual parent subvolume
cd /mnt/tmp/
Here 'ls -a' would output 'rootfs' if I understood correctly
btrfs subvolume create home
Create new subvolume, now being sibling of 'rootfs'
cp -a --reflink=always /home/* /mnt/tmp/home/
Copy old /home
umount /mnt/tmp/
Don't need it anymore
Then go to fstab
, and do something like
...
UUID= / btrfs subvol=rootfs bunch_of_options_and_stuff
...
-> change into
...
UUID= / btrfs subvol=rootfs bunch_of_options_and_stuff
UUID= /home btrfs subvol=home bunch_of_options_and_stuff
...
Then just rm -rf /home/
(or just move to keep it as backup if something is fucked up) and reboot?
Does this sound about right?
This seems right and exactly the way I’ve set it up. On subvolid=5 I have subvolumes
and
@home
, in/etc/fstab
I mount/
assubvol=@
, and/home
assubvol=@home
.Yes, that seems correct to me. I would also say that the flat layout is preferable because it makes dealing with snapshots later easier. When snapshotting the rootfs subvolume you won’t have to keep track of where exactly the home subvolume is located and it is easier to boot into a different rootfs snapshot.
[This comment has been deleted by an automated system]
Could you just not include home in the automatic snapshots?
[This comment has been deleted by an automated system]
I still don’t see how having a flat subvolume layout would make that more problematic. You can still (even better in my opinion) choose what subvolumes to automatically snapshot, which to include in backups etc.
[This comment has been deleted by an automated system]