Search Linux Here

Google
 

Thursday, February 28, 2008

How to clone an installation : Ubuntu (5.10 / 6.06.1 / 6.10)

How many times have you reinstalled your machine? I know I long ago lost count. It isn’t that it is unreliable but, in my case, I often upgrade to new versions or reinstall to test things out. How nice would it be if you could clone your current installation and fairly easily reinstall to just about the same stage you were before you changed? This post will tell you how!

The first thing to remember is that Ubuntu uses the APT package management system which handles installed packages and their dependencies. If we can get a list of currently installed packages you can very easily duplicate exactly what you have installed now on a future machine. Below is a command you can use to export a list of your installed packages.

# sudo dpkg --get-selections | grep '[[:space:]]install$=' \| awk '{print $1}' > package_list

update: (see comments) - the blog reformats the single-quotes around the parameters for grep & awk. Note that both should be the character on the quote key. Also, the “–get-selections” is a double-dash, although it doesn’t appear as such.

At this point you should end up with a file called “package_list” which consists of a long list of every package your currently have installed.

The next step would be to tell the clone machine to install each of those packages. You’ll have to copy that file to the clone machine (via network, usb drive, email, etc) and also make sure to duplicate the /etc/apt/sources.list file. Without the same access to repositories it may not be able to find the packages.

To tell your system to use the previously exported package list use the following command (after making sure to also clone your /etc/apt/sources.list file):

1. sudo aptitude update
2. cat package_list | xargs sudo aptitude install

Note: this should only be used between the same distribution and the same release version. Example, only use this to clone a 6.06.1 to 6.06.1 machine. You will run into problems in trying to clone from 6.06.1 to 6.10 or similar.

No comments: