Help with dd
okay first of all i apologize for putting up another dd question since there is a really wonderful thread already available at linuxquestions.org at
http://www.linuxquestions.org/questi...d.php?t=362506 however before i tried something i just wanted to be sure if that would work or not. So here is what i want to do: I have a toshiba machine with 60 GB hard disk . The partitions are are follows: Device Boot Start End Blocks Id System /dev/sda1 * 1 1341 10771551 7 HPFS/NTFS /dev/sda2 1342 7296 47833537+ f W95 Ext'd (LBA) /dev/sda5 1342 3253 15358108+ 7 HPFS/NTFS /dev/sda6 3254 6204 23703876 7 HPFS/NTFS /dev/sda7 6205 6982 6249253+ 83 Linux /dev/sda8 6983 7113 1052226 82 Linux swap / Solaris /dev/sda9 7114 7296 1469916 83 Linux Now i wish to take the back of my hard disk so that if i loose data i can quickly restore it. i know i can use dd if=/dev/sda of=/mnt/myexternaldrive/backup bs=4k to take the back up. My questions is it possible that after words i restore for example only /dev/sda1 (NTFS with the boot loader lilo).??/ if i can do that , then how would i access /dev/sda1 for restoring (i can mount the backup but how to access the partitions inside it???? Another thing i keep comming across with dd is that "hard disk should be exactly the same".. Does it mean i cannot backup my 60GB internal hardisk to my external 320GB hardisk?? And lastly, is the dd command present in linux LiveCD's like ubuntu or knoppix etc, since i would need to boot the system (and mount my external drive )before i can actually restore it? Also, would i need to make partitions on the disk before restoring or would that be taken care of itself since i guess partition table would also be restored from the backup??? hmmm that turns out to be more than just one question but i hope you ppl dont mind.. Thnx |
(1) You can dd the whole disk and this is usually the easiest.
(2) You can later restore selectively say only sda1. dd copies the entire partition including the boot sector. Therefore you Lilo will be restored as it is inside the sector 0 of hda1. (3) When you restore sda1 you swap the devices from the input with the output. Thus using your original command it would be changed to Code:
dd if=/mnt/myexternaldrive/sda1 of=/dev/sda1 bs=4k For restoring a partition you need both partitions identical in size or the filing index will be messed up. When a smaller disk is cloned into a large disk the extra capacity just become unallocated empty space which can be incoporated into existing partitions by resizing software like Gparted or Parted Magic. (5) I have not met a Linux that has not got dd. It is nearly your God given right when using a Linux. (6) When you restore a disk you write the whole disk including the partition table. Therefore there is no need to partition the target disk. However, as a word of caution, it pays to create just a partition in the target so that you can check it is using the correct geometry of 255 heads and 63 sectors, otherwise most raw disks can be cloned straight from a purchase. Hope the above helps. |
Thnx and 1 last question
Thnx a lot for the information... Now i can happily get on with messing with my distro. Lol.
just 1 last question: If i simply create a large enough Ext2 partition on the my external drive and the use dd to copy the entire laptop hardisk in a xyz.img file, all of the above things would still work. I think ext2 or ext3 does not have problems with large file sizes like 60 GB...??? Thank you very much again for your help. |
"cp -a" works without the hazards of dd mistakes. The only thing it won't copy is your MBR.
|
Quote:
or ANYTHING in the 63 or so unused sectors between partitions... But, yes, you can certainly use file system commands and then back up mbr, etc. by other methods. |
Quote:
|
Okay.. as suggest in the above post i am running an experiment...lol with a 10 GB partition containing windows XP.
This is what i did: # dd if=/dev/sda1 of=/mnt/Temp/Win_c_Backup.img bs=4k where /mnt/Temp is a 60 GB partition on my external USB Hardisk. The copying is still in progress but its tooooooo slow. Like it has taken already more than 10 mins and is till copying it. Just to verify i opened the drive and looked at it, and yes there is a file called win_c_backuo.img there but so far its size is only 2.8 GB after 10 mins... I had thought the copying would go may be a bit faster than that. Before , i tried a 5 GB partition and that time copying took only 5-8 mins ... Any ideas on about how to speed things up.. Would it help if i increase the size mentioned in bs parameter??? Edited **************** I read up on dd and i think that the bs parameter specifies the number of bytes to written to hard disk with a single system call. So i think here with the command that i have used , it meas 10GB /4K number of system calls. May be that is the reason for slow speed. And the final result of the command is [root@localhost Temp]# dd if=/dev/sda1 of=/mnt/Temp/Win_c_Backup.img bs=4k 2692887+1 records in 2692887+1 records out 11030068224 bytes (11 GB) copied, 5409.06 seconds, 2.0 MB/s So it should speed things up if i change the value to something like 4k*10 |
Think I got about 20Mb/s when using dd from an internal disk to an external disk.
Internal to internal is about 50 to 55Mb/s using bs=32768. |
Job accomplished..
Thank you. yes you seem to be rite (in fact you are rite ..lol)
with bs = 2048k i ended up with 10 MB/s... Thanks a lot for your help and input. |
All times are GMT -5. The time now is 08:32 AM. |