The original idea comes from "dmsetup ls --tree", but lsblk(8) is better :-) It uses "holders" and "slaves" from /sys filesystem. This means that the util is usable without root permissions and it works for all types of block devices (dmsetup uses DM ioctls).
For example my laptop with dm-crypted $HOME and partitioned RAID0 (md8) on scsi_debug device (sdc):
$ lsblkYou can also list more details about devices. The next example is from scsi_debug device with 4KiB sectors and enabled alignment offset:
NAME MAJ:MIN RA SIZE RO MOUNTPOINT
sda 8:0 0 93.2G 0
├─sda1 8:1 0 102M 0 /mnt/test
├─sda2 8:2 0 1K 0
├─sda3 8:3 0 2.3G 0 [SWAP]
├─sda4 8:4 0 76.2G 0 /
├─sda5 8:5 0 10G 0
│ └─kzak-home (dm-0) 253:0 0 10G 0 /home/kzak
└─sda6 8:6 0 4.7G 0 /boot
sdc 8:32 0 500M 0
├─sdc1 8:33 0 250M 0
│ └─md8 9:8 0 498.9M 0
│ ├─md8p1 259:0 0 100M 0
│ ├─md8p2 259:1 0 100M 0
│ └─md8p3 259:2 0 297.9M 0
└─sdc2 8:34 0 249M 0
└─md8 9:8 0 498.9M 0
├─md8p1 259:0 0 100M 0
├─md8p2 259:1 0 100M 0
└─md8p3 259:2 0 297.9M 0
$ lsblk --topology /dev/sdblsblk(8) is also usable in script, for example:
NAME ALIGNMENT MIN-IO OPT-IO PHY-SEC LOG-SEC ROTA SCHED
sdb 3584 4096 32768 4096 512 0 cfq
├─sdb1 0 4096 32768 4096 512 0 cfq
└─sdb2 0 4096 32768 4096 512 0 cfq
$ lsblk --nodeps --noheading --raw -o ALIGNMENT /dev/sdbreturns only alignment-offset for device sdb.
3584
Thanks to Milan Broz (from Red Hat) who is author of the original lsblk(8) prototype.