0

Cant figure how to enumerate all physical disks, like hdds, ssds, NVMes and maybe flashdrives connected to machine and filter out all these loop devices, ram disks, cdrom and floppies. I've checked out this and this to no avail.
In addition I would like to identify and distinguish remote device mapping(which are block devices) connected, like samba and such.
Any help is appreciated.

EDIT001: looks like /sys/block/devicename/device/type would give me some useful information according to this the question is if I should look for TYPE_DISK only or there is anything else I should consider

EDIT002: Interestingly, but NVMe disk does not contain ./device/type file

  • Did you look in the sources of lsblk? – ajeh Jun 18 '18 at 17:14
  • not yet. do you know I will find there something useful? – kreuzerkrieg Jun 18 '18 at 17:42
  • I imagine so, if the output of lsblk is what you are trying to get in your code. – ajeh Jun 18 '18 at 18:30
  • not exactly, lsblk shows disks as well as rom/loop devices. I think the /sys/block/devicename/device/type is the way to go – kreuzerkrieg Jun 19 '18 at 4:36
  • sudo udevam settle && LC_ALL=C lsblk -o name,type | grep 'disk$'? – AlexP Jun 19 '18 at 11:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.