Bad blocks handling of nwipe
Closed this issue · 4 comments
Ahoy! I hope you’re doing well.
I’ve modified my mount-loop
script to create loopback devices with a random number of bad blocks. When I use dd
to write data to every block, it eventually encounters a bad block, resulting in the following error:
dd: error reading '/dev/mapper/faulty-loop-loop0': Input/output error
0+0 records in
0+0 records out
0 bytes copied, 0.000136647 s, 0.0 kB/s
However, when I use nwipe
, it completes without any issues. Does nwipe
only detect bad blocks if they fail during the wiping process?
That's a useful feature. How does it achieve one or more bad blocks in a loop device?
Are they contiguous bad blocks or single random location bad blocks?
That's a useful feature. How does it achieve one or more bad blocks in a loop device?
Are they contiguous bad blocks or single random location bad blocks?
Hey. Yeah it's quite advanced now.
This script simulates bad blocks using the following steps:
-
Loop Device Setup: It sets up a loop device from a file, which simulates a block device using the
losetup
command. -
Faulty Block Simulation: When using the
faultymount
orfaultymountfs
options, the script creates a loop device and simulates faulty blocks by setting up a Device Mapper (DM) table using thedmsetup
command. The faulty blocks are passed as arguments (e.g., block numbers or ranges).- The Device Mapper table is used to define how blocks are mapped. In this case, some blocks are mapped to an "error" target to simulate failures when those blocks are accessed.
- The script parses the faulty blocks provided as input (e.g.,
500-510
) and creates the DM table. The valid blocks are mapped normally, and the specified faulty blocks are mapped as errors, which effectively "corrupts" those blocks.
So you can manually specifiy specific blocks to be bad.
faultymount 1G 500,1000 Create a 1G-sized loop device with blocks 500 and 1000 faulty."
Or a whole range of blocks.
faultymountfs 1G 500-510 Same as above but also create a filesystem and mount it, blocks 500 to 510 faulty."
But don't forget, in this case write to the /dev/mapper
device, not the underlying loop device directly.
https://github.com/Knogle/mount-loop
Are there maybe any more functions that could be useful?
Thanks for the detailed description, I think I'll fork that and start using it for my own tests.
I can't think of any new features at the moment, but if I do I'll be sure to let you know.