You are not logged in.
Hi,
I'd like to determine the type of a given block-device, whether there is a luks or an lvm on it or whether it is carrying a filesystem.
I can deremine the relations of several devices by looking at /sys/block/$name/{holders,slaves}. For device-mapper there is /sys/block/[name]/dm/uuid, which seem to start with a device-type ("LVM-$uuid" and "CRYPT-LUKS1-$uuid"). However, as I want to use it in a script, I'm not sure if I can rely on that for parsing and it does't exactly solve my problem with what is actually *on* the device.
I finally want to determine things like "this is carrying a luks, is this luks already opened and if, is it mounted or not?" For that I need information not only what this device is but what's on there, because if a luks is unopened, I cannot determine that it's a luks via looking at the holders (as there are none).
Does anyone have an idea how to deal with this or where I can read out this information? I could brute-force it by asking lvm, cryptsetup and so on, however, this seems quite unelegant to me, there might be a better way, doesn't it?
Thanks in advance!
Last edited by Ovion (2014-06-14 17:46:18)
Offline
I dont know of a single utility. you could parse through /etc/crypttab and use vgdisplay with grep.
"Do not attribute to malice that which can be explained through incompetence"
Offline
man 8 lsblk
Arch Linux is more than just GNU/Linux -- it's an adventure
pkill -9 systemd
Offline
man 8 lsblk
This.
The number of times I've used lsblk to work out what is there is unbelievable.
Claire is fine.
Problems? I have dysgraphia, so clear and concise please.
My public GPG key for package signing
My x86_64 package repository
Offline
lsblk is awesome! Thanks a lot!
Edit: nope, not exactely what I was looking for (but still quite awesome ).
The Problem is that lsblk is just working for already mounted/opened/... devices. What I plan to do is to use it in a way that I determine the type on a device (e.g. crypt) in a program and if this cryptocontainer is not open, I want to automatically open it. To know that I must call cryptsetup I must know what's on a device (e.g. crypt) before it's opened so that my script knows it has to open that with cryptsetup.
Any way to do this?
Last edited by Ovion (2014-06-13 14:14:57)
Offline