An understanding of dd command is important but dd itself is a simple operation of
(1) Read the "1" and "0' of the input device and write the same on the output device. The default packet size is one sector of 512 bytes unless specified otherwise by the user with the bs parameter.
(2) The starting and finishing points will be defined by the input device. This is to say from the beginning sector to the last sector of the input device.
This thread was written for the input device as one whole disk holding the original information and the output device is another spare disk larger in size. This is a lot safer than cloning a partition or a file.
As long as the input device is correctly identified then it will only be used for reading purpose. Any error in the rest isn't going to be critical. I have put in Step (3) and (4) in Post #1 purely as extra precautions for 1st and 2nd lines of defense against mistakes in choosing the wrong source disk.
I would recommend before hitting the return key a user should shout at the top of his/her voice for
dd if=/dev/hda of=/dev/sda bs=32768
data dump using input file equal to device hda, output file equal to device sda and block size 32768
The block size can be omitted but the operation takes a lot longer.
Last edited by saikee; 08-12-2007 at 11:29 AM.
They don't call it data destroyer for nothing. heh.
Originally Posted by bacon12
I found an excellent solution and have successfully moved a PATA Vista partition to a SATA partition. Making sure to boot for the first time with no other drives connected which could cause the new Vista partition not to call itself "C:\" was critical.
Here's a link to the full walkthrough:
The link you posted is interesting.
It apears that there are similarities to the method described in this thread
e(1) Vista installation DVD is being used as a Live DVD. An operating sysytem is "sourced" from the outside and the operating system residing in the hard disk is not booted.
(2) The Vista Live DVD is used as a utility just for the cloning process.
(3) All hardware has to be keep unchanged so as not to contradict setting discovered by Vista .
(4) Depending on the cloning process it is some times necessary to repair/restore the Vista's MBR (reported by the user). This apparently applies to both methods.
Then there are the following differences
(a) Vista Live DVD clones a system by copying its files (several users reported omission of files after the process). Linux Live CD clones a partitions/disk by just the binary bits (of "1" & "0"). Thus Linux Live CD can clone any system whereas Vista Live DVD clones only the filing system it supports.
(b) Vista Live DVD clones an operating system with several commands necessitating the creation and formatting of a partition.
The color commands are regarded essential while others are optional and can possibly omitted by an experienced user.
LIST DISK (Shows the disks attached)
SELECT DISK 0
(Selects the first disk)
LIST PARTITION (Shows the partitions on the first disk)
CREATE PARTITION PRIMARY
(Creates a new primary partition on the first disk)
LIST PARTITION (Shows the partitions, and now there is one)
SELECT PARTITION 1
(Selects the newly-created partition)
(Marks the new partition as active, or bootable)
(Formats the partition with NTFS)
LIST VOLUME (Shows the newly-formatted volume)
ROBOCOPY E:\ C:\ /e /efsraw /copyall /dcopy:t /r:0
The main theme of this thread is simplicity by cloning the whole disk and dd can do it with just one line of command using a disk directly off a sealed raw disk (sda)
even the red bit is optional as it is there just to make the cloning go faster by transferring a bigger block of data each time.
dd if=/dev/hda of=/dev/sda bs=32768
(c) I am not sure if it is necessary but the link indicates the hard drive of the resident MS operating system must be physically removed first in order for Vista not to pick up any change in the hardware when at a later time the system to be cloned is introduced back in an external USB disk.
The Linux Live CD method described here has been applied by me for cloning internal disks, external disks, Sata disks, Pata/IDE disks, 3.5" desktop drives, 2.3" laptop drives in any combination. The resident disk can remain in its original position if required in the cloning process.
The above is not an attempt to sell the method described in this thread but to lay out in the open all the relevant differeces and similarities to let the readers to understand better what is going on behind all these commands and instructions.
I personally welcome any alternative method, especially on backing up a Vista, to place together in one place to enable users to make their choices, and if desired to understand the underlining principles too. So I learn a new thing today myself.
I would have prefered to use the linux live CD method you described, but I needed to move a partition rather than the entire disk. You voiced concerns about whether or not the DD method would work for moving partitions so I gave the Vista install disk tools method a try.
It was kind of slow, just like Vista installation itself, and clumsy. In the end, I did need to reactivate windows. That process included:
- Windows telling me my original key was "currently in use"
- Calling tech support and dealing with giving/getting a 25 character alphanumeric key to/from a non-native english speaker. Even from a native English speaker that is a pain.
- Windows telling me the new key was "not valid with this version of Windows."
- Being told I would have to call back in an hour and given the "pay per incident" support phone number.
In a few minutes I just tried the automated phone support option in the activation window.
-The "activation ID" (or whatever it's called) I received automatically did not work.
-I was connected to another "technician"
-I only had to give her the first 6 digits of the 48 digit activation ID (phew)
-She gave me a new 48 which finally worked.
Who knows if it's using my new key or my old key, but now I understand why people try everything possible to avoid re-activation.
saikee first off I would like to thank you for creating such a great tutorial. I am a huge open source fan and people like you are what keep things going.
I recently received a new 120gb sata drive for my laptop and have decided that I am going to use your tutorial method to transfer my existing windows and fedora 6 drive to the more beefy counterpart. The only problem is that I need to move the data first to one of my external drives before I can move it back to my laptop, being as it has only the one singular sata connection.
My problem exists here. I have two external disks, one 250gb and one 400gb. The 250 is full but the 400 has less than 100gbs taken up. Using your tutorial I could transfer the contents of my 250 to my 400 and then use my 250 for the swap, but that would end up being a slight pain as, even though they are USB 2.0 it would add a significant amount of transfer time to take all the data off and slap it all back on after I am done.
I have seen the "Learn the DD command" thread from Awesome Machine on LinuxQuestions.org and noticed that you could use DD to write to a file... I think. It's just although his thread is very useful it seems a little hazy at times and I want to make sure. And even then I couldn't quite find the command it would take to copy the image file to my new disk.
Once again, thanks for your help. People like you make the open source world go round.
You do not need to back up the data before the cloning process. This is because you use the source disk "exclusively" for reading purpose in "if=/dev/hda".
Only the "device" specified in the "of=/dev/sda" will be written on.
Thus you can put the new 120Gb in a 2.5" hdd USB enclosure, boot up Fedora or a Linux Live CD and proceed with the cloning process.
If you are using 2/6/20 kernel or newer the existing laptop disk may be called sda and the new USB disk will be named as sdb. USB disk is always called sda or sdb in your case.
You can clone it with Fedora because the cloning process operates on the hardware level and does not affect the Fedora's mounted filing system.
I recommended to read Post #16 through and be certain of the input device name. No mistake can be made here!
In Open source we can talk about the theory and method openly and share the knowledge. I am only passing the knowledge the mods and members in JustLinux have taught me.
Last edited by saikee; 08-12-2007 at 11:42 AM.
Thanks for the advice, however my problem isn't backing up the hard drive that currently has my os's on it but using one of my current external drives as a middle man in the swap.
I want to go "current drive -> external drive" then move on to "external drive -> new drive" My only concern is that because dd writes the entire contents of the source disk bit for bit that I would lose my data on the external drive that I chose to use for the process. I could back up the data from the external drive but that would just add a good portion of time to the process.
I guess if I phrase it better my question would be "can dd write to a file so I can leave the current contents of one of my externals untouched?" And then how would I transfer that data to my new drive if it can write to a file?
I just thought I saw something on a different thread that said it could write to a ".dd" file or something of the sort.
I would just go out and buy a 2.5 sata enclosure but I am going to college soon and I need to cut as many corners when it comes to spending as I possibaly can.
Thanks again, your help is invaluable.
The output file in dd is "of=". You can just name a file there as the recipient of the output destination. I rarely go down this way though because you don't save time and the file is huge because dd does not do compression. You can compress the file afterward with tar or gzip but the file is only good after expansion to its original form.
Unfortunatly it seems as though my only choice now is to write to a file, then to write back to my new hd.
However, I have hit a roadblock due to my noobishness with linux. I tried to specify the output file onto one of externals but it returned the error "directory does not exist"
Do I need to mount the external I am copying to? How do I give the "of=" the correct path to write the file to one of my external drives?
Sorry for presenting you with what I assume is such a basic question but I tried to find out on my own through some basic linux shell tutorials and failed miserably.
You have to mount the external drive, have sufficient room in a directory and specify the absolute path to it, some thing like "of=/mnt/sdb1/backup_Aug_13."
Have alook at Awesomemachine's thread on dd too. Plenty of examples there.
Last edited by saikee; 08-13-2007 at 04:18 AM.
After I realized I was unable to use an old Compaq 5441 to clone my old 20GB HD into a new Samsung 100GB, (Samsung too big for Bios) I whined a bit, then bought a Maxtor external HD at Wal-mart, $74.
I plugged it into my Dell Inspiron 2650, booted on a Puppy 2.11 live CD, and typed on the terminal: dd if=/dev/hda of=/dev/sda bs=32768 <enter>
Since my Inspiron had USB 1.1 I had no idea how long it would take. Answer: around 6 or 7 hours. It reported:
610470 records in
610470 records out
I checked with fdisk -l and the external HD indeed was a near clone of the 20GB HD.
md5sum /dev/hda f211ffc1f778ab88d72f3e1b94869f60 on original HD.
I then shut down, swapped in the new Samsung into the Inspiron, and typed in:
dd if=/dev/sda of=/dev/hda bs=32768 count=610470 <enter>
I did not want the thing to run all the way to overflow, at that slow speed, thus the limit on blocks to known size shown during original clone.
I went to bed, and in the morning the external HD was apparently cloned onto the new Samsung.
md5sum /dev/hda 113fe44165be8fd4a936e133a89471e4 on the new cloned/cloned HD. Not the same. I don't know if this is grounds to worry or not.
I booted on the new clone, and though md5sum is changed, seems to work okay.
I then tried Puppy 2.11 qparted for partitioning. It insisted on making each new partition a primary partition.
Then, I tried qparted in Kubuntu 7.04 Live CD, and it did not give me the choice to format as ext3. Unless I did something wrong?
So, I dug around, could not find 2007 Mandriva install CD, must have left it in Mexico. I did find Mandrake 10.1 install CD, and then partitioned the rest of new HD into 5 more partitions, which will give me room for several distros. Also, 35GB Fat 32, to be used for storage. I used Mandrake/Mandriva since 1999, but they ship too much junk and I finally tired of it. Their install disks are the best partition tool I have ever used, so I keep one around just for that. Just continue install with custom partitioning, until partitions are set and formatted, then hit the power switch and remove install disk.
Anyway, I am using as I type the cloned HD, and soon will be installing new distros.
That 35GB storage, I am going to experiment. I will see if I can move .evolution and kppprc and other config files in there, and when I install a distro which uses one of them, split screen on file browser, and MAKE A LINK where it should go, then use the same file with all distros. And, any changes will instantly be available for all distros.
Well, if it doesn't work, I will have learned something useful.
I can understand only the first bit.
You were cloning a 20Gb disk, right? The 610470 number of record each 32768 byte long is exactly 20Gb. Say doing it in 6.5 hours averaging 0.854Mb/s or 6.83Mbit/s. That ties in pretty well with USB 1.1 burst speed of 12Mbit/s.
Unless your Maxtor disk is a desktop size of 3.5" I would have expected you to remove 20Gb disk and drop the Maxtor in and use it right away. Instead you use the Maxtor as the source to clone the 100Gb Samsung disk.
Your second cloning will be only successful if the Maxtor is less than 100Gb in capacity.
Anyway it looks you have achieved your aim. So congratulation.
Like many things in Linux, this is more complex in the contemplating than in the doing.
It was an external HD I bought, not a HD. It is a one-piece assembly. I suppose it could be taken apart, there are screws. But, I did not need to take it apart. Besides, unless it happened to be a laptop HD inside, (unlikely because they are generally more expensive) it wouldn't plug into my laptop anyway.
Now as far as being limited to an external HD no greater than the HD to be the end clone, that is the wonder of command dd.
Look at the command, and you will see at the end: count=610470 which was derived from the original transfer to Maxtor.
That means when I use the Maxtor as source to clone my new Samsung, it starts the transfer at the beginning, which includes MBR and partition tables, then when it finishes the 610470 blocks (size 32768) it stops.
So, the Maxtor can be 4 TB, if such a thing is possible, and cloning transfer will stop at exactly 20GB.
Also, someone in one of the threads reported that moving data from a larger partition than the recipient, results in a halt and error message that disk is full. In my case, I didn't want the transfer to run another 30 hours just to halt by itself, so I tried the COUNT parameter and it worked perfectly. Of course.
Hope this helps.
Last edited by irlandes; 09-16-2007 at 10:54 AM.
Reason: Added material
By the way, this is time to thank you again, Saikee. If it were not for the original thread, which you posted, and the reference link you supplied on my own question, and the follow-up assistance, I would have had absolutely no clue at all.
It is not friendly diplomacy on my part to say it would not have happened without your kind assistance. It is just plain fact. Thanks!