systeminformation
systeminformation copied to clipboard
feature: Linking partitions and disks with si.diskPartitions() or additional field [Windows]
Is your feature request related to a problem? Please describe.
For a given directory path, I want to be able to know the disk the path is located at. Ex. The user would like the app to store data at D:/my/favorite/storage. The app should show the user the mounted storage device name (and other device details) at path D:/my/favorite/storage.
Describe the solution you'd like
I believe, on Mac & Linux, that I can combine accurately blockDevices and diskLayout to determine the disk, by using the "identifier": "disk4s1" on blockDevices[i] and "device": "disk4", on diskLayout[j]. Similarly on Ubuntu blockDevice[i].name = "sda" and diskLayout[j] = "/dev/sda" so I can do this join without any changes.
However, on Windows, it doesn't seem possible with those two methods as identifier gives D: and device on Windows gives SCSI\\DISK&VEN_NVME&PROD_HFM001TD3JX013N\\5&EB4279F&0&000000.
There could be an additional method si.diskPartitions, which the users can use to join diskLayout and blockDevices data. Or for a smaller change, we can use the join method described at https://stackoverflow.com/a/31092004 and add an additional field to diskLayout or blockDevices so that they can be linked.
The result of this join looks something like
DiskSize : 1024203640320
RawSize : 1002245004800
FreeSpace : 594412773376
Disk : \\.\PHYSICALDRIVE1
DriveLetter : C:
DiskModel : HFM001TD3JX013N
VolumeName : OS
Size : 1002245001216
Partition : Disk #1, Partition #1
DiskSize : 2000363420160
RawSize : 2000363274752
FreeSpace : 887951982592
Disk : \\.\PHYSICALDRIVE2
DriveLetter : D:
DiskModel : SanDisk Extreme 55AE SCSI Disk Device
VolumeName : NodeSSD
Size : 2000353755136
Partition : Disk #2, Partition #0
Now I can show the user the device name, free storage, etc. available at path D:/my/favorite/storage because we know the disk (storage device).
Describe alternatives you've considered Partially described above for Mac. Not sure about Linux yet. Will test.
Additional context Add any other context or screenshots about the feature request here.
@sebhildebrandt I see, in the docs, that si.diskLayout[i].device is not supported for Windows. Would setting device to the drive letter (ex. C: or D:) on Windows make sense?
@jgresham this makes absolutely sense!! Will provide a solution for that in the next few days. Can I contact you to give it a try? If all runs fine I then will publish a new release.
@sebhildebrandt Awesome! Please let me know how I can help in any way!
Could I help in any way?
@jgresham thank you ... already working on it but not yet ready ;-)
I need the linked data for my project soon. Do you think it will be ready in the next week? Otherwise, I'm thinking to fork and implement it in the meantime. I can link my fork here for reference.
UPDATED !!
@jgresham As I am working on this, I would need to check it with also your current data: can you provide the full output of:
Powershell:
Get-WmiObject -Class Win32_diskdrive | Select-Object -Property PNPDeviceId,DeviceID, Model, Size, @{L='Partitions'; E={$_.GetRelated('Win32_DiskPartition').GetRelated('Win32_LogicalDisk') | Select-Object -Property DeviceID, VolumeName, Size, FreeSpace}} | fl
Data from systeminformation ... maybe you can clone the code and run npm run test, then press d (diskLayout) , e (blockDevices) and f (fileSize).
Thank you in advance.
...btw. sorry for the delay! One of our family members died and it was a tough time ....
Output of raw command:
PNPDeviceId : SCSI\DISK&VEN_NVME&PROD_HFM001TD3JX013N\5&EB4279F&0&000000
DeviceID : \\.\PHYSICALDRIVE1
Model : HFM001TD3JX013N
Size : 1024203640320
Partitions : @{DeviceID=C:; VolumeName=OS; Size=1002245001216; FreeSpace=650691387392}
PNPDeviceId : SCSI\DISK&VEN_NVME&PROD_SABRENT_ROCKET_4\5&1079444C&0&000000
DeviceID : \\.\PHYSICALDRIVE0
Model : Sabrent Rocket 4.0 2TB
Size : 2000396321280
Partitions :
PNPDeviceId : SCSI\DISK&VEN_SANDISK&PROD_EXTREME_55AE\7&26157617&0&000000
DeviceID : \\.\PHYSICALDRIVE2
Model : SanDisk Extreme 55AE SCSI Disk Device
Size : 2000363420160
Partitions : @{DeviceID=D:; VolumeName=NodeSSD; Size=2000353755136; FreeSpace=887955128320}
npm run test d output:
┌────────────────────────────────────────────────┐
│ Disk Layout v: 5.14.4 │
└────────────────────────────────────────────────┘
[
{
device: 'SCSI\\DISK&VEN_NVME&PROD_HFM001TD3JX013N\\5&EB4279F&0&000000',
type: 'SSD',
name: 'HFM001TD3JX013N',
vendor: '',
size: 1024203640320,
bytesPerSector: 512,
totalCylinders: 124519,
totalHeads: 255,
totalSectors: 2000397735,
totalTracks: 31752345,
tracksPerCylinder: 255,
sectorsPerTrack: 63,
firmwareRevision: '41000C20',
serialNum: 'FFFF_FFFF_FFFF.',
interfaceType: 'NVMe',
smartStatus: 'Ok',
temperature: null
},
{
device: 'SCSI\\DISK&VEN_NVME&PROD_SABRENT_ROCKET_4\\5&1079444C&0&000000',
type: 'SSD',
name: 'Sabrent Rocket 4.0 2TB',
vendor: '',
size: 2000396321280,
bytesPerSector: 512,
totalCylinders: 243201,
totalHeads: 255,
totalSectors: 3907024065,
totalTracks: 62016255,
tracksPerCylinder: 255,
sectorsPerTrack: 63,
firmwareRevision: 'RKT401.3',
serialNum: '6_A74C_6030.',
interfaceType: 'NVMe',
smartStatus: 'Ok',
temperature: null
},
{
device: 'SCSI\\DISK&VEN_SANDISK&PROD_EXTREME_55AE\\7&26157617&0&000000',
type: 'SSD',
name: 'SanDisk Extreme 55AE SCSI Disk Device',
vendor: 'SanDisk',
size: 2000363420160,
bytesPerSector: 512,
totalCylinders: 243197,
totalHeads: 255,
totalSectors: 3906959805,
totalTracks: 62015235,
tracksPerCylinder: 255,
sectorsPerTrack: 63,
firmwareRevision: '3001',
serialNum: '214R402',
interfaceType: 'USB',
smartStatus: 'Ok',
temperature: null
}
]
Time to complete: 4.136s
npm run test e output:
┌────────────────────────────────────────────────┐
│ Block Devices v: 5.14.4 │
└────────────────────────────────────────────────┘
[
{
name: 'C:',
identifier: 'C:',
type: 'disk',
fsType: 'ntfs',
mount: 'C:',
size: '1002245001216',
physical: 'Local',
uuid: 'A8209090',
label: 'OS',
model: '',
serial: 'A8209090',
removable: false,
protocol: ''
},
{
name: 'D:',
identifier: 'D:',
type: 'disk',
fsType: 'exfat',
mount: 'D:',
size: '2000353755136',
physical: 'Local',
uuid: '6EC5B470',
label: 'NodeSSD',
model: '',
serial: '6EC5B470',
removable: false,
protocol: ''
}
]
Time to complete: 1.053s
npm run test f output:
┌────────────────────────────────────────────────┐
│ File System v: 5.14.4 │
└────────────────────────────────────────────────┘
[
{
fs: 'C:',
type: 'NTFS',
size: 1002245001216,
used: 351574712320,
available: 650670288896,
use: 35.08,
mount: 'C:'
},
{
fs: 'D:',
type: 'exFAT',
size: 2000353755136,
used: 1112398626816,
available: 887955128320,
use: 55.61,
mount: 'D:'
}
]
Time to complete: 1.024s
..and how terrible :( sorry to hear about your family member. Please don't be sorry for a delay
PS: I am extremely grateful that you maintain this amazing open source library. So thank you for your work and commitment to open source.
@jgresham Thank you so much for your kind words. And also thank you for providing all requested information. This is what I can work with. Will provide a first version till tomorrow evening.
@jgresham I made a first version and It would be fine if you can test it: can you do the following:
mkdir sysinfo
cd sysinfo
git clone https://github.com/sebhildebrandt/systeminformation.git
npm run test
then just type on key e and grab the output. Here you should now see an additional property device which corresponds to the device id of diskLayout(). This should give all to link diskLayout(), blockDevices() and fsSize().
Key q quits the test.
Does this gives proper output and does it make sense that way? I was only able to test it on one single windows machine so it is not sure that all runs as expected. If you find issues, please just post it here ;-) I need also to test it on other machines but I cannot do this right now ...
Regards
@sebhildebrandt Yes, makes sense! Looks good to me!
I tested with my setup and the device's match across block devices and disks as expected. Tested with two internal ssd, external ssd, and external usb drive. Also, I don't have any other device with Windows to test on :(
Thank you! This is extremely helpful :)🙏
@jgresham thank you so much for testing!! AND thank you so much for supporting the project on buymeacofee. I will make a new release tonight ... Currently this is now working on linux, max OS and windows. For windows I am pretty sure that there is room for improvements. Will review (and improve) this after having the possibility to test it more in detail. Thank you once again and comments are always welcome.
@jgresham new version 5.15.0 just published with updated docs