Document how to use Anaconda with BTRFS suvolumes surviving a new installation

Document how to use Anaconda with BTRFS suvolumes surviving a new installation.
Like many I do like the /home directory (and more subvolumes) to survive an reinstall of Linux Fedora.
I have done this for years, with ext4, xfs, etc…

Now with BTRFS I found it impossible with Anaconda :custom install" to reinstall Fedora without deleting some subvolumes, I need to keep, usually the one where /home is mounted.

It would also be nice to preserve the .ks file(s) to reinstall a new (or current) version with more or less the same user’s installed packages… the /home directory mat be a good place to put this, and a simple “Preserve /home” in Anaconda installer.

Thanks for the attention.

Definitely good material for Fedora Magazine. :slight_smile: +1

I did this recently with the advanced “blivet” installation:
1 - Removed the root volume
2 - re-created the root volume
3 - Assigned mount point on root and home volume
4 - Assigned mount point on EFI opening.

I managed to finish the installation without problems, keeping the home volume.
In my case I had other volumes, for example “flatpak”, I kept it and I found all the flatpak APPs installed.
Actually I have several, but home and flatpak are the volumes that I have kept, for the rest I have removed and recreated them.
The only note, at the end of the installation, the installer stopped a few minutes on SELinux, surely it recreated the contexts?

emanu@fedora ~> sudo btrfs subvol list /
ID 261 gen 4122114 top level 5 path var_lib_flatpak
ID 933 gen 4122185 top level 5 path @home
ID 941 gen 4122185 top level 5 path @
ID 942 gen 4122185 top level 5 path var_log
ID 943 gen 4122185 top level 5 path var_tmp
ID 944 gen 4122118 top level 5 path var_cache
ID 947 gen 4121983 top level 5 path libvirt_homeuser
ID 951 gen 4122117 top level 5 path var_lib_libvirt


emanu@fedora ~> cat /etc/fstab

# /etc/fstab
# Created by anaconda on Mon Aug 23 18:24:18 2021
# Accessible filesystems, by reference, are maintained under '/dev/disk/'.
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info.
# After editing this file, run 'systemctl daemon-reload' to update systemd
# units generated from this file.
UUID=1dfbd78c-313d-44a6-9612-2c7b45bed032 /                       btrfs   noatime,compress=zstd:1,autodefrag,subvol=@ 0 0
UUID=4323-EA93          /boot/efi               vfat    umask=0077,shortname=winnt 0 2
UUID=1dfbd78c-313d-44a6-9612-2c7b45bed032 /home                   btrfs   noatime,compress=zstd:1,autodefrag,subvol=@home    0 0
UUID=1dfbd78c-313d-44a6-9612-2c7b45bed032 /var/cache              btrfs   noatime,compress=zstd:1,autodefrag,subvol=var_cache 0 0
UUID=1dfbd78c-313d-44a6-9612-2c7b45bed032 /var/lib/flatpak        btrfs   noatime,compress=zstd:1,autodefrag,subvol=var_lib_flatpak 0 0
UUID=1dfbd78c-313d-44a6-9612-2c7b45bed032 /var/lib/libvirt        btrfs   noatime,compress=zstd:1,autodefrag,subvol=var_lib_libvirt 0 0
UUID=1dfbd78c-313d-44a6-9612-2c7b45bed032 /var/log                btrfs   noatime,compress=zstd:1,autodefrag,subvol=var_log 0 0
UUID=1dfbd78c-313d-44a6-9612-2c7b45bed032 /var/tmp                btrfs   noatime,compress=zstd:1,autodefrag,subvol=var_tmp 0 0
# Mount VM libvirt home utente
UUID=1dfbd78c-313d-44a6-9612-2c7b45bed032 /home/emanu/libvirt     btrfs   noatime,autodefrag,subvol=libvirt_homeuser 0 0
# Mount vari dischi
LABEL=backup /media/emanu/backup btrfs compress-force=zstd:10,autodefrag,nofail,noauto 0 0
UUID=f265041b-2c7c-4135-b0c9-ab424428b3d1 /media/emanu/game/ btrfs noatime,compress-force=zstd,autodefrag,subvol=@game 0 0
UUID=0c249f5b-1c96-4ed8-83f3-62bea79504da /media/emanu/dati/ btrfs noatime,compress-force=zstd,autodefrag,subvol=@dati 0 0
LABEL=backup2T /media/emanu/backup2T btrfs noatime,compress-force=zstd:10,autodefrag,nofail,noauto 0 0

QA:Testcase partitioning custom btrfs preserve home might help as a template.

There is an unfortunate bug right now, btrfs compression isn’t set if the user renames a mountpoint’s subvolume. We might need to hold publishing any advice until Fedora 35 ships, to know whether it will be fixed for final release. It will not be fixed for Fedora 35, so it’s up to the discretion of the author of the article whether the bug should be given a mention.

1 Like

thanks a lot for your reply.
With fstab.

@agompel +1 Taiga card #396 has been created for this article

@agompel It looks like you have a FAS account but have not signed the FPCA.

You can sign the FPCA by signing in to your FAS account at
Select the “Edit Profile” button
Find and select the “Agreements” tab

Once you have done that, please log into Taiga so we can assign the card to you.

Information on writing for the Magazine is located here.

Please let us know if you have questions, and thanks for volunteering to help on the Fedora Magazine.