You are not logged in.

#1 2024-03-15 14:36:46

kvaziq
Member
Registered: 2024-03-15
Posts: 2

Creating btrfs subvolumes after installation

Greetings,

I am a new Linux user. I've installed Arch Linux a few months ago and I like it. Now, I want to create backups of my system using snapshots, as it is possible I mess up something from time to time. During installation I've set my system to use the btrfs filesystem, but I did not setup any subvolumes. This is how my lsblk looks like:

sdb       8:16   0 931.5G  0 disk
├─sdb1    8:17   0   260M  0 part
├─sdb2    8:18   0    16M  0 part
├─sdb3    8:19   0     2G  0 part /boot/efi
├─sdb4    8:20   0     8G  0 part [SWAP]
├─sdb5    8:21   0 223.9G  0 part /
├─sdb6    8:22   0 672.4G  0 part
└─sdb7    8:23   0    25G  0 part

I've read that it is good practice to setup a different subvolumes for the / directory and for the /home directory. Almost all guides are for doing this during installation. Seems this one is applicable, but i guess it has to be done from a live usb: https://www.reddit.com/r/archlinux/comm … umes_post/
Is this guide correct and is it possible to create new subvolumes for / and /home so long after installation without data loss or reinstalling everything? I am asking to be sure as I do not want to mess up everything I've configured so far.

Thank you in advance.

Offline

#2 2024-03-16 21:46:39

ectospasm
Member
Registered: 2015-08-28
Posts: 303

Re: Creating btrfs subvolumes after installation

It's always good to read the official Btrfs documentation, especially the Btrfs SysadminGuide (I know this is on the archived/outdated Btrfs wiki, but I couldn't find this article on the new documentation site).

There will be tradeoffs in how you set it up, and it is possible that you've already gone beyond using subvolumes if you didn't already start using them from the beginning.  On my new laptop, I have a Btrfs top-level subvolume called top (the device file is /dev/mapper/top once I've unlocked the LUKS2 container it resides in), and my root subvolume (mounted at /) is the first subvolume I created.  I have a separate /home subvolume, which is a subvolume of my root subvolume (not top, but there's no reason it couldn't be a subvolume of top).

What I would do for your setup is create a rw (read/write) snapshot (aka, a subvolume) of your top-level subvolume (which already exists, it may be /dev/mapper/root), and make that your default subvolume (see the documentation for what that means).  Then move/rename your /home directory to a new temporary name, then make a new rw subvolume for /home, and copy the contents of the moved/renamed /home to this new /home.

Then, once / and /home are on different subvolumes, you can use snapper to set up automatic read-only snapshots (see the Snapper wiki title for details).

Offline

#3 2024-03-18 10:47:45

kvaziq
Member
Registered: 2024-03-15
Posts: 2

Re: Creating btrfs subvolumes after installation

Thank you for your response! I will try to this over the weekend most probably.

Offline

Board footer

Powered by FluxBB