LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 03-24-2006, 05:59 AM   #1
gobexe
LQ Newbie
 
Registered: Mar 2006
Posts: 1

Rep: Reputation: 0
clonning linux with tar


Hello,

For those who dont have the time to go through all my ordeal, my question is simple. How can I clone a linux machine with tar (and not dd)?

Here is my story.

I needed to install 20-something machines with Linux (Redhat 9) and since they needed to have the same configuration, I decided to try to clone them instead of installing each separately. I googled for some pointers towards, didnt find any, so decided to take matters into my own hands.

I did the original installation with no problem, created four partitions [/, /usr, /home and swap, formatted with ext3]. After installing the machine just as I wanted it, i did a 'tar zcvpf' on / and /usr (i started the machine with a boot cd, mounted the partitions and then did the tar'ing). All was fine, until i started to clone the first machine.

In my mind, the procedure was simple. All I needed to do was create 4 partitions, and then untar the files on the corresponding partitions, do a grub-install and that was it. BUT NO!! The first problem I had was that unless the created partitions were the exact match (cylinder to cylinder) to the original, the machine will not boot (boot process stops with kernel panic). Though I feel st00pid, I created the exact partitions and did the installation and everything worked fine ... until yesterday (about 2 weeks from the day i did the installation).

The problem I have now is that on all machines, df -k shows that / is used only 1% (when in fact 20-something% is in use) and when i try to create a file (either touch or mkdir) i get a 'no space left on device'. If I reboot it i get a grub 117 error, and when i try to mount the / partition from a boot cd, i see that everything is corrupted. Now, I have to do the installation again ... unless someone points out the do's and dont's of machine cloning using tar.

I am now totally lost! I dont know what to do!

/G/
 
Old 03-24-2006, 07:22 AM   #2
Randux
Senior Member
 
Registered: Feb 2006
Location: Siberia
Distribution: Slackware & Slamd64. What else is there?
Posts: 1,705

Rep: Reputation: 54
I'm no expert but I just did something similar (but with one machine) with tar. Since nobody has replied yet I will tell you what I can but I am sure the guys know how to do it. I did use an unused partition to test it before I did the real thing.

I created a .tar.bz2 of each filesystem (I had less mount points than you, but the deal is the same) by tar -cpjf rootfilesys.tar.bz2 / for example. I burned this stuff to a CD which is what I think you said you did also.

I loaded a live CD and I fdisked and made new filesystems (not the same sizes) and then I changed directory (not chroot) into the root of the new filesystem. I did tar -xvjf /dev/cd/rootfilesys.tar.bz2. It restored all the files and then I was able to edit the fstab on the new system and chroot into it. Then I ran lilo, which could be a difference...lilo resolves the kernel stuff at lilo time, not boot time. I really don't know what grub does. I rebooted into my new system and then I built the other mount points.

I think it would help if you could show some doc because it's a little hard to see where you might have gone wrong. I know for sure that you don't need to have the same size filesystems (but of course it does need to be big enough to contain the extracted archive).

If these 20 machines of yours can really be set up exactly the same, then I would suggest looking at partimage. It does a nice job of making copies of partitions and even splits up the images to fit whatever media you have, if you want. The only thing is, the file systems have to be exactly the same size or bigger, *even* if the data doesn't require it. For example, let's say you have a 1GB root but it's only 25% full. If you use partimage you will only be able to restore this image to a 1GB or bigger partition, even though you have 750M of free space. That does suck, but it is very very nice if you have identical machines like maybe in your scenario. Because then you really can clone without too much pain. You will need a live CD to do the boot management unless you figure out how to use the MBR feature of partimage.

Last edited by Randux; 05-11-2006 at 10:23 AM.
 
  


Reply

Tags
cloning


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
tar tar cvf - . | (cd /root/; tar xvf -) ewt3y Linux - General 10 02-19-2014 10:55 AM
how can i decompress this tar.tar file? hmmm sounds new.. tar.tar.. help ;) kublador Linux - Software 10 02-23-2008 05:40 AM
Clonning data, fifo/pipe/tee problem : Resource temporarily unavailable rmarco Linux - General 2 05-05-2005 11:15 AM
problem unzipping a tar.bz2 file tar: Error is not recov jyome Linux - Software 4 09-04-2003 01:04 PM
Diferance between rpm, tar, tar.gz, scr.tar, etc mobassir Linux - General 12 08-21-2003 06:30 AM


All times are GMT -5. The time now is 05:25 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