📜 ⬆️ ⬇️

Quick search for intact areas on a dying hard drive

Hard drives are known to be wobbly. This is especially true in the small user class, in which they do not dream of the reliability of, say, server hardware. However, failures of the glands dear to our heart at the most inappropriate moment for this can even be delivered to the home user by a lot of unpleasant minutes, hours or even days (I recently told you about one such case, unfortunately, do not express how much time was killed to fight the wrong equipment). Faced with the task as quickly as possible to find out which area barely live external hard drive with a capacity of 160 GB. To stick a partition at least 10 in size and to be more or less confident in it, I was surprised to find that, at least remaining faithful to the Linux operating systems, this could not be done with existing tools. As it was necessary to get out - welcome under kat.


What is


It turned out that the linuksoid is equipped with the e2fsck utility to check for errors and correct them on the existing ext2 / ext3 / ext4 partitions. Its important feature is the ability to integrate with another utility - badblocks - and thus the broken disk blocks and mark them so that they are not used later (this feature is activated using the –c key). To check the surface of the disk that does not yet have file systems, you can use the same integration with the badblocks utility mk2fs to create file systems by running with the same key. In the cases described, by default, the read-only check mode is started, in which the badblocks, which is clearly trying to draw conclusions about the performance of disk blocks only for read operations. By doubling the -c key in the main utilities (or using the -n key when running badblocks directly), you can perform the check in a safe read-write mode that does not damage your data. Only now it works for an order of magnitude (if not more) longer and hangs heavily, like the main mode, in a collision with heavily damaged areas of the disk. A dangerous method of speeding up the read-write mode can be to explicitly launch badblocks with the -w key (read-write data, which destroys data) and redirect its output (through a stream or file) to the mk2fs or e2fsck utilities, safe - please interrupt the check with a large number errors (-e n key) - but instead of bypassing the broken section with entering its coordinates in the log, the badblocks in this case just stop working. That's what this behavior is and I want to fix it.

What do you want


And I want to have a utility that quickly runs through the disk, analyzing it adaptively, and tells the user that such and such part of it is hopeless, but here and there you can try to create a partition and fully check, hoping that, firstly, time will not be wasted, and secondly, you really did all or almost everything possible in such a hurry way that it is relatively safe to place your data. For starters, you can try to create an add-on over badblocks, which will allow, as an experimental study, to flexibly change the mode of operation of the badblocks extension, the essence of which is the omission of heavily damaged areas and general accelerated testing by cutting the disc into pieces and checking only parts of each piece blocks - this will allow with some predetermined accuracy (± n-megabytes, for example) to find suspicious parts of the disk for m-megabytes that are uninterrupted, and then, as an option, investigate and denser and do not waste time on a heavily fragmented disk of the injury.
')
A prototype (quite working, my specific task with an external disk, he decided) can be found in the git-repository of goodranges . The main objective of this article is to gather from the community ideas and comments on the development of this prototype in the existing utility. Any comments in any form you like are welcome, as are pull ricksta.

Of course, the prototype is experimental in all respects and the work on it is a great end, so please do not beat it with slippers for style and architectural solutions.

PS The utilities mentioned in the article have exhaustive man pages. Enjoy reading

Source: https://habr.com/ru/post/148428/


All Articles