4

How do I simulate a bad sectors block device on Linux to test some tools?

I followed the steps in Simulate a faulty block device with read errors?, but it is throwing "device-mapper: reload ioctl on bad_disk failed: Invalid argument" error.

Is there any other ways to create a bad sector block device?

Community
  • 1
  • 1
aandroidtest
  • 1,493
  • 8
  • 41
  • 68
  • Does it work fine if you simplify the description? For example remove the error block and leave only one linear device? Does it work with putting 2 devices with no error? How about error itself? – viraptor Aug 04 '15 at 10:05
  • "bad sector" is ambiguous: Unreadable or unwritable? Until recently I believed that re-writing to an unreadable sector ("pending") would rellocate it; however I have a harddisk that has thousands of read errors (SMART selftests also fail), but not a single redirected sector, even after overwriting. On that disk write operations also fail... – U. Windl May 05 '17 at 10:59

1 Answers1

1

This is way beyond my knowledge-base, but you may find this discussion useful. They are talking about using hdparm and the --make-bad-sector option. Buyer beware....

Another interesting discussion is this one, which talks about the difference between actually having a bad sector and manually creating one -- depending on what tools you are testing, these two may be registered and/or treated differently?

In any case, the most relevant things I found online were from the forums at hddguru, so chances are the folks over there might have some good input for you :)

Hope that helps with something...

svenevs
  • 833
  • 9
  • 24