문제

I'm working on a OS portable program that would benefit from detecting if a physical storage device is a SSD or a plain old spin-disk.

On Linux there is:

/sys/block/sdX/queue/rotational

which return 0 or 1 if SSD, but I'm not sure if this is the best way.

On Windows and UNIX I have not found any way of detecting it, perhaps I should use ioctl DEVICE_SEEK_PENALTY_DESCRIPTOR and check the seek penelty (which should be very low on a SSD storage device), or perhaps use DeviceIoControl to check the nominal media rotation rate (which also should be very low on a SSD storage device).

Any recommendations for me on how to proceed with detecting SSD disks on POSIX compatible OS'es?

도움이 되었습니까?

해결책

Related: https://unix.stackexchange.com/questions/65595/how-to-know-if-a-disk-is-an-ssd-or-an-hdd

IMO though. You could use the POSIX method of determining the OS, and have various methods to detect SSD, and when it can't be determined, simply ask the end-user, and if they don't know, have a safe default. I guess that is what I would do if there wasn't a POSIX compliant method (but I would probably check the POSIX mailing list first though too). I hope this helps.

다른 팁

I'll echo Lorenzo Gatti's comment above in saying that the best way to do this is almost certainly an option exposed to the user. There is no portable way of doing this, and I'd not be surprised if other OSs (particularly older ones, which are a problem unless you have some guarantee that your users are using a somewhat current OS) had no way of doing this.

Really, a checkbox along the lines of "I am using a solid-state drive", defaulting to off, would probably be the best option, especially since the ones likely to have an SSD are (for now, at least) tech-savvy enough to know what they have.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top