|
V
|
|
Hard disk clone using dd comand from colinux.
-
The purpose of this page is to show a procedure how to clone a windows XP system (drive c) partition, using dd command from
colinux.
Such a procedure has to be tested first. I use colinux, because attaching a new disk to it, is merely a file in the host operating system, edit the colinux configuration file and mount it on colinux.
-
colinux has the ability to access the host operating system disks. So my intention is to use it to clone the XP disk, using dd command.
But first I must get my hands wet, with a small disk, making sure I really know well the procedure.
-
Also since the XP system disk is presently very large, I need first to practice the procedure on a small disk.
For that colinux is a good system to exercise backup and restore, as it it easy to work with its virtual disks.
-
The drill consists of the following phases:
- Create a small disk for colinux. Create a device and mount it. Put some text files (can be any type of files, but for the exercise, I use something I can easily check its integrity) on it.
- Clone the disk. Remove the disk and erase its data.
- Create a larger disk and restore data, from the former disk, on it.
- Compare each file and see that the disk was completely restored.
-
In order to create a disk for colinux, I need to create a file with all 0 in it:
dd if=/dev/zero of=TryDisk count=1024 bs=1024
Check its content:
od -c TryDisk
0000000 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
*
4000000
-rw-r--r-- 1 root root 1048576 2012-02-04 13:19 TryDisk
Add the following line to the colinux configuration file:
#Trial for backup
cobd4="d:\Pini\tmp\TryDisk
Now prepare it for mount and mount it:
mkfs.ext3 /dev/cobd4
mount /dev/cobd4 /mnt/Try
Check that all went okay:
cd /mnt/Try/
df -h .
Filesystem Size Used Avail Use% Mounted on
/dev/cobd4 1003K 17K 935K 2% /mnt/Try
Backup the disk
Create an image to a disk of colinux. My host, windows XP, has two partitions for the hard disk namely c and d. C is for the windows and d is for data. On colinux I mounted each to /mnt/pcC and /mnt/pcD.
dd if=/dev/cobd4 | gzip -c > /mnt/pcD/Pini/tmp/back_1.img.gz
If a USB portable disk is preferred, plug it and re-boot colinux adding to command the reference to the USB disk:
colinux-daemon.exe -t nt cofs0=c:\ cofs1=d:\ cofs2=e:\ @example.conf
mount it, before usage:
mount -t cofs cofs2 -o uid=bob,gid=bob /mnt/pcE
At the end un-mount the USB disk:
umount /mnt/pcE
Create an image and pass it to another computer using ssh:
dd if=/dev/cobd4 | gzip -c - | ssh user@192.168.0.17 "dd of=back_1.img.gz"
One may wish to save the CPU time of encrypt, which ssh uses (on a very large disk back, as in my case 80GB, this may be significant time saving):
nc -l 2222 > back_1.img.gz #listen on the remote linux
dd bs=1M if=/dev/cobd4 | gzip -c - | nc 192.168.0.17 2222
-
Shutdown colinux. Delete the virtual disk by deleting the file TryDisk, using widows host operating system.
Create a new file for the new disk:
dd if=/dev/zero of=TryDisk_2 count=2048 bs=1024
2097152 2012-02-04 13:53 TryDisk_2
#Trial for backup - modify the colinux configuration file.
cobd4="d:\Pini\tmp\TryDisk_2"
#restore data
gunzip -c /mnt/pcD/Pini/tmp/back_1.img.gz | dd of=/dev/cobd4
#list files
ls -lart /mnt/Try/
drwxr-xr-x 7 root root 4096 2012-02-04 20:30 ..
drwx------ 2 root root 12288 2012-02-04 20:41 lost+found
-rwxr-xr-x 1 pini pini 3251 2012-02-04 20:45 gm_asp.unx
-rwxr--r-- 1 pini pini 193 2012-02-04 20:45 conv.unx
-rw-r--r-- 1 pini pini 55 2012-02-04 20:46 Zefat.txt
-rw-r--r-- 1 pini pini 528 2012-02-04 20:46 yd.txt
...
df -h .
Filesystem Size Used Avail Use% Mounted on
/dev/cobd0 2.0G 1.7G 264M 87% /
#check that file are the same with some text compare utility.
for f in `ls`;do perl ~/bin/cmp_diff.pl $f ~/Home_2/GeneralInfo/youtube/;done
-
Note that in a real crash the restore will be done differently:
Once your disk is totaly lost, you boot from a small linux on CD. Find its IP and from the remote linux, which has the backup image issue the following command:
zcat tmp/back_1.img.gz | ssh user@192.168.0.16 'dd of=/dev/sda'
Note /dev/sda is whatever the mini linux rescue disk recognized your new disk.
-
The backup may take a very long time to complete. dd does not issue a progress message. From checking the manual pages on dd:
"Note that sending a SIGUSR1 signal to a running 'dd' process makes it
print to standard error the number of records read and written so far,
then to resume copying.
$ dd if=...of=...& pid=$!
$ kill -USR1 $pid;"
This output was received on debian machine:
988937+0 records in
988936+0 records out
506335232 bytes (506 MB) copied, 111.85 s, 4.5 MB/s
Under bash one can use a while loop to print progress of dd:
while ps -p $pid > /dev/null ; do date ; kill -USR1 $pid; sleep 10;done;
send_mail.unx
-
A clone back is done on cygwin for a system window XP partition using compression. The results when using compression programs such as gzip and bzip2, are shown in the following
page.
|
|
Search This Site
Feedback This Site
new pages on this site
|
|