Duplicate your Ubuntu Installation….

Home / CLI / Duplicate your Ubuntu Installation….

As good as Ubuntu (and linux) are in general, once in a while you just get to a point where you need a reinstall. That’s when the realization kicks in that you’ve got far too many packages installed since the initial Ubuntu install. It’s okay, there is a way out. Make sure you have a USB key.

On Ubuntu Workstation (with graphical interface):

Run Synaptic package manager. Once inside Synaptic, go to File/Save Markings As menu option and choose a filename and location (USB stick). MAKE SURE YOU ALSO CHECK THE BOX “SAVE FULL STATE, NOT ONLY CHANGES”. This will save a text file that contains every single package installed on your system (through apt system and all it’s variants….manual compile/installs are something else). Now you can go ahead and reinstall the machine and configure your repositories. Once the machine is up and running again, load up Synaptic and go to File/Read Markings and point it at the file you saved on the USB stick and press Apply.

This will start a download process that will set the machine up (as far as installed packages are concerned) just like it used to be. Configurations need to be done manually, but atleast you get all your packages back.

This is also super handy if you’re duping identical systems. Remember that you can not do this to upgrade from one version to another. This is strictly for “Restoring” installed software packages from the same version of Ubuntu.

On Ubuntu Server (command line):

First we need to create a list of all the installed APT packages and configurations and save them:
sudo dpkg --get-selections > /tmp/dpkglist.txt
sudo debconf-get-selections > /tmp/debconfsel.txt

Copy the files from /tmp to your USB stick or save them somewhere else.

Now reinstall the OS, copy your backed up debconfsel.txt and dpkglist.txt file to your fresh system’s /tmp directory and execute the following:
sudo dselect update
sudo debconf-set-selections < /tmp/debconfsel.txt
sudo dpkg --set-selections < /tmp/dpkglist.txt
sudo apt-get -y update
sudo apt-get dselect-upgrade

Don’t worry! This method only adds and upgrades packages, it will not remove packages that do not exist in the list.

We also covered aptoncd program which basically does the same thing (it’s a extra install). Last but not least to make a costum Ubuntu install CD/DVD you want to check out our entry on Reconstructor.

2 Comments

  • lefty crupps

    > Configurations need to be done manually, but atleast you get all your packages back.

    Backing up your /home/ directory (or using a different partition at install) means tha your user configurations should work well on the next install; system-wide software configurations are stored in /etc/ so a backup of that should help with most of those system configurations. Nice eh?

  • Many

    Hi Lefty,

    Thanks for droping by…..yeah ubuntu is quite nice and maturing well. I guess you’re right, you can capture most of the config if you backup your /home and /etc on top of the debconf backup. Nice :-)

    TTYL
    Many

Leave a Reply