PDA

View Full Version : Cloning a harddisk



Balaam
04-02-2004, 01:18 PM
First off, i am more experienced in using Windows (all flavors since 3.1) than in using Linux.
Not that i'm 100% new to Linux, i have been working with Linux every now and then and i know some of the basics, but Linux still does hold a lot of secrets for me, especially the CLI commands do because there are so much of them.
I have done a search on this forum and read the FAQ here, but i couldn't find anything that seems to aplly to my problem.

Now that you know a bit about my background, here's my problem:
I have two equally sized harddisks (160GB), i'll call them #1 and #2.
#1 is starting to decay rapidly, so i want to move all my data over to #2. My question now is; is there a command or program that comes on the Knoppix CD (using 3.2 now) and that lets me clone an entire harddisk from one HDD to another? Maybe something that works like Norton Ghost.

On #1, i use Xp, i have both Fat, Fat32 and NTFS partitions, the MBR should be copied too, if possible.
#2 is clean, there is not even a partition table present.

I am getting rather desperate because i have a lot of data on my harddisks that i definitely do not wish to lose.
I really hope that someone can (and wants to :-)) help me here because i may lose all my data soon....

monkymind
04-02-2004, 02:20 PM
Open a terminal (konsole or rxvt etc) and type:

apt-cache show parted

That will give you a description of parted (partition manipulation program). If you want a gui parted version - try qtparted.

Cheers
rob

PS g4u - is another way of doing it: http://www.feyrer.de/g4u/

tommydl
04-02-2004, 02:20 PM
You can try using the command "dd". If the disks are identical (excactly same size down to the byte) you can simply do a "dd if=/dev/hda of=/dev/hdb" that will write all the contents of /dev/hda to /dev/hdb. WARNING all data on the of=/dev/xxx drive will be overwritten!

Balaam
04-02-2004, 03:28 PM
Open a terminal (konsole or rxvt etc) and type:

apt-cache show parted

That will give you a description of parted (partition manipulation program). If you want a gui parted version - try qtparted.

Cheers
rob

PS g4u - is another way of doing it: http://www.feyrer.de/g4u/

Thanks for the suggestions monkeymind, but it seems like Knoppix 3.2 does not have qtparted on board, but if it does, where would i be able to find it? I mean the path, or the location in the KDE start menu.
After looking through the readme of parted, it looks like parted is a program for manipularting individual partitions, what i really need is a track and sector copy program to make an idential copy of the old harddisk to the new one in one go.

g4u is not an option, my system does not meet the system requirements.

Again, i appreciate your input, but it seems that this is not the type of program/command that i was looking for.

Balaam
04-02-2004, 03:37 PM
You can try using the command "dd". If the disks are identical (excactly same size down to the byte) you can simply do a "dd if=/dev/hda of=/dev/hdb" that will write all the contents of /dev/hda to /dev/hdb. WARNING all data on the of=/dev/xxx drive will be overwritten!

Yes, the disks are identical, in the sense that it's the same brand, type and size.

Before i dare trying this, i need to be 100% sure about something.
HDD #1 is the primary slave and #2 is the secondary master.
I think that means that #1 is /dev/hdb and #2 is /dev/hdc, correct?
And how about error handling? Can it ignore bad clusters and/or read errors?
Oh, and overwriting HDD #2 is exactly what i want, thanks for the warning though.

I'm really scared to screw this up as you can probably tell, so please forgive me my insecurity and apperhensiveness.

OErjan
04-02-2004, 04:02 PM
sorry no. dd will make a 100% copy of the errors aswell... there are not many programs able to reliably recover those data, atleast not below 5k euro, and then not 100%gaurantee, sorry.
hmm, where did my earlyer reply go?? oh well.

Balaam
04-02-2004, 04:13 PM
sorry no. dd will make a 100% copy of the errors aswell... there are not many programs able to reliably recover those data, atleast not below 5k euro, and then not 100%gaurantee, sorry.

Copying the errors would be okay i guess, i have other (Windows- and DOS based) programs that may be able to recover some lost data.
As long as DD does not freak over bad clusters and such, i would be very, VERY happy.


hmm, where did my earlyer reply go?? oh well.

I think it's got eaten by the moof-monster. :-)

Oh, almost forgot, was i correct in assuming that the primary slave is /dev/hdb and the secondary master is /dev/hdc?

I am very nervous about trying anyting now, i have tried other things and it didn't work. I am so afraid of losing what's left of my data, i can hardly think straight....

OErjan
04-02-2004, 04:32 PM
why not check? do
dmesg |grep hd that should give some info. and if you then do a check to see which disk has which files...
fdisk -l might help some aswell, perhaps
mount can give some further info. if you do these it should become clear which disk is which. if not. ask and i will try to answer.
btw, as long as dd gets input it SHOULD not crash, if the disk otoh has i/o issues... it might.

Balaam
04-02-2004, 04:52 PM
why not check? do dmesg |grep hd that should give some info. and if you then do a check to see which disk has which files...

Thank you, when i do dmesg |grep hd i get this (trimmed the report a bit for readability):

