0

I have an external USB drive, which - for whatever reason - sometimes drops out unrecoverably. Probably due to faulty cables or something. On this I have a LUKS partition.

dmesg reports

Buffer I/O error on dev dm-0, logical block 0, lost sync page write

lsusb shows no difference between a fully working condition and the dropout.

I would like to monitor this partition as I also like to have it available. It's not vital to be available, otherwise I would choose different technology here. Also the disk is supposed to spin down whenever it is not in use.

Watching free space does not help, as the OS apparently caches that information and reports the last known state. Trying to access the filesystem for monitoring does not work either, as I don't want the disk to spin up regularly.

This might be a trivial question, yet I could not find an answer. To clarify: I only ask how to find out that the device dropped out, resp. the LUKS partition is not available. Not how I can notify anyone.

1

Some investigation and try-and-error lead to a rather simple solution.

cryptsetup status <label>

produces (amongst others) the line

device:  /dev/sda1

when all is working and

device:  (null)

when the device has gone away.

0

You can use lsusb to monitor the state/presence of external USB devices. However, using something as dm-crypt on an unreliable device is a recipe for disaster, and I strongly suggest you to avoid it.

  • I'll give it a try. And: of course this setup cannot be recommended for anyone except the slightly insane :-) – Florian Heer Mar 4 '18 at 12:11
  • Unfortunately, lsusb still reports the device like nothing happened. – Florian Heer Mar 4 '18 at 12:29

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.