Reinstalling Fedora while keeping /home partition

It might be useful to describe my situation:

It was late at night and I was very, very tired, recovering deleted photos using photorec. After it had finished, it made root-owned folders with lots of deleted photos, which I could not remove even using sudo. So, I went to “sudo su” and typed, out of bad habit, sudo rm -rf /*. I realized my horrible mistake 3 seconds later, pressed Ctrl + C, and shutdown my computer.

I booted into the computer with a live fedora usb, mounted my drive read-only, to discover that all had remained was /home and /root with some files that I hope were untouched. During my original installation, I made a separate /home partition. So can I just reinstall Fedora while not wiping my /home, and how would I do that? Any other advice is appreciated. Thanks :grin:

Not a direct answer to your question, but you could make a backup of /home, then do a fresh install and restore the files. While in the live USB environment, you should be able to rsync the files to somewhere or maybe even attach an external disk, create a BTRFS filesystem on it, and try to take a snapshot of what’s remaining of the old file system and btrfs send it to the external disk. All of this assumes there’s still enough left of /home to backup.

This is why one should ALWAYS proofread the commands before pressing enter.
You are not the first to make this type of error so don’t feel too bad about it.

The suggestion above seems the simplest, though I have seen posts here that suggest that one may do a reinstall even with a btrfs file system and reuse the existing home subvolume. I have not committed to btrfs yet so cannot provide better info.

Thanks for the responses. As @eddiejennings suggested, I’ll definitely make a backup of my /home directory. In the meanwhile, I’ll continue to look around to see if I can reinstall while reusing the /home subvolume and keeping it intact (or whatever’s left of it, at least).

In order to preserve /home, you will need to manually partition your new install. Choose existing /home, set mount point to /home, but DO NOT MARK to format it.


See also

What I was suggesting was while in a Live USB session, copying the /home data elsewhere and then restoring it, if you wanted to start anew, but Arturas’s suggestion will get you what you want.

Thanks all. I was able to create a new Fedora system while keeping my previous /home directory with all my files, via in the installer going to Custom, marking the /root btrfs subvolume to delete, using existing home subvolume mounted as /home, and creating new mountpoints for /root, /boot, etc. However, getting back all my packages and drivers were a chore :smiling_face_with_tear:

1 Like

See Need help with dnf commands for listing and installing packages to & from a txt file - #3 by computersavvy

to create a list of installed packages that can easily be re-installed.