How to know if a disk is an SSD or an HDD

  • I want to know whether a disk is a solid-state drive or hard disk.

    lshw is not installed. I do yum install lshw and it says there is no package named lshw. I do not know which version of http://pkgs.repoforge.org/lshw/ is suitable for my CentOS.

    I search the net and there is nothing that explain how to know whether a drive is SSD or HDD. Should I just format them first?

    Result of fdisk -l:

    Disk /dev/sda: 120.0 GB, 120034123776 bytes
    255 heads, 63 sectors/track, 14593 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x00074f7d
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/sda1   *           1          14      103424   83  Linux
    Partition 1 does not end on cylinder boundary.
    /dev/sda2              14         536     4194304   82  Linux swap / Solaris
    Partition 2 does not end on cylinder boundary.
    /dev/sda3             536       14594   112921600   83  Linux
    
    Disk /dev/sdc: 120.0 GB, 120034123776 bytes
    255 heads, 63 sectors/track, 14593 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x00000000
    
    
    Disk /dev/sdb: 128.0 GB, 128035676160 bytes
    255 heads, 63 sectors/track, 15566 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x00000000
    
    
    Disk /dev/sdd: 480.1 GB, 480103981056 bytes
    255 heads, 63 sectors/track, 58369 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x00000000
    

    If this really is a SSD you might want to reformat it to align the erase blocks with the partitions.

    SATA (Serial ATA) refers to the connection type of the drive, and does not imply that it is a Hard Disk Drive (HDD). SSDs can simultaneously be SATA, so I'm suggesting an edit to the title.

  • Totor

    Totor Correct answer

    8 years ago

    Linux automatically detects SSD, and since kernel version 2.6.29, you may verify sda with:

    cat /sys/block/sda/queue/rotational
    

    You should get 1 for hard disks and 0 for a SSD.

    It will probably not work if your disk is a logical device emulated by hardware (like a RAID controller).

    See this answer for more information...

    On Stackoverflow somebody found this sys-info didn't work.

    @PythoNic please file a kernel bug report about this.

    @totor Better add this comment on the other post. I don't know his/her kernel version :)

    Nice! Works without having sudo privileges.

    The method does not work for USB sticks – they are certainly not rotational drives (see Doesn't detect USB flash drive as SSD).

    What about hybrid drives?

    @CMCDragonkai They propably appear as rotational since the flash memory is mostly an "improved cache". You tell us...

    @Totor You are correct in the "hybrid" drives. However, dual-drive hybrids show up as two individual drives, where SSHD (Solid-State Hybrid Drive) shows up as a single drive. So, the SSHD would show rotational of 1.

    On virtual servers, you may need to fetch `/sys/block/vda/queue/rotational`

    On certain computers, you need to run `cat /sys/block/nvme0n1/queue/rotational` instead, `sda` does not exist on my laptop

    @Ferrybig There are only SSDs in NVME format, not HDDs (unless you do have some strange breakout adapter from NVME slot to plain SATA cable). But not sure if even SATA SSD over NVME shows as NVME in linux or as plain sdX.

    This works if you know which device to show (e.g. `sda`) a-priori. If you want to discover disks + whether they are rotational, try @don_crissti answer.

License under CC-BY-SA with attribution


Content dated before 6/26/2020 9:53 AM