Linux - HardwareThis forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
My HD fails badly when i try to dd copy it's content on another drive, then i have to cut power and plug it back to make it recognized again.
However, i noticed that i can clone the last partition without failure.
So the idea would be to dd the entire disk to another one, _starting from the end_ until it fails.
Or starting from a random X point, same X point where the copy will start on the target drive (it's two drives with same cylinders/sectors number).
Then i'll see what i can do from here.
Anyway, i don't know how to so this in a safe manner, and i don't want to do useless tries as it may damage my drive further :/.
I would do the minimum exercising of that knackered disk.
IME, the electronics of a disk goes, or else the platter fails. I'm presuming the latter. It gets worse as you thrash it.
Grab any good partition with cp-a; Even (sub)directories on bad partitions with cp-a, if you can. Ignore system files, and go after what you need only, in order of importance. You will get quick to realise when you have asked for something that's knackered, and be quick to hit Ctrl_C.
dd is big trouble to restore unless you have a similar disk (Same size, heads, cyls, sectors etc.). If you have an identical disk, the directories line up if you copy the whole shebang. Not otherwise.
Then, I might let e2fsck loose on it and say "Yes" to it. Your unreadable crap may build up in lost & found as bunches of sectors, and you can do your best with that later.
ddrescue has a "--reverse" mode for working from the end of the device/file toward the beginning. My limited experience with ddrescue has certainly never involved a drive that locks up when trying to read from a region with problems, so good luck with that.
As rknichols said, use ddrescue rather than dd. Because when dd runs into bad sectors it tries, tries and tries again to keep reading them. But they may be impossible to read due to your disk failure. ddrescue will do its best to read the mostest the fastest, skipping over problem areas initially, then coming back to them later to attempt further reading. Thus you don't waste what little life your harddrive may still have in it trying to read, re-read, and re-read again what may eventually prove to be impossible to read.
I omitted to say that i can't mount the partition 1, partition 2 is swap.
When i try to mount, dmesg reports a bunch of errors, and i lose the drive, having to unplug and replug power.
The partition 1 is xfs, and xfs_repair do the same.
Given the extra information you provided in your second post, I'm turning to the electronics as an armchair diagnosis. In this case, you're up the creek without a paddle and sinking fast.
I did rescue one disk in that state by buying a fresh one from the manufacturer(Maxtor), swapping in the card, and bingo, my data was there. Might be worth a shot.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.