LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian
User Name
Password
Debian This forum is for the discussion of Debian Linux.

Notices

Reply
 
Search this Thread
Old 08-15-2007, 04:19 PM   #1
kushalkoolwal
Senior Member
 
Registered: Feb 2004
Location: Middle of nowhere
Distribution: Debian Squeeze
Posts: 1,249

Rep: Reputation: 48
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
 
Old 08-15-2007, 04:33 PM   #2
JimBass
Senior Member
 
Registered: Oct 2003
Location: New York City
Distribution: Debian Sid 2.6.32
Posts: 2,100

Rep: Reputation: 48
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
 
Old 08-15-2007, 05:23 PM   #3
kushalkoolwal
Senior Member
 
Registered: Feb 2004
Location: Middle of nowhere
Distribution: Debian Squeeze
Posts: 1,249

Original Poster
Rep: Reputation: 48
Quote:
Originally Posted by JimBass View Post
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.

Last edited by kushalkoolwal; 08-15-2007 at 05:32 PM. Reason: not trying to be lazy..
 
Old 08-15-2007, 05:56 PM   #4
HappyTux
Senior Member
 
Registered: Mar 2003
Location: Nova Scotia, Canada
Distribution: Debian AMD64
Posts: 3,513

Rep: Reputation: 63
Quote:
Originally Posted by kushalkoolwal View Post
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.
 
Old 08-15-2007, 06:11 PM   #5
kushalkoolwal
Senior Member
 
Registered: Feb 2004
Location: Middle of nowhere
Distribution: Debian Squeeze
Posts: 1,249

Original Poster
Rep: Reputation: 48
Quote:
Originally Posted by HappyTux View Post
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`
 
Old 08-15-2007, 06:30 PM   #6
HappyTux
Senior Member
 
Registered: Mar 2003
Location: Nova Scotia, Canada
Distribution: Debian AMD64
Posts: 3,513

Rep: Reputation: 63
Quote:
Originally Posted by kushalkoolwal View Post
Hmm...So What should I use?
Code:
apt-get -u dselect-upgrade
or
Code:
apt-get -u install `cat packagelist.txt`
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.
 
Old 08-15-2007, 07:35 PM   #7
JimBass
Senior Member
 
Registered: Oct 2003
Location: New York City
Distribution: Debian Sid 2.6.32
Posts: 2,100

Rep: Reputation: 48
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cloning system to different hardware platform twk Linux - Hardware 1 12-18-2006 01:13 PM
Cloning Linux System from PC->PC ALInux Linux - General 4 07-26-2006 05:09 PM
cloning (somewhat) my lfs system DropSig Linux From Scratch 2 02-11-2006 10:23 PM
disk/system cloning Sharaz Linux - General 2 12-28-2005 03:11 PM
cloning system image gag Linux - Newbie 1 11-24-2003 01:24 PM


All times are GMT -5. The time now is 01:20 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration