Distinguish SATA vs. SSD disk on the command line?

Hi,

I’m currently trying to know if I have a SATA or an SSD disk installed on an HP ProDesk. Before opening it, I wonder if there’s a command that allows to get this kind of information. I’ve googled this, but only found some unreliable information.

Any suggestions ?

Niki

There seems to be “rotational” property among the “ansible_devices” data.

- hosts: all
  gather_facts: false
  tasks:
  - name: Collect only facts about devices
    ansible.builtin.setup:
      gather_subset:
      - '!all'
      - '!min'
      - devices
      filter:
      - ansible_devices
    register: devdata

  - debug:
      msg: "{{ item.value.model }} : {{ item.value.rotational }}"
    loop: "{{ devdata.ansible_facts.ansible_devices | dict2items }}"
    loop_control:
      label: "{{ item.key }}"

Alas, at least VM’s and SD-card readers return suspicious value.

(I did assume HDD spinner vs SSD, not SATA SSD vs NVMe SSD.)

1 Like

I know you are using ansible, so jlehtone’s answer may be better, but for manual inspection if you have smartd enabled, and the drives support it, you can use journalctl | grep -i ssd to show any SSD drives, and journalctl | grep -i smart will show if smartd is running, and if it is what it is currently monitoring. Look for a line like this one:

Monitoring 3 ATA/SATA, 0 SCSI/SAS and 0 NVMe devices

You can track disks down to id’s and busses used vai cmds like:
lshw -class disk -class storage
lsblk -S <–show only SCSI
lsblk -d -o MODEL,SIZE,STATE,TYPE,ROTA,KNAME,HCTL,TRAN,VENDOR
lspci
lsscsi
et.al. (too many to list)

You could of course use dmesg | grep <keyword> or journalctl -b | grep <keyword> to shrink the search space for speed, and systemctl status smartd.

2 Likes

The lsblk is a binary. Ansible is Python code. They probably read from same place.
The latter seems to look from /sys/block. If they can, then we can:

for DD in /sys/block/*
do echo $(basename ${DD}) $(cat ${DD}/queue/rotational)
done
2 Likes

I suggest the following commands and examples.

Command #1
lsblk --nodeps --all --output NAME,SIZE,TYPE,MOUNTPOINT,MODEL,VENDOR,TRAN

<< example #1 >>

NAME  SIZE TYPE MOUNTPOINT MODEL            VENDOR   TRAN
sda   300G disk            Virtual disk     VMware
sr0  1024M rom             VMware SATA CD00 NECVMWar sata

<< example #2 >>

NAME  SIZE TYPE MOUNTPOINT MODEL            VENDOR   TRAN
sda   1.8T disk            Logical Volume   LSI      sas



Command #2
lsscsi -c

<< example #1 >>

Attached devices:
Host: scsi0 Channel: 00 Target: 00 Lun: 00
  Vendor: ATA      Model: TOSHIBA MG04ACA2 Rev: FP3B
  Type:   Direct-Access                    ANSI SCSI revision: 06
Host: scsi0 Channel: 00 Target: 01 Lun: 00
  Vendor: ATA      Model: TOSHIBA MG04ACA2 Rev: FP3B
  Type:   Direct-Access                    ANSI SCSI revision: 06
Host: scsi0 Channel: 01 Target: 00 Lun: 00
  Vendor: LSI      Model: Logical Volume   Rev: 3000
  Type:   Direct-Access                    ANSI SCSI revision: 06

<< example #2 >>

Attached devices:
Host: scsi0 Channel: 00 Target: 00 Lun: 00
  Vendor: VMware   Model: Virtual disk     Rev: 2.0
  Type:   Direct-Access                    ANSI SCSI revision: 06
Host: scsi1 Channel: 00 Target: 00 Lun: 00
  Vendor: NECVMWar Model: VMware SATA CD00 Rev: 1.00
  Type:   CD-ROM                           ANSI SCSI revision: 05



if there is installed smartmontools (smartctl), use smartctl -a devicename

1 Like

I think NezSez’s answer is pretty good. I would like to make his answer a little bit easier to use.
From my own ThinPC, the commands I used are as belows:

# lspci | egrep "NVME|SCSI|SAS|SATA" 
00:1f.2 SATA controller: Intel Corporation 8 Series/C220 Series Chipset Family 6-port SATA Controller 1 [AHCI mode] (rev 04)
 # lsblk -d -o MODEL,SIZE,STATE,TYPE,ROTA,KNAME,HCTL,TRAN,VENDOR
MODEL         SIZE STATE   TYPE ROTA KNAME HCTL       TRAN   VENDOR
Hoodisk SSD 119.2G running disk    0 sda   0:0:0:0    sata   ATA     
                4G         disk    0 zram0                   
                0B         disk    0 zram1                   
                0B         disk    0 zram2 

As you can see, the storage controller in my thinPC is an embeded SATA controller, while the disk in my thin pc is a 120G SATA SSD.
Hope this helps you.

1 Like

Note that Solid State Disk (SSD) is a storage type, while Serial Advanced Technology Attachment (SATA) is a connection protocol. It’s very common to have an SSD connected by SATA. Perhaps you mean M.2/NVMe vs SATA, or HDD vs SSD?