Categories
Uncategorized

How to locate LUKS devices

Discover two distinct and easily sriptable methods and combine features from both of these to locate and identify LUKS devices.

Locate and display LUKS devices.

$ sudo blkid --match-token TYPE=crypto_LUKS
/dev/sda3: UUID="66a9da0f-a9a5-482c-8c27-c201685b8c17" TYPE="crypto_LUKS" PARTUUID="17303409-4d7d-4074-828b-0f4d101649a6"
/dev/loop24: UUID="b5df8ab7-a61d-404b-a1af-f763f46558f5" TYPE="crypto_LUKS"
/dev/sdc1: UUID="ac32a865-2716-43e3-8db9-798d4279a3a3" TYPE="crypto_LUKS" PARTUUID="3f3bac3f-01"

Directly identify specific device.

$ sudo cryptsetup isLuks /dev/sda3 && echo "This is a LUKS device." || echo "This is not a LUKS device"
This is a LUKS device.
$ sudo cryptsetup isLuks /dev/sda1 && echo "This is a LUKS device." || echo "This is not a LUKS device"
This is not a LUKS device