Let's assume this is based on device-mapper. How can I tell if a given block device is already in use? (For example, a PV of a currently in use VG, or a encrypted LUKS device that is currently decrypted).

Also - how can I tell whether a given block device comes from device-mapper, or is a physical one?

  • 1
    Have a look at /sys/class/block/<device>/holders – Stéphane Chazelas Jul 18 '16 at 12:46

I think lsblk will answer these questions for you with a nice display.

ls /sys/class/block/*/holders/ | 
awk '/\/sys/ {line=$0; next} ! /^$/ {print line,"\t",$0} /^$/ {line=""}'

outputs the same information in a different format.

dmsetup deps has some complementary info.

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.