Given a block device, how can I get its "parent"?
A example would be a LUKS virtual decrypted device (/dev/mapper/decrypted), whose parent would be the encrypted block device (/dev/sdb)
block-devicelinux
Given a block device, how can I get its "parent"?
A example would be a LUKS virtual decrypted device (/dev/mapper/decrypted), whose parent would be the encrypted block device (/dev/sdb)
Best Answer
For non-interactive work, this can be done using
dmsetup deps
, which lists the block device's dependencies. By default, it'll return the major:minor device numbers, but you can provide additional options to output a name:For doing this interactively, the best way is just to use
lsblk
, which outputs a nicely formatted graph: