Search:  
Gentoo Wiki

Reinstall_Gentoo_keeping_your_old_configuration

This article is part of the HOWTO series.
Installation Kernel & Hardware Networks Portage Software System X Server Gaming Non-x86 Emulators Misc

Contents

Introduction

This document walks you through a Gentoo install on a box you already had a running Gentoo system on.

Why this Wiki?

What's the use of this document? Well, I had a pretty customized Gentoo running on my box, but at one point it started to stop working properly. That just happens if you tweak a lot. I was reluctant to reinstall, because I had made all those customizations and was afraid to lose them. Finally I took the risk. This is the log of my procedure.

Disclaimer

Backups, backups, backups! If you break your system and lose your data I take no responsibility!

The Procedure

Step Zero: Back up your data

The backups we will really need during this procedure are primarily from /etc. I took the liberty of just backing up and later restoring the whole directory. The only other file you need is /var/lib/portage/world. If you use KDE, you'll want to back up configuration files under /usr/kde/[your KDE version] as well. I suppose something similar goes for GNOME, but I don't know if it keeps its config under /etc or in a separate directory.

You'll want to back up your kernel configuration as well, if you have compiled your own kernel. You can either back up /usr/src/linux/.config, or read the kernel configuration from /proc/config.gz.

It is also wise to backup your home-dir, even when you don't use it much, because many programs use hidden dirs (starting with a ".") in de /home/username-dir to keep their config-files. (ie: the gimp, firefox, thunderbird,...). To see what I mean do: ls -a

That said, I strongly advise you to back up all the data you keep on your system as well. Not only does this step protect your data, it also protects your nerves if anything goes wrong. And consider that with less strained nerves you are prone to make less errors...

Step One: Have a free partition

Obviously, if you want to reinstall Gentoo you'll have its partition for a reinstall. I felt more comfortable keeping the original partition and freeing another one, so I could copy config files from the original install instead of the backup media (which i would have to switch with the Gentoo LiveCD then).

I also used the opportunity to optimize my disk layout.

Step Two: Install Gentoo from LiveCD

Follow the Installation Guide here, until you get to the "Configuring the kernel" section. I assume you want to keep your old kernel configuration, so copy the backed up .config to /usr/src/linux, or zcat config.gz > /usr/src/linux/.config. Then make oldconfig. Answer all the questions (if you're in a hurry you can simply press RETURN every time to accept the default), and go on to make && make modules_install. Keep following the Guide.

Step Three: Restore

Warning: Do this only if you are absolutely sure about what you are doing; this broke my newly installed system and I had to start over again installing from cd. Better is to keep your old etc-dir and only overwrite the config files you need!

cp -a /[your backup location]/etc/* /etc

Step Four: Update your system

emerge --sync && emerge -uD system. At this point, possibly gcc is updated to a newer version, so you should source /etc/profile. I don't know if portage uses the new compiler regardless whether it is set in your current shell, but it certainly doesn't hurt to do this.

You probably have a customized /etc/make.conf with your own USE-flags, so you want to emerge --newuse system as well.

Finally you can reinstall all the software you had on your system:

Code: Reinstall World

cat /path/to/backup/world | xargs -n1 emerge -uv

Retrieved from "http://www.gentoo-wiki.info/Reinstall_Gentoo_keeping_your_old_configuration"

Last modified: Thu, 27 Dec 2007 00:52:00 +0000 Hits: 11,035