clone systems with tar command


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users clone systems with tar command
# 1  
Old 10-14-2008
clone systems with tar command

I have several machines which I want to be exactly identical. It is the first time I am trying to clone machines and I searched on the internet and found many people archive and extract their disks using some tools, using dd, and I also found someone using tar. I read about different tools. I tried g4u, a tool for hard disk image cloning, but it didn't boot. Now, I am more familiar with tar and I created an archive of the whole file system of one machine using tar (tar -czvlps −−same−owner −−atime−preserv -f machine.tgz /) and I extracted this tar on other machines (tar -xslpzf machine.tgz). I did this with machines booted on CDs, mounting the drives and copying over network.

When I reboot I see the new machines with hostname as expected, I try login with the old password combinations, however I get "permission denied" and I am thrown back to login. When I try ssh to a new machine I get "unable to get valid context." Permissions and files should be exactly the same on the new machine (and look as if they were, although I didn't do any extensive comparisons).

Now before I try other stuff or go into long search of the problem, I am suspecting that I miss something and I want to ask people who have done this before. Am I making some stupid mistake? I suppose that tar and dd are more or less doing the same thing, or is there any forcing argument for using dd instead. Any help appreciated.
# 2  
Old 10-14-2008
Are the machines using DHCP to get their network addresses? If not, I can see where there might be a problem.

Also, if you clone the machines, you're also cloning their SSH private keys. This would cause a problem. (Unless your SSH rc scripts generate their keys on first boot and you remembered to clone the system and remove the original keys).

Also your tar command might not handle: sockets, devices, named pipes. You should check to see if devices were correctly carried over.

Finally, did you overwrite the boot sector so that it can find the new kernel? This is OS dependent.
# 3  
Old 10-15-2008
Thanks for your help, otheus.

I am administrating DHCP on a head node together with a central /etc/hosts.

You are right about ssh private keys, however this is not my problem. I need to login from just one machine (head node) to the clones and this remote login seems to work with the new machines (because the private key of my head node corresponds to the (identical) public key on my clones. However: (example)
head# ssh clone5
Unable to get valid context for root
Last login: Tue Oct 14 19:45:14 2008
Connection to 192.168.1.5 closed.

I am going to check now sockets, devices, and named pipes (together with the tar options). And... yes, good point, I am not sure about /boot neither, I'll check that also.
# 4  
Old 10-15-2008
Okay, the other thing about "Context" is it is used in conjunction with selinux. So check your grub file to make sure selinux isn't enabled at boot time. OR you should be able to run "selinuxenabled && echo yes". If you get nothing, the it's not selinux.
# 5  
Old 10-15-2008
Hi.

I downloaded clonezilla recently, but have not yet had a chance to try it. It claims to be similar to Norton Ghost Corporate Edition, and notes:
Quote:
At the NCHC's Classroom C, Clonezilla SE was used to clone 41 computers simultaneously. It took only about 10 minutes to clone a 5.6 GBytes system image to all 41 computers via multicasting!
See Clonezilla for details. Best wishes ... cheers, drl
# 6  
Old 10-17-2008
succeeded cloning with dd

I found one error, which with permissions. Tar by default maps the user ids to the system where you compress and extract, respectively. On cloning over network I did not take care of this. You can tell tar explicitely by the --numeric-owner option to conserve the original mapping.

I found a howto that described a more elegant way to clone systems using rsync (importantly with the numeric-ids option):
node2> rsync -Saq --numeric-ids --exclude=/proc --exclude=/sys --exclude=/dev
-e 'ssh -c blowfish' node1:/ /mnt/hd

where node2 is the new machine, node1, the machine from where we want to clone.
However this neither worked. ;(
I did this after booting node2 from CD, mounting file system starting /mnt/hd with subdirectories mirrowing node1 filesystem. This implied that /boot on node2 and node1 has same permissions... I don't get it.

I then tried dd with piping to and from netcat, respectively on machine to clone from and machine to clone to, as described in a second howto from same site. It is the first time I heard of netcat (nc) which is a very cool program, a kind of pipe over the network.

On node1 you run:
dd if=/dev/hda conv=sync,noerror bs=64k | nc -l 5000

On node2 you run:
nc 192.168.1.1 5000 | dd of=/dev/hda bs=64k
where 192.168.1.1 is the ip of node1.

This took a lot of time (it said 158GB read/written), but it worked!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

UNIX command to check if file name ends with .tar OR if the file is a tar file

Hello Team, Would you please help me with a UNIX command that would check if file is a tar file. if we dont have that , can you help me with UNIX command that would check if file ends with .tar Thanks in advance. (10 Replies)
Discussion started by: sanjaydubey2006
10 Replies

2. Shell Programming and Scripting

Single command - unzip files from a tar command

I have a tar file that contains multiple .Z files. Hence I need to issue a tar command followed by a gzip command to fully extract the files. How do I do it in a single command? What I'm doing now is tar xvf a.tar (this will output 1.Z and 2.Z) gzip -d *.Z (to extract 1.Z and 2.Z) (9 Replies)
Discussion started by: ericlim
9 Replies

3. Shell Programming and Scripting

tar command to explore multiple layers of tar and tar.gz files

Hi all, I have a tar file and inside that tar file is a folder with additional tar.gz files. What I want to do is look inside the first tar file and then find the second tar file I'm looking for, look inside that tar.gz file to find a certain directory. I'm encountering issues by trying to... (1 Reply)
Discussion started by: bashnewbee
1 Replies

4. What is on Your Mind?

From Systems Admin to Systems Eng.

I have been wondering how do Systems Administrators do the jump into Systems Engineering? Is it only a matter of time and experience or could I actually help myself get there? Opinions? Books I could read? Thanks a lot for your help! (0 Replies)
Discussion started by: svalenciatech
0 Replies

5. Shell Programming and Scripting

tar command dont tar to original directory

HI, if I have a tarfile called pmapdata.tar that contains tar -tvf pmapdata.tar -rw-r--r-- 0/0 21 Oct 15 11:00 2009 /var/tmp/pmapdata/pmap4628.txt -rw-r--r-- 0/0 21 Oct 14 20:00 2009 /var/tmp/pmapdata/pmap23752.txt -rw-r--r-- 0/0 1625 Oct 13 20:00 2009... (1 Reply)
Discussion started by: borderblaster
1 Replies

6. UNIX for Dummies Questions & Answers

command to clean up file systems

As you will verify, I am a really naive user of AIX 5.1. As such I wonder if you could possibly let me know of a command or procedure I could use to automatically, globally and safely, remove all useless files from my machine. I'm not referring to my own files because I perfectly know which of them... (1 Reply)
Discussion started by: ahjchr
1 Replies

7. UNIX for Dummies Questions & Answers

tar -cvf test.tar `find . -mtime -1 -type f` only tar 1 file

Hi all, 4 files are returned when i issue 'find . -mtime -1 -type f -ls'. ./ora_475244.aud ./ora_671958.aud ./ora_934052.aud ./ora_934050.aud However, when I issued the below command: tar -cvf test.tar `find . -mtime -1 -type f`, the tar file only contains the 1st file -... (2 Replies)
Discussion started by: ahSher
2 Replies

8. Shell Programming and Scripting

Need a script to tar all file systems on the machine into one filesystem.

Hi I am very poor at scripting.:o I need to develop a script that should tar up all the filesystems on the machine on to a single filesystem called /tarfilesystem. Any suggestions ... Thank You very much (1 Reply)
Discussion started by: urrahman_zia
1 Replies

9. UNIX for Dummies Questions & Answers

Tar Command

I'm new to Unix, :confused: What is a TAR Command? What does it do? I need simple explanation. (4 Replies)
Discussion started by: technie07
4 Replies

10. UNIX for Dummies Questions & Answers

Creating create mirrored disk files systems using mkfs command

What is the correct mkfs syntax to create mirrored disk files systems? I need to make the file system 20gb. For example: machine# mkfs -F ufs /dev/md/dsk/d40 size not specified ufs usage: mkfs special size(sectors) \ -m : dump fs cmd line used to make this partition -V : print this... (4 Replies)
Discussion started by: GLJ@USC
4 Replies
Login or Register to Ask a Question