Ask Your Question
4

How do I reinstall Fedora keeping configuration, packages and data?

asked 2018-09-19 12:29:17 -0600

genodeftest gravatar image

updated 2018-09-21 09:05:03 -0600

Sometimes, one needs to reinstall Fedora because it got messed up by mistake or because it has not been updated for several releases.

Note: This is fallout of https://ask.fedoraproject.org/en/ques... worthy getting a separate answer. I will answer this question myself.

edit retag flag offensive close merge delete

Comments

a workstation or a server as described in the question linked? Backup strategy may be different.

florian gravatar imageflorian ( 2018-09-19 12:39:13 -0600 )edit

I do not see any difference. Do you have an example?

genodeftest gravatar imagegenodeftest ( 2018-09-19 13:10:19 -0600 )edit

your point 3. and point 7. for example. However, I think those are minor differences! Great question and great answer! I guess this will be very helpful to other users (that sort of question has been asked many many times here).

florian gravatar imageflorian ( 2018-09-20 10:31:15 -0600 )edit

1 Answer

Sort by » oldest newest most voted
3

answered 2018-09-19 13:07:29 -0600

genodeftest gravatar image

updated 2018-09-20 06:54:48 -0600

Preparation

  • Make sure that you have enough space for backing up all your disk
  • Check the "Common bugs" page for the new Fedora release, e.g. for Fedora 28 for any issues. If you are planning to install an unstable release or a version just released a few days ago, check the Blocker bugs for critical bugs which may affect you.

Backup

First, you need to carefully make a backup.

  1. Save the list of installed packages (rpm -qa) just in case.¹
  2. Save the list of manually installed packages (dnf leaves using the dnf leaves plugin). This will be needed later if you want to reinstall all the extra packages you've installed before.¹
  3. For every user installed, take a copy of the dconf database running dconf dump / as their user ID.¹
  4. Create a copy of /etc. Do this as root or with sudo because otherwise you will be missing important files due to missing permissions. This will backup system-wide configuration.²
  5. Take a backup of a list of all enabled systemd units using systemctl list-unit-files | grep enabled
  6. If you have /opt or files in /usr/local, make a backup too.²
  7. If you are interested in keeping logs, etc., or are using a web server, backup the relevant parts of /var too. This is not normally needed.
  8. Backup the output of rpm -Va. Have a look at this list as it will contain all files which differ from package defaults. This is especially important for config files which may reside outside of /etc, but also for permissions.
  9. Take a full backup of /home.³ If it is on a separate partition, take an image, e.g. by using GNOME disks or dd (dangerous). If it is not on a separate partition, consider putting it on a separate partition as this will ease future reinstallations. If you don't have a separate partition, then carefully back-up your /home and store it useing tar or cp -a ... to ensure the permissions of all files remain unchanged when you restore.
  10. Take a full image (backup) of all disk(s) connected to that computer just in case anything goes wrong.
  11. Have a look at the backups to make sure that they actually work. If the backup failed (e.g. corrupted data) and you rely on it, you have a problem (or several problems).

¹: Do this from the currently running system or through a chroot environment from a live image. ²: Do this either from the currently running system or a live image. ³: Do this from a live image, not from the running system! Otherwise file modifications will be lost. You may also get problems with permissions.

Fedora installation

Boot from any installer media and do a full installation, wiping the root partition. You do not have to wipe a separate /home partition. You need to wipe any partition containing the boot manager (/boot) or the system-managed folders below /usr. If you have a separate partition for /var, you ... (more)

edit flag offensive delete link more

Comments

This is really good. I commend you.

I have the following questions, needed clarifications 1. Any partitions outside root, do not have to be wiped with the new install, correct? 2. If the rebuild is on a hardware raid, with LVs, can re installation be defaulted to the standard fedora lv/partition/ then mount the salvaged partitions?

ecjbosu gravatar imageecjbosu ( 2018-09-19 16:07:32 -0600 )edit

Not only is this a very good post, but it, given its lengthy and intricate contents, is worthy of some automation. I'm a noob and in no position therefor to be trusted (even with my own system), but I would like to call on anyone who would be able to provide some out-of-the-box experience for this functionality to contribute to the community.

I've installed deja-dup, but that looks to me as rather simplistic (at least the out-of-the-box experience) as the default is to save my home folder (duh).

degski gravatar imagedegski ( 2018-09-19 23:34:42 -0600 )edit

@ecjbosu: I added a few more details on which partitions to remove and which need not to be removed. I have no experience with RAID or multi-disk-btrfs so I cannot give more details. If you can, I will be happy to include your description. I do not know how to turn this post into a wiki though.

genodeftest gravatar imagegenodeftest ( 2018-09-20 01:39:52 -0600 )edit

@degski: Due to the fact that this process requires at least 4 reboots, I doubt that there is an easy way to automate it. I have put some of the steps below "Backup" into a bash script which works fine for me, but there is not much magic to that.

genodeftest gravatar imagegenodeftest ( 2018-09-20 01:41:56 -0600 )edit
1

/boot/efi should be preserved, unless you are sure it contains nothing coming from other OS installations.

/usr/local may need to be saved, although its contents is usually coming from software installed from source. If you have any of these, they should be installed from source again.

/etc/passwd and /etc/shadow are tricky as it contains user ids created by rpm packages as well as user ids. The former would usually get different uid numbers after re-installation, and should not be modified.

Same goes for /etc/group.

villykruse gravatar imagevillykruse ( 2018-09-20 02:24:00 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-09-19 12:29:17 -0600

Seen: 2,361 times

Last updated: Sep 21 '18