cloning a debian system from one machine to another
DebianThis forum is for the discussion of Debian Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
cloning a debian system from one machine to another
Hi,
I know this has been asked many times and some information is available on Internet but a while back I had tried that and I did not get the expected result.
So here is the thing. I have a Debian Machine A which I have customized by adding/removing several packages over last 2-3 months. Now I recently installed a base system from Debian NetInstall CD (called it as Machine B) Now What I want is that MAchine B should be an exact clone of MAchine A (packages wise).
In short, whatever packages are there on Machine A should be on Machine B, and whatever packages are there on Machine B and not on Machine A, should be removed from Machine B.
I know people suggest using
Code:
dpkg --get-selections
dpkg --set-selections
I would like to know the exact steps...
I am using apt-get and NOT aptitude. Also I am not willing to move on to aptitude.
Oh yes, both the machines are debian etch (stable)
I'm guessing not, as this info is all over the place.
Here's to your laziness -
Code:
dpkg --get-selections | grep '[[:space:]]install$' | awk '{print $1}' > packagelist.txt
email or scp packagelist.txt to the new machine, then:
apt-get -u install `cat packagelist.txt`
You can add a -f to the install if you're in a hurry and feeling braze. I suggest against that however.
Peace,
JimBass
Thanks for your reply. As I mentioned in my post that I had searched over the internet before and I had tried what was suggested without any luck...Your method is a bit different than the usual ones, which suggest using something like "apt-get dselect upgrade". Looks like yours is more straightforward and should work.
I had one question: Will your solution remove the packages that from Machine B which are not there on Machine A?
Thank you once again for the reply.
Edit: Here is what I had found over the internet before:
Code:
On the source machine:
dpkg --list '*' > file.list
Copy file.list and /etc/apt/sources.list to the target machine, and then:
dpkg --set-selections < file.list
apt-get -u dselect-upgrade
I was little bit apprehensive about using dselect.
Last edited by kushalkoolwal; 08-15-2007 at 05:32 PM.
Reason: not trying to be lazy..
Edit: Here is what I had found over the internet before:
Code:
On the source machine:
dpkg --list '*' > file.list
Copy file.list and /etc/apt/sources.list to the target machine, and then:
dpkg --set-selections < file.list
apt-get -u dselect-upgrade
I was little bit apprehensive about using dselect.
Your not using dselect with that last command you would be using dselect's package list that you set with dpkg to tell apt what packages should be installed.
Your not using dselect with that last command you would be using dselect's package list that you set with dpkg to tell apt what packages should be installed.
Either they are both pretty much the same command using the same package list to do it, I was just saying you are not really using dselect in that command other than to get the list of packages that will be upgraded/installed using apt. If you have already used the set-selections command then the one you want is the dselect-upgrade if not the latter packagelist.txt one can still be used.
To uninstall packages from B that are not on A, (which I wouldn't bother doing, as it will make little difference in space) -
Just change things around a bit. Which ever command you use to get the list of packages on A (dpkg --list or dpkg --get-selections), use on B, and make the output name slightly different, like packlist2.txt, or file2.list. Then run a diff command on the 2 lists, packagelist.txt and packagelist2.txt, or file.list and file2.list. Save the output of the diff command to another file, say remove.list, then ultimately, do
Code:
apt-get -u remove 'cat remove.list'
You may do something very bad by doing that as well. I would carefully go through the removal.list and see what those packages are. I doubt both machines have identical hardware. Taking something off B is going to seem like a really stupid thing when it turns out to have something to do with having a functional network card. Long story short, I wouldn't bother with the removal step at all. I didn't give verbose removal instructions, just guidelines, so you'll have to think about why you're doing this, and if anything good will come out of it.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.