Skip to content


Some hard drive management tips and tools (on Linux)

Remember why this is called a notepad? Well, now is the time. 😉

To run some disk testing:
– quick tests (1 or a few minutes): smartctl -d ata -t short /dev/sda
– long tests (several hours, stops at first error): smartctl -d ata -t long /dev/sda
To read the results of said testings: smartctl -a /dev/sda

NB: usually smartctl is already installed on the distribution, but in case your provider ships a minimalist OS (this is the case of EUserv, for instance), you’ll need to install it yourself: simply run apt-get install smartmontools.

Another testing tool (haven’t really used it yet): badblocks /dev/sda

To reassign a block (although as far as I tested, this doesn’t work on ext4):
dd if=/dev/zero of=/dev/sda1 bs=4096 count=1 seek=3778301
sync

(cf http://www.gra2.com/article.php/20041015232512624 for more boring/tedious details, notably on how to compute the “seek” position)

Apparently, hdparm can be used to write to arbitrary sectors too, cf http://serverfault.com/questions/461203/how-to-use-hdparm-to-fix-a-pending-sector.

Finally a great combo to erase empty space on a partition, although this probably shouldn’t be used on a live machine because it will fill up the partition with a huge, random file, beore overwriting it several times:
dd if=/dev/urandom of=/some/file.name bs=4M
shred -uvz -n 7 /some/file.name

Source for this combo.
Note that /dev/urandom can be very slow on a cheap CPU, in which case it might be wiser to use /dev/zero as a source of data (since the file will be overwritten several times anyway). Check the documentation of shred, it’s interesting and short.

Posted in Linux.


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.

Sorry about the CAPTCHA that requires JS. If you really don't want to enable JS and still want to comment, you can send me your comment via e-mail and I'll post it for you.

Please solve the CAPTCHA below in order to fight spamWordPress CAPTCHA