Difference between revisions of "Cloning a computer"

From Linuxintro
imported>ThorstenStaerk
(make sure there is no DVD mounted)
imported>ThorstenStaerk
(local - this did not work)
Line 19: Line 19:
  
 
= local =
 
= local =
Local cloning is e.g. to a USB disk to [[make a USB disk bootable]]. In this case we assume the target disk is ''/dev/sdx2'' and it is mounted to ''/mnt/sdx2''. To clone your harddisk:
+
Local cloning is e.g. to a USB disk to [[make a USB disk bootable]]. In this case we assume the target disk is ''/dev/sdx2''. To clone your harddisk:
 
* make sure there is no DVD, CD, network drive and other things mounted
 
* make sure there is no DVD, CD, network drive and other things mounted
 +
* mount the target harddisk to /mnt:
 +
mount ''/dev/sdx2'' /mnt
 
* issue the [[command]]s
 
* issue the [[command]]s
 
  cd /
 
  cd /
  tar -cv $(ls | grep -v proc | grep -v sys) | ( cd ''/mnt/sdx2''; tar xv )
+
  tar -cv $(ls | grep -v proc | grep -v sys | grep -v mnt) | ( cd /mnt; tar xv )
  [[mkdir]] ''/mnt/sdx2/''proc ''/mnt/sdx2/''sys
+
  [[mkdir]] /mnt/proc /mnt/sys /mnt/mnt

Revision as of 16:26, 29 December 2011

Cloning a computer means you have one computer and want to copy the complete harddisk to another. This can mean different things and can have different reasons.

Reasons

  • You want to have a stand-in computer in case your "pet computer" breaks. In this case it is enough to copy every file from hard disk A to hard disk B.
  • You want to virtualize your computer. In this case you will have to dump every byte from your source (physical) to your target (virtual) computer.

Over the network

Clone a Linux computer

When cloning a Linux installation, you will be able to pack all files, like that:

cd /
tar -cvz $(ls | grep -v proc)  | ssh root@192.168.0.5 "cat >slash.tar.gz"

Clone any computer

This is how you can clone the harddisk of any computer, even if it is an encrypted Windows computer. Boot the computer from Knoppix, open a console, enter

dd if=/dev/sdx | bzip2 -z | ssh root@192.168.0.5 "(cat >backup-sdx.bz2)"

Be sure to replace /dev/sdx by the harddisk you want to clone and 192.168.0.5 by your target computer's IP.

local

Local cloning is e.g. to a USB disk to make a USB disk bootable. In this case we assume the target disk is /dev/sdx2. To clone your harddisk:

  • make sure there is no DVD, CD, network drive and other things mounted
  • mount the target harddisk to /mnt:
mount /dev/sdx2 /mnt
cd /
tar -cv $(ls | grep -v proc | grep -v sys | grep -v mnt) | ( cd /mnt; tar xv )
mkdir /mnt/proc /mnt/sys /mnt/mnt