btrfs-progs
duperemove
https://wiki.archlinux.org/title/Snapper#Suggested_filesystem_layout
This allows for rolling the rootfs back to a snapshotted version, since the rootfs isn't tied to vol-id 5, anymore.
Debian installer uses /@rootfs
as the subvol /
, instead of @
. See https://wiki.debian.org/Btrfs%20migration for more information.
When you need to make /@
level changes, you will still need to mount subvol-id 5 in /mnt.
sudo mount /dev/nvme0n1p3 /mnt
- Label the main/root btrfs filesystem
root-btrfs
and the boot filesystemboot-btrfs
.
sudo chattr +C /var/lib/libvirt/images
sudo chattr +C ~/.local/share/libvirt/images
sudo chattr +C ~/.local/share/gnome-boxes/images
sudo mount /dev/disk/by-label/root-btrfs -osubvolid=5 /mnt
sudo btrfs subvolume create /mnt/@swap
sudo chmod u=rwx,g=,o= /mnt/@swap
sudo umount /mnt
sudo mkdir /var/swap
sudo chmod u=rwx,g=,o= /var/swap
# Edit /etc/fstab to mount @swap to /var/swap.
sudo systemctl daemon-reload
sudo mount /var/swap
sudo btrfs -v filesystem mkswapfile -s 8g /var/swap/swapfile1
sudo ls -al /var/swap
# Edit /etc/fstab and add the following line:
# /var/swap/swapfile1 none swap defaults 0 0
sudo swapon -a
sudo swapon
# Example mount line for the swap subvol:
# sudo mount /dev/disk/by-label/root-btrfs -osubvol=@swap /var/swap
sudo btrfs device add -f /dev/mapper/root2_crypt /
sudo btrfs balance start -dconvert=raid1 -mconvert=raid1 /
sudo btrfs scrub start /
sudo btrfs scrub status /
sudo btrfs filesystem defragment -r /
sudo duperemove -rdh /
# Or, you can speed things up with a hashfile, which will then
# use the save hash if the timestamp matches.
sudo duperemove -rdh -A --hashfile=/duperemove_hashfile /
The -A
allow it to work over readonly snapshots.
Warning: Running duperemove
cannot effectively remege/resnapshot two unrelated subvolumes/snapshots. I did the following experiment, to test this. Restore root and home from a backup, manually using rsync. I then used btrfs send/receive to send the same backup as a subvolume to the machine being restored. I ran duperemove
many times, but the most storage space I could recover/merge was about 200GB of 800GB. I still had a massive 600GB of undedupeable additional storage being consumed by this subvol that contains identical data to my main subvols.
- snapper
- snapper-gui
- btrfs-assistant
- btrfsmaintenance
- btrbk