1

I would like to create hard drive errors on my linux box - so that I can test that the application I'm writing performs correctly when there are uncorrectable errors.

I have an application from a hard disk manufacturer that will create bad sectors on a drive, but it is windows only - and would involve much plugging and unplugging of disks, as I am on a linux platform.

I have seen this previous post: Simulate a faulty block device with read errors? but cannot use this as I don't have dmsetup available.

I know I can use dd to corrupt files, by writing random data over files, but I would like to create a bad sector, not a readable, but corrupt file.

Any tips much appreciated

Thanks!

Community
  • 1
  • 1
time4tea
  • 2,169
  • 3
  • 16
  • 21
  • creating a bad block is a really bad idea, today every hearddisk has a seperate space to replace the bad blocks, so you would have waste this first, after this ur disk is dieing and soon you can trash it. you should go with "Simulate a faulty block...", dm (device mapper) is simple and isnt hard to set up! EDIT: posted as answer. – K1773R May 02 '12 at 09:53

1 Answers1

0

creating a bad block is a really bad idea, today every hearddisk has a seperate space to replace the bad blocks, so you would have waste this first, after this ur disk is dieing and soon you can trash it. you should go with "Simulate a faulty block...", dm (device mapper) is simple and isnt hard to set up!

K1773R
  • 922
  • 4
  • 10
  • 1
    i want to make a sector of a file that is already on the disk unreadable. i don't mind that it is a bad idea in general - in this particular case it is a good idea, because it is part of the acceptance criteria for some software! i will look again at dm, but i don't think the restricted kernel i have will support it. – time4tea May 02 '12 at 10:09
  • if its worth to waste a HD then go for it, write with DD constantly to a specified sector, but this will take really long and isnt a good idea at all. – K1773R May 02 '12 at 10:51
  • 1
    I think that you missed that his tool is from the hard drive maker, and it most likely marks a disk block as 'bad' but not really permanently. It does sound like a useful tool for testing RAID devices and OS filesystem drivers. – Zan Lynx Sep 23 '13 at 19:14
  • The obvious solution would be to write a block with a "crc" error. But I wonder how to make it too. – Camion Aug 25 '19 at 15:32