Update Ubuntu: reinstall and migrate

For numinous reasons I rather reinstall Ubuntu than update it. And when doing so I want to keep only the files that carry personal information and not old system/GUI config files that maybe skew the look of the new installation.

So, how do I go about it?

A assumption here is that you have installed your old Ubuntu using at least two partitions: one for / and one for /home. If not I recommend that you simply back up your /home directory to an external device and then skip right to the section Recover old files below.

Another assumption is that you use Ubuntus EncryptedHome feature. If you do not, then just backup your home folder and skip to the last section.

Contents
1. Prepare and install
2. Recover old files

Prepare and install

  1. Create a bootable USB stick with the new Ubuntu.
  2. Reboot and let it check itself for defects.
  3. Boot from it.
  4. Open up a terminal:
    CTRL + ALT + t
  5. Start Nautilus:
    sudo nautilus
  6. Show hidden files:
    CTRL + h
  7. Since we want to keep our username the way it was we need to move two folders:
    1. Rename /home/YOUR_USERNAME to e.g. /home/YOUR_USERNAME-old
    2. Rename /home/.ecryptfs/YOUR_USERNAME to e.g. /home/.ecryptfs/YOUR_USERNAME-old
  8. Unmount the device by clicking the eject symbol in the left part of Nautilus under the heading Devices.
  9. Close Nautilus and start the installation process. It's the first icon in the launchbar.
  10. Install using the custom option.
  11. Select the former / as Ext4 and /. Check format.
  12. Same for /home but without formatting it (how obvious :-) ).
  13. Install.

Recover old files

After sucessfully booting into your new Ubuntu do the following:

  1. Open up a terminal:
    CTRL + ALT + t
  2. Mount your old home directory:
    sudo ecryptfs-recover-private
  3. Answer n until it presents you with the correct path to your old home directory.
  4. Answer y or just press Enter when asked if you know your login passphrase.
  5. Open Nautilus and go to /tmp/.
  6. There is a write protected folder with a cryptic name starting with ecryptfs. There are your old files.

Now we can copy all the relevant old files into our new installation:

  1. Still in /tmp/ecryptfs...:
  2. Show hidden files: CTRL + h
  3. Maybe open up a second Nautilus window and copy (as much as you want of) the follwing files from /tmp/ecryptfs... to your home directory.
    Here is a selection of files you probably want to copy:
    • Chrome: .config/google-chrome/
    • Firefox: .mozilla
    • Thunderbird: .thunderbird
    • Nautilus bookmarks: .config/gtk-3.0
    • Online accounts: .config/libaccounts-glib
    • Keyring: .local/share/keyrings
    • Empathy chatlogs: .local/share/TpLogger
    • Webkit local storage used e.g. by Nitro: .local/share/webkit
    • Zeitgeist the Ubuntu activity log: .local/share/zeitgeist
    • Pidgin: .purple
    • SSH keys: .ssh

If you want this tutorial to be more exhaustive and more illustrative please comment below.

The author

Written by Per

Free software enthusiast and transhumanist residing in Stuttgart, Germany.


comments powered by Disqus