Difference between revisions of "Cloning a computer"

From Linuxintro
imported>ThorstenStaerk
(Clone any computer locally)
imported>ThorstenStaerk
Line 7: Line 7:
 
= Over the network =
 
= Over the network =
  
== Clone a Linux computer ==
+
== file-by-file copy ==
 
To store a backup of one computer on the other via [[network]], use the command:
 
To store a backup of one computer on the other via [[network]], use the command:
 
  cd /
 
  cd /
Line 21: Line 21:
 
* /boot/grub/menu.lst to contain generic device names
 
* /boot/grub/menu.lst to contain generic device names
  
== Clone any computer ==
+
== byte-by-byte copy ==
 
This is how you can clone the harddisk of any computer, even if it is an encrypted Windows 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
 
Boot the computer from Knoppix, [[open a console]], enter
Line 29: Line 29:
 
= local =
 
= local =
  
== Clone a Linux computer ==
+
== file-by-file copy ==
 
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:
 
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
Line 39: Line 39:
 
  [[mkdir]] /mnt/proc /mnt/sys /mnt/mnt
 
  [[mkdir]] /mnt/proc /mnt/sys /mnt/mnt
  
== Clone any computer ==
+
== byte-by-byte copy ==
 
This is how you can clone the harddisk of any computer locally (e.g. to a USB drive), even if it is an encrypted Windows computer.
 
This is how you can clone the harddisk of any computer locally (e.g. to a USB drive), even if it is an encrypted Windows computer.
 
* boot the computer from Knoppix
 
* boot the computer from Knoppix

Revision as of 14:50, 16 May 2013

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

file-by-file copy

To store a backup of one computer on the other via network, use the command:

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

To clone a computer over the network, say:

cd /
tar -cv $(ls | grep -v proc)  | ssh root@192.168.178.3 "(cd /public/ubunturoot; tar xv )"

Afterwards you may want to change

  • IP address, netmask, gateway, name server, time server, hostname
  • /etc/fstab to contain generic device names like /dev/sda1 instead of /dev/disk/by-uuid/7e9e1890-312e-43eb-8ebb-82fe03b62732
  • /boot/grub/menu.lst to contain generic device names

byte-by-byte copy

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

file-by-file copy

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

byte-by-byte copy

This is how you can clone the harddisk of any computer locally (e.g. to a USB drive), even if it is an encrypted Windows computer.

  • boot the computer from Knoppix
  • open a console
  • mount the USB disk, e.g.
mount /dev/sdz1 /mnt/usb
  • enter
dd if=/dev/sdx | bzip2 -z | cat >/mnt/usb/backup-sdx.bz2

Be sure to replace /dev/sdx by the harddisk you want to clone.