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?

  • 0v0@sopuli.xyz
    link
    fedilink
    arrow-up
    1
    ·
    1 year ago

    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 / as subvol=@, and /home as subvol=@home.