this post was submitted on 30 Oct 2023
48 points (100.0% liked)

Linux

48181 readers
968 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 5 years ago
MODERATORS
 

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?

Edit:

Everything went smoothly. Well just don't fuck up fstab like I did. Decided not to make /var into a subvolume because not sure if you can do it the same way, thinking that logs etc are being written all the time so the gap between me copying everything to the subvolume, and eventually booting might make weird things but dunno. Also added compress=zstd into fstab mount options to reduce writes on the ssd.

you are viewing a single comment's thread
view the rest of the comments
[–] skullgiver@popplesburger.hilciferous.nl 3 points 1 year ago* (last edited 11 months ago) (4 children)

[This comment has been deleted by an automated system]

[–] AnonStoleMyPants@sopuli.xyz 1 points 1 year ago (3 children)

Could you just not include home in the automatic snapshots?

[–] skullgiver@popplesburger.hilciferous.nl 1 points 1 year ago* (last edited 11 months ago) (2 children)

[This comment has been deleted by an automated system]

[–] Gobbel2000@feddit.de 1 points 1 year ago (1 children)

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.

[–] skullgiver@popplesburger.hilciferous.nl 1 points 1 year ago* (last edited 11 months ago)

[This comment has been deleted by an automated system]