sebhildebrandt / systeminformation

System Information Library for Node.JS
MIT License
2.73k stars 310 forks source link

Please add more info in blockDevices #308

Open BillDietrich opened 4 years ago

BillDietrich commented 4 years ago

All of this is on Linux Mint 19.2, don't know if it shows up differently on other OS's:

For each device, the partition size is given, but not the partition starting address. Please give starting address. Also please give any "flags" on the partition.

For each device, there is a type field and an fstype field. But I think maybe these should be three fields, maybe devicetype (disk or part), partitiontype (primary, extended, logical) and fstype. The issue I am having is with understanding the partitioning on my Linux hard disk, as follows:

"sudo parted -l | more" gives me:

Model: ATA WDC WD3200BEVT-7 (scsi)
Disk /dev/sda: 320GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End     Size    Type      File system  Flags
 1      1049kB  1024MB  1023MB  primary   ext4         boot
 2      1026MB  320GB   319GB   extended
 5      1026MB  37.0GB  36.0GB  logical   ext4
 6      37.0GB  320GB   283GB   logical   ext4

blockDevices gives me:

{
    "name": "sda",
    "type": "disk",
    "fstype": "",
    "mount": "",
    "size": 320072933376,
    "physical": "HDD",
    "uuid": "",
    "label": "",
    "model": "WDC WD3200BEVT-7",
    "serial": "WD-WXC1AB0N6142",
    "removable": false,
    "protocol": "sata"
},
{
    "name": "sda1",
    "type": "part",
    "fstype": "ext4",
    "mount": "\/boot",
    "size": 1023410176,
    "physical": "",
    "uuid": "4d00a399-3c8a-4621-92d6-2853cf52ab3a",
    "label": "",
    "model": "",
    "serial": "",
    "removable": false,
    "protocol": ""
},
{
    "name": "sda2",
    "type": "part",
    "fstype": "",
    "mount": "",
    "size": 1024,
    "physical": "",
    "uuid": "",
    "label": "",
    "model": "",
    "serial": "",
    "removable": false,
    "protocol": ""
},
{
    "name": "sda5",
    "type": "part",
    "fstype": "ext4",
    "mount": "\/",
    "size": 35998662656,
    "physical": "",
    "uuid": "eca7e79b-b45a-4d3c-bef3-5a6bfcd32f05",
    "label": "",
    "model": "",
    "serial": "",
    "removable": false,
    "protocol": ""
},
{
    "name": "sda6",
    "type": "part",
    "fstype": "ext4",
    "mount": "\/home",
    "size": 283047362560,
    "physical": "",
    "uuid": "b5033879-a8ab-4ade-9605-fa272887e0c4",
    "label": "",
    "model": "",
    "serial": "",
    "removable": false,
    "protocol": ""
},

It seems to me that blockDevices is losing the distinction among physical/primary/extended/logical partitions. I don't fully understand this stuff, maybe I'm wrong about some of it. Thanks.

BillDietrich commented 4 years ago

For each device, the partition size is given, but not the partition starting address. Please give starting address. Also please give any "flags" on the partition.

On Linux, this information can be obtained from "fdisk -l":

Disk /dev/sda: 298.1 GiB, 320072933376 bytes, 625142448 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x505e25fb

Device     Boot    Start       End   Sectors   Size Id Type
/dev/sda1  *        2048   2000895   1998848   976M 83 Linux
/dev/sda2        2002942 625141759 623138818 297.1G  5 Extended
/dev/sda5        2002944  72312831  70309888  33.5G 83 Linux
/dev/sda6       72314880 625141759 552826880 263.6G 83 Linux
the-nicolas commented 3 years ago

It would be great to have at least the information from lsblk correctly.

The method blockDevices() returns more or less information about the filesystem and not about the partition layout.

https://github.com/sebhildebrandt/systeminformation/blob/49f9bebbc4a9edb56da3a313df03b56a5276a45a/lib/filesystem.js#L354

It would be great to have columns like PARTUUID and PARTLABEL, because this information is essential to identify and mount the filesystem to the correct mountpoint.

Mixing filesystems, disks and partitions to one data structure seems not to be the best idea, because they have almost nothing in common (just the name attribute and size).

I use as workaround now https://github.com/balena-io-modules/partitioninfo That thing is not calling any external command and reads the MBR directly - bleeding fast.

If your script has root access running "sfdisk -J /dev/xx" also returns everything you can imagine directly as JSON...