- 7 easy methods to check disk type (HDD or SSD) in Linux
- Check disk type (HDD or SSD)
- Method 1: Check if the disk is rotational
- Method 2: Using lsblk
- Method 3: Using disk model number
- Check disk interface types
- Method 1: Using lspci
- Method 2: Using lshw
- Why the bus info is SCSI when the disk interface type is ATA Disk?
- Method 3: Using hdparm
- Method 4: Using lsblk
- Conclusion
- Related Posts
- Linux Command To Find SATA Link Speed Such as 1.5 / 3.0 / 6.0 Gbps [ Hard Disk ]
- A note about SATA revision
- Linux Command To Find SATA Link Speed Such as 1.5 / 3.0 / 6.0 / 16.0 Gbps
- dmesg command examples
- Use smartctl command to find out SATA speed info on Linux
- Putting it all together
- Find Linux SATA link speed with hdparm command
- A shell script to find out Linux stata port speed info
- Conclusion
7 easy methods to check disk type (HDD or SSD) in Linux
Table of Contents
In this article I will share different commands which can be used to check the hard drive (disk) type in your Linux environment. I have verified these commands on RHEL/CentOS Linux so if you are using a different distribution such as Ubuntu, Debian, etc then some of the commands may now work.
Check disk type (HDD or SSD)
There are different types of disk available out of which the most used are Hard Drive (HDD) and Solid State Drive (SSD). You can use the following methods to identify your disk type whether it is HDD or SSD
Method 1: Check if the disk is rotational
You should check the value of /sys/block/sdX/queue/rotational , where sdX is the drive name. If the value is 0, you’re dealing with an SSD, and 1 means plain old HDD.
These are the available disks on my Linux server:
Now we can check the rotational value of these individual disks:
As the value for both the disks are 1, it means my both the disks are HDD.
Method 2: Using lsblk
Here also we will use the concept of identifying the disks with rotational feature to check the disk type. Although here we are using lsblk to list all the available connected disk types and their respective rotational values:
So all the identified disks have rotational value as 1 so this means they all are part of HDD.
Here I have another setup with SSD disks:
Method 3: Using disk model number
We can get the model number of the disk using lsblk command:
If you are using any kind of RAID such as hardware or software raid then it is possible you won’t get the model number with above command. In such case we have to rely on some third party tools. For example on my HPE Proliant Blades we are using hardware and software raid so on those servers I get following output:
As you see instead of Model Number, I get » LOGICAL VOLUME » so here I rely on HPE third party software such as ssacli and HPE Array Configuration Utility (acu cli) to get the model number. First we need the physical drive location, which can be collected using:
Now that we have the Physical Drive location i.e. 1I:1:1, we can query the details for this PD:
As you see it gives us a bunch of information about the drive we are using along with the model number.
Now that we have the model number of both our disk, we can search for the specification guide of these disks. For example the above model number is for Smasung disk which as per their online specification guide is SSD
You can also use different commands to get the model number of the disks, such as
This can give you a long list of output but you can filter the model number from the output, sample below from my server:
Check disk interface types
Now that you are familiar with the type of disk you are using, you should know the type of disk interface you are using in your environment. The different types of available disk interface types are
- Advanced technology attachment (ATA)
- Integrated Drive Electronics (IDE)
- Serial ATA (SATA)
- Small Computer system interface (SCSI)
- Serial attached SCSI (SAS)
- Fibre Channel
Method 1: Using lspci
lspci is a utility for displaying information about PCI buses in the system and devices connected to them. We can grep for the specific interface type from the output of lspci
Method 2: Using lshw
lshw is a small tool to extract detailed information on the hardware configuration of the machine. It can report exact memory configuration, firmware version, mainboard configuration, CPU version and speed, cache configuration, bus speed, etc. on DMI-capable x86 or IA-64 systems and on some PowerPC machines. It currently supports DMI (x86 and IA-64 only), OpenFirmware device tree (PowerPC only), PCI/AGP, CPUID (x86), IDE/ATA/ATAPI, PCMCIA (only tested on x86), SCSI and USB
Here is a sample output with SCSI disk interface
Here is a sample output with SATA interface
Here is a sample output from NVME disks
Here is a sample output with ATA disk interface
Why the bus info is SCSI when the disk interface type is ATA Disk?
If you observe the above output, we have ATA as the disk interface while the bus info is SCSI. The bud info is SCSI because that is the subsystem that provides IO for these disks.
It basically means that even though the disk interface is ATA, the drivers interact to the next kernel layer (the generic disk driver) using SCSI. This isn’t actually true of all SATA drivers on all kernel versions with all kernel compile-time configurations, but it’s common. Even PATA devices can appear as SCSI at that level (again, that depends on the kernel version and kernel compile-time configuration, as well as whether the ide-scsi module is used).
Method 3: Using hdparm
hdparm provides a command line interface to various kernel interfaces supported by the Linux SATA/PATA/SAS «libata» subsystem and the older IDE driver sub-system. Many newer (2008 and later) USB drive enclosures now also support «SAT» (SCSI-ATA Command Translation) and therefore may also work with hdparm.
We can use -I with hdparm which will request identification info directly from the drive, which is displayed in a new expanded format. Here are some example outputs:
But hdparm works exclusively with devices which speak the ATA protocol, for disks with other protocols, you may get the following error:
Method 4: Using lsblk
This can be one of the most reliable method to get the disk interface type. lsblk lists information about all available or the specified block devices. Using -o with lsblk we can print additional columns. To get the disk interface type we can use «TRAN» which will print the device transport type.
For example on a server using Fibre Channel:
On a server using HDD, here both the disks are using SAS protocol.
On Virtual Box environment, the virtual disks are using SATA while the DVD is using ATA protocol:
Conclusion
In this tutorial we explored different commands and methods which can be used to check the disk type and the disk interface type used to detect the disks in the server. But before you use these commands, you should be familiar with all the different disk and interfaces available.
Related Posts: how to check my hard disk is ssd or hdd. how to check if you have a solid state drive. what kind of hard drive do I have. how to check ssd. how to check disk type hdd or ssd. how to check disk interface type in Linux.
Related Posts
Didn’t find what you were looking for? Perform a quick search across GoLinuxCloud
If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.
For any other feedbacks or questions you can either use the comments section or contact me form.
Thank You for your support!!
Источник
Linux Command To Find SATA Link Speed Such as 1.5 / 3.0 / 6.0 Gbps [ Hard Disk ]
H ow do I find out my SATA link speed? How do I make sure my sata hard disk is working at 6Gbps speed and how do I verify this on a Linux server running on HP or IBM amd64 hardware?
Introduction: You need to go through the dmesg command output or a log file called /var/log/messages or /var/log/syslog . You can also use smartctl command to find out information about hard disk and current link speed on Linux based system. [donotprint]
Tutorial details | |
---|---|
Difficulty level | Easy |
Root privileges | Yes |
Requirements | None |
Est. reading time | 2m |
[/donotprint]
A note about SATA revision
- SATA REVISION => SPEED (
/s) - SATA revision 1.0 => 1.5 Gbit/s, 150 MB/s
- SATA revision 2.0 => 3 Gbit/s, 300 MB/s
- SATA revision 3.0 => 6 Gbit/s, 600 MB/s
- SATA revision 3.2 => 16 Gbit/s, 1969 MB/s
Linux Command To Find SATA Link Speed Such as 1.5 / 3.0 / 6.0 / 16.0 Gbps
You need to use the following commands:
- dmesg command – Display the Linux kernel ring buffer.
- smartctl command – Control and monitor command for SMART hard disks or SSDs.
Let us see all examples in details.
dmesg command examples
Open the Terminal or login using ssh command and than type the following command:
Here is another example:
You can find same info using /var/log/messages:
# grep -i SATA /var/log/messages | grep —color -i ‘link up’
Sample outputs:
Please note that on modern Linux distro /var/log/messages may be replaced with /var/log/syslog:
# grep -i SATA /var/log/syslog | grep —color -i ‘link up’
Use smartctl command to find out SATA speed info on Linux
Type the following command as root user:
- No ads and tracking
- In-depth guides for developers and sysadmins at Opensourceflare✨
- Join my Patreon to support independent content creators and start reading latest guides:
- How to set up Redis sentinel cluster on Ubuntu or Debian Linux
- How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
- How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
- A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
- How to protect Linux against rogue USB devices using USBGuard
Join Patreon ➔
Putting it all together
Gif 01: Linux commands to find out SATA link speed
Find Linux SATA link speed with hdparm command
To get SATA hard disk link speed, type:
A shell script to find out Linux stata port speed info
Here is outputs from all of above commands:
Conclusion
And there you have it; now you know how to find out your SATA link speed on Linux. The higher disk speed means a smoother experience for you on the desktop or a better server response for your web apps.
🐧 Get the latest tutorials on Linux, Open Source & DevOps via
Category | List of Unix and Linux commands |
---|---|
Documentation | help • mandb • man • pinfo |
Disk space analyzers | df • duf • ncdu • pydf |
File Management | cat • cp • less • mkdir • more • tree |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Linux Desktop Apps | Skype • Spotify • VLC 3 |
Modern utilities | bat • exa |
Network Utilities | NetHogs • dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • glances • gtop • jobs • killall • kill • pidof • pstree • pwdx • time • vtop |
Searching | ag • grep • whereis • which |
Shell builtins | compgen • echo • printf |
Text processing | cut • rev |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
Comments on this entry are closed.
How to know speed of my external usb HDD is there any specific command?
Ashwani the most reliable method is to copy a big file say 4GB or so.
From your system to external HDD and check iostat.
However, your internal HDD should be fast enough and system shouldn’t be loaded.
I trust this method 🙂
Interesting, but then, I would like to know more:
– How to you toggle to higher bit rate when/if possible?
– How do you link these message to your drives? For instance, you have here “ata3” link, how does this links to any /dev/sd.. ?
TIA,
— P
How to you toggle to higher bit rate when/if possible?
You need to pass boot time kernel parameters using grub. Search libata.force using this doc. Example to force 1.5G and 3.0G: libata.force=1:3.0G,2:1.5G
How do you link these message to your drives? For instance, you have here “ata3″ link, how does this links to any /dev/sd.. ?
You need to go through /sys/class/ata_link . Search for sata_spd file. Use lsscsi command to map ids.
By the way, on my Debian squeeze 6.0.5, /sys/class does not contain /ata_link but it contains:
- scsi_device
- scsi_disk
- scsi_generic
- scsi_host
I tried to find clues, such as in /sys/class/scsi_device/2\:0\:0\:0/device/, but then I cannot make a link to ata3 or alikes. No sata_spd found yet.
I have used lsscsi, either, and I have just watched your video and your lsscsi topic.
I am still unable to link “ata3” to an exact drive, “dmesg|grep” commands didn’t tell much, but thanks to you, I learned some new stuff. :-))
Commands discussed here depends upon your bios, hd firmware, motherboard and kernel driver. You need libata driver loaded. Linux ship with various ata driver located in /lib/modules/$(uname -r)/kernel/drivers/ata . Linux will load the correct driver at boot time as per your hardware. The examples output is taken from kernel v3.2.0 running on Debian Linux 6.0.5. For testing purpose try loading backported kernel v3.2.0.
FYI, on my plain debian 6.0.5, Linux uses following modules tree:
ata_generic => libata => scsi_mod
So kernel v3.2.0 does not seem mandatory for libata
Linux runs on a Thinkpad T400 laptop (exact model 64741AG).
To measure the actual speed of an external USB disk:
I use dd command from dev/null to a file on that USB disk, using block size parameter set to 1MB, and count set to 1000. This creates a 1 GB file, so averages disk speed, and eliminates buffering.
The above is for write speed
from a 1 GB file on the USB disk to /dev/null, you can test read speed
My SATA link shows 1.5 GB
[ 1.204017] ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
However when I check the read write speed I get
/dev/sda1:
Timing cached reads: 412 MB in 2.01 seconds = 205.47 MB/sec
Timing buffered disk reads: 166 MB in 3.03 seconds = 54.80 MB/sec
And when I copy a file over a 1 Gbps network connection I get around 30 to 40 mbps. What could be the bottle neck as I believe the network file transfer speeds should be able to reach over 105-110 Mbps.
The problem with relying on dmesg is that the message may have dissapeared on systems with a long uptime.
This can be an alternative:
$ smartctl -a /dev/sda|grep ^SATA
SATA Version is: SATA 3.0, 6.0 Gb/s (current: 3.0 Gb/s)
(on my SATA 1 disk, this line does not appear)
Your post (and some of the comments) inspired me to write this, it prints all ata_link speeds and devices:
Thanks for this script. It clearly printed the hard drive name and speed.
Instead of using
smartctl -a
you can use
smartctl -i for a more compact output. 🙂 For example:
Hi. I want to remove my optical drive and replace it with a ssd.
Here is output of above commands
sudo hdparm -I /dev/sda | egrep “Model|speed|Transport”
Model Number: TOSHIBA MQ01ABF050
Transport: Serial, ATA8-AST, SATA 1.0a, SATA II Extensions, SATA Rev 2.5, SATA Rev 2.6, SATA Rev 3.0
* Gen1 signaling speed (1.5Gb/s)
* Gen2 signaling speed (3.0Gb/s)
* Gen3 signaling speed (6.0Gb/s)
* SMART Command Transport (SCT) feature set
sudo smartctl -a /dev/sda | grep “^SATA”
SATA Version is: SATA 3.0, 6.0 Gb/s (current: 6.0 Gb/s)
does this mean i m goot with sata3.
yes, current: 6.0 Gb/s indicate that your hard drive named /dev/sda ( TOSHIBA MQ01ABF050 ) is running at sata3.
Источник