It's not a loopback device you're looking for, but rather device-mapper.
Use dmsetup
to create a device backed by the "error" target. It will show up in /dev/mapper/<name>
.
Page 7 of the Device mapper presentation (PDF) has exactly what you're looking for:
dmsetup create bad_disk << EOF
0 8 linear /dev/sdb1 0
8 1 error
9 204791 linear /dev/sdb1 9
EOF
Or leave out the sdb1
parts to and put the "error" target as the device for blocks 0 - 8 (instead of sdb1
) to make a pure error disk.
See also The Device Mapper appendix from "RHEL 5
Logical Volume Manager Administration".
There's also a flakey
target - a combo of linear
and error
that sometimes succeeds. Also a delay
to introduce intentional delays for testing.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…