LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Learn the DD command (https://www.linuxquestions.org/questions/linux-newbie-8/learn-the-dd-command-362506/)

ukiuki 04-19-2012 02:39 AM

How DD threat bad sectors when cloning?
 
How DD threat bad sectors when cloning? Got 500GB HDD that is starting to falling, it is just a system drive no data to backup, will DD make a clean copy of the system when the drive has bad sectors?

Regards

catkin 04-19-2012 02:46 AM

The best you can do is use conv=sync,noerror on the dd command so it leaves empty blocks when it gets an error when reading the input. That way, the blocks on the output HDD end up in the right places.

ukiuki 04-19-2012 03:34 AM

Quote:

Originally Posted by catkin (Post 4656940)
The best you can do is use conv=sync,noerror on the dd command so it leaves empty blocks when it gets an error when reading the input. That way, the blocks on the output HDD end up in the right places.

Thank you.

unSpawn 04-19-2012 04:38 AM

The best you can do is use dd as described by catkin and check out ddrescue and dd_rescue. Both offer options not present in 'dd' like reading a disk back-to-front, retrying and copy rate adjusting.

ukiuki 04-19-2012 02:23 PM

Quote:

Originally Posted by unSpawn (Post 4657100)
The best you can do is use dd as described by catkin and check out ddrescue and dd_rescue. Both offer options not present in 'dd' like reading a disk back-to-front, retrying and copy rate adjusting.

That is really good to know, thank you.
I hope that using DD will be possible to avoid reinstall the system again(ugh), it is a big install of programs.

Regards

ukiuki 04-20-2012 07:11 AM

Code:

dd if=/dev/sda of=/dev/sdb bs=512 conv=sync,noerror
I did the above command it did copied the whole disk, but not all the partitions content, just the 1st one had the data copied, it generated all the partitions thou the 2nd and so are empty. Why is that so?

Regards

catkin 04-20-2012 08:56 AM

Quote:

Originally Posted by ukiuki (Post 4658251)
Code:

dd if=/dev/sda of=/dev/sdb bs=512 conv=sync,noerror
I did the above command it did copied the whole disk, but not all the partitions content, just the 1st one had the data copied, it generated all the partitions thou the 2nd and so are empty. Why is that so?

Regards

Because the partition table is at the beginning of the disk after the 446 byte master Boot Record (MBR). What you are seeing suggests the early part of the dying HDD is readable but the later parts not. The first partition may not be completely populated. You could try fscking the copy (not the original or you may further damage it).

ukiuki 04-20-2012 10:13 AM

Quote:

Originally Posted by catkin (Post 4658351)
Because the partition table is at the beginning of the disk after the 446 byte master Boot Record (MBR). What you are seeing suggests the early part of the dying HDD is readable but the later parts not. The first partition may not be completely populated. You could try fscking the copy (not the original or you may further damage it).

The problem is with the SMART.
Ok i got this with Clonezilla !! Not sure what happened with DD but now it is working just fine all partitions has been cloned and running! :)

Regards

AwesomeMachine 05-19-2012 06:21 AM

manufacturer's disk repair utility, dd, ddrescue, foremost, fsck
 
Quote:

Originally Posted by ukiuki (Post 4656931)
How DD threat bad sectors when cloning? Got 500GB HDD that is starting to falling, it is just a system drive no data to backup, will DD make a clean copy of the system when the drive has bad sectors?

Regards

Usually the best thing is to use the manufacturer's repair utility, seatools, wddiag, etc; and do a nondestructive scan for bad sectors.

The data can usually be successfully relocated from the failing sectors to extra sectors on the drive used for this purpose.

That's the first line of defense. Most drives are not really failing. They just have an imperfect area on one surface platter. My experience has been that running the utility permanently solves the problem, and the drive works for five or ten years more.

But, the test can fail if the drive controller is bad. The utility prints a report.

dd is not a sophisticated recovery tool. It's my last choice. I've never used dd for data recovery. But dd has an undocumented function. Over time, data tracks expand. This can give bad blocks errors. So, you can write the drive back to itself:

dd if=/dev/sda of=/dev/sda

That tightens the tracks.

ddrescue is better. It contains sophisticated algorithms to read the edges of bad tracks, to repeatedly read the same track and pick up a little bit more of the data with each pass, to read the drive backwards, to guess at the correct contents to fill small unrecoverable gaps within blocks of recovered data, to operate without a valid partition table, but I have seen it fail.

foremost is a file carver. It will carve out every file. The problem is it doesn't preserve the file names (uses numbers instead), recovers deleted files, recovers only a small number of file types by default, groups the files in a directory tree according to file type.

But I've seen foremost recover everything off a DVD+R that looked like it had been put under a vehicle tire for traction to get out of a snow bank. I had a CD that I scored with deep knife cuts for disposal, but I messed up. Then I had to recover the data.

Foremost can recover everything from a disk like that. The moral is, it takes a bit of work and ingenuity to render a CD safe for disposal.

Everything has some risk, but fsck has a map and relocate bad blocks function that gives you an idea of what eternity might be like, but it's one of the safest remedies.

You choose based on how critical the operation is.

slxu 05-22-2012 02:24 PM

Awsome!
 
This thread really helps me a lot.

apjena 09-05-2012 01:27 AM

very nice post on dd
 
Thanks for this nice educative post. I just wonder can anyone give a reason why dd if=...iso of=/dev/sdb to create a bootable flash works sometime and sometime not. It seems a powerful command but it doesnot work sometimes where MS Windows programs like lilo (great app though) work on same flash drive and same iso.

TobiSGD 09-05-2012 05:03 AM

Copying an ISO image to a disk using dd is only possible if the ISO image is a hybrid-ISO.

schneidz 09-05-2012 08:21 AM

Quote:

Originally Posted by apjena (Post 4772978)
Thanks for this nice educative post. I just wonder can anyone give a reason why dd if=...iso of=/dev/sdb to create a bootable flash works sometime and sometime not. It seems a powerful command but it doesnot work sometimes where MS Windows programs like lilo (great app though) work on same flash drive and same iso.

i dont think lilo is an ms windows program :confused: ?

if you run the file command it will tell you if your iso is a partition or an image of a full disk including boot sector and partition table (judging by your example command you are expecting the latter).

nug121 09-09-2012 05:49 AM

DD post..
 
Thank you for writing that post. I am tired and needed to go to sleep a while ago but reading that kept me up and caused me to register on this site and post.

AwesomeMachine 09-23-2012 05:51 AM

U3
 
Quote:

Originally Posted by apjena (Post 4772978)
Thanks for this nice educative post. I just wonder can anyone give a reason why dd if=...iso of=/dev/sdb to create a bootable flash works sometime and sometime not. It seems a powerful command but it doesnot work sometimes where MS Windows programs like lilo (great app though) work on same flash drive and same iso.

U3 -Awesome


All times are GMT -5. The time now is 11:19 PM.