Is there a way to tell, given a path to a LUKS block device, and not knowing the passphrase, whether the device is already open (decrypted)?
What about knowing the path to the decrypted device?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
The following code checks whether the device DEV_LUKS is an encrypted LUKS device and already opend (decrypted).
DEV_LUKS=/dev/sda cryptsetup isLuks $DEV_LUKS && echo "$DEV_LUKS is a LUKS Device" || echo "$DEV_LUKS is not a LUKS Device" test -b /dev/disk/by-id/dm-uuid-*$(cryptsetup luksUUID $DEV_LUKS | tr -d -)* && echo "$DEV_LUKS is opened" || echo "$DEV_LUKS is not opened"