LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Debian (https://www.linuxquestions.org/questions/debian-26/)
-   -   cloning a debian system from one machine to another (https://www.linuxquestions.org/questions/debian-26/cloning-a-debian-system-from-one-machine-to-another-577364/)

kushalkoolwal 08-15-2007 04:19 PM

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)

THanks

JimBass 08-15-2007 04:33 PM

Did you use google at all?

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

kushalkoolwal 08-15-2007 05:23 PM

Quote:

Originally Posted by JimBass (Post 2860129)
Did you use google at all?

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.

HappyTux 08-15-2007 05:56 PM

Quote:

Originally Posted by kushalkoolwal (Post 2860165)
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.

kushalkoolwal 08-15-2007 06:11 PM

Quote:

Originally Posted by HappyTux (Post 2860195)
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.


Hmm...So What should I use?
Code:

apt-get -u dselect-upgrade
or
Code:

apt-get -u install `cat packagelist.txt`
:scratch:

HappyTux 08-15-2007 06:30 PM

Quote:

Originally Posted by kushalkoolwal (Post 2860213)
Hmm...So What should I use?
Code:

apt-get -u dselect-upgrade
or
Code:

apt-get -u install `cat packagelist.txt`
:scratch:

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.

JimBass 08-15-2007 07:35 PM

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.

Peace,
JimBass


All times are GMT -5. The time now is 08:55 AM.