For testing purpose I need to simulate a crash of the disk (by detaching it) while other processes are using it.
I tried:

umount -f /srv/node/d1/

It doesn't want to unmount it. It shows me the next message:

umount: /srv/node/d1: target is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))

There several processes which I don't want to stop manually because it will not be a crash. Does somebody know how to just detach a disk in linux? It would be more easy to detach it physically but I am using a virtual machine with virtual disks.

  • 1
    may be echo "1" >/sys/dev/block/<id>/device/delete , where <id> is the id of a block device? – Serge Oct 7 '16 at 14:04
  • 1
    You can simulate failures of disks using scsi_debug kernel module. Or do you need to test one of your existing real devices? – rudimeier Oct 7 '16 at 14:10
  • @rudimeier I need to simulate it with the existing device – Alexandr Oct 7 '16 at 14:34
  • If this is a virtuel machine you can "unpresent" the disk. (not sure that will properly simulate a crash) – Archemar Oct 7 '16 at 14:41
  • @Archemar Do you know how to do it? – Alexandr Oct 8 '16 at 8:25

It will be easier to use device mapper doing a linear remapping to the underlying disk and mounting from there as you can then simulate the disk crashing by switching device mapper to return the error target (e.g. through the use of dmsetup wipe_table). See https://unix.stackexchange.com/a/144200/134856 for this and other (such as using scsi_debug) disk error simulation techniques.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.