ide_setup: hda=scsi
ide_setup: hdb=scsi
ide_setup: hdc=scsi
ide_setup: hdd=scsi
ide0: BM-DMA at 0xffa0-0xffa7, BIOS settings: hda:pio, hdb:DMA
ide1: BM-DMA at 0xffa8-0xffaf, BIOS settings: hdc:DMA, hdd:DMA
hdb: WDC WD1600JB-00EVA0, ATA DISK drive
hdc: WDC WD1600JB-00EVA0, ATA DISK drive
hdb: 312581808 sectors (160042 MB) w/8192KiB Cache, CHS=19457/255/63
hdc: 312581808 sectors (160042 MB) w/8192KiB Cache, CHS=19457/255/63


So, if i understand correctly, the system sees both harddisks. What i don't understand is why the report says "hdX=scsi", is that standard? (i hope it is)


fdisk -l might help some aswell,

It tells me the following:

Can't open /dev/hdc
Can't open /dev/hdb
I'm not sure what that means, does it mean that those disks are present but not mounted?


perhaps mount can give some further info. if you do these it should become clear which disk is which. if not. ask and i will try to answer.

Mount seems to show the mounted disks only and i haven't mounted the harddisks (yet) because i am just too afraid to damage anything, even though i do know that mounting them from KDE only mounts them in read-only mode.


btw, as long as dd gets input it SHOULD not crash, if the disk otoh has i/o issues... it might.

Well, thank you for making me even more nervous! :lol: :wink:

OErjan
04-02-2004, 04:56 PM
sorry, i just say it might, not likely but... and if you have important stuff not yet backed up to oter edia i would reomend leaving the disk to a profesional recovery lab. the cost is high but it is safest i can give advice on, if you do not have the budget... what will you loose?

Balaam
04-02-2004, 04:59 PM
sorry, i just say it might, not likely but... and if you have important stuff not yet backed up to oter edia i would reomend leaving the disk to a profesional recovery lab. the cost is high but it is safest i can give advice on, if you do not have the budget... what will you loose?

Please notice the smileys, the remark about making me more nervous wasn't meant to be taken seriously...

OErjan
04-02-2004, 05:05 PM
hey we might as well go via ICQ, we are reading/posting in near realtie anyway

monkymind
04-02-2004, 05:07 PM
Thanks for the suggestions monkeymind, but it seems like Knoppix 3.2 does not have qtparted on board, but if it does, where would i be able to find it? I mean the path, or the location in the KDE start menu.
After looking through the readme of parted, it looks like parted is a program for manipularting individual partitions, what i really need is a track and sector copy program to make an idential copy of the old harddisk to the new one in one go.

g4u is not an option, my system does not meet the system requirements.

Again, i appreciate your input, but it seems that this is not the type of program/command that i was looking for.

I don't know if knoppix 3.2 had qtparted ... but to find out
type in konsole:
sudo qtparted
if this doesn't work - try:
sudo nparted

BTW I'm not sure by what you mean about your sytem not meeting the requirements for g4u??? If your system can boot knoppix it can boot g4u ...........

Then use the copy drive to drive option:

* to copy disks locally, type copydisk disk0 disk1

Hope you find something that suits you!
Cheers
rob

Balaam
04-02-2004, 05:46 PM
hey we might as well go via ICQ, we are reading/posting in near realtie anyway

Good idea. I forgot my UIN, but found it again now. I have added it to my profile so feel free to contact me.

Balaam
04-03-2004, 12:53 PM
Here's a little status report:

I am not 100% finished with copying the harddisk but DD seemed to have been what i was looking for.
The only problem i have encountered was an I/O error which caused a termination of the copy process. But every cloud has a silver lining and the process did copy the partition table as well as a large part of the harddisk.

What i will need to do at this moment is compare all the partitions and copy the files that seem to be missing. One potential problem is that amongst those partitions are a few that are NTFS formatted, but i'll see how i'lkl tackle that one.

Thank you all for your help, and monkeymind, i have tried the copydisk command you've suggested, but it seems that this command also does not come with Knoppix 3.2, sorry....

Anyway, you now know how far i've got at this moment. I'll check back in when everything is ready and working.

Balaam
04-07-2004, 12:34 PM
Another update:

After my last post, i have copied the missing partitions using the command
dd /dev/hdbX /dev/hdcX and most partitions were copied just fine, but some revealed more I/O errors.
These errors were the reason why i needed to move my stuff from harddisk #1 to harddisk #2 in the first place. Anyway, these errors caused some partitions to be only copied partially.
Now the partition table contains the info that partition X, let's say /dev/hdb10 is 10GB, but because it's only partially copied, the actual size is smaller than reported.
So i must reformat those faulty partitions now (i have over 20 partitions) and filecopy the contents of the decaying harddisk over to the new one.

I am copying my files from the old harddisk to the new one using Midnight Commander (to noobs like me, the command is "mc") which works perfectly. It is a lot like Norton Commander so it looks and feels familiar, but it's much better at handling errors than any other method i have tried so far.

Expect at least one more status report from me a a later time.

Again, thanks to everyone that helped!