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.

Florian Heer
  • 111
  • 4

2 Answers2

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.

Florian Heer
  • 111
  • 4
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.

shodanshok
  • 44,038
  • 6
  • 98
  • 162