How to check if my Ubuntu is placed on SSD?

Dude, where's my root?

First of all we need to know on what disk your root filesystem is located ( in other words , what device houses your Ubuntu. One way is with df.

$ df / -h                                                                       
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       110G   58G   48G  55% /

Great ! I now know that my Ubuntu is placed onto /dev/sda disk, which is 110 GB in size ( and the other 10 GB are used for something else). Not enough info ? OK, how about this:

$ sudo lshw -short -C disk                                                      
[sudo] password for xieerqi: 
H/W path         Device     Class          Description
======================================================
/0/1/0.0.0       /dev/sda   disk           120GB Radeon R7
/0/2/0.0.0       /dev/sdb   disk           500GB TOSHIBA MQ01ABF0

Oh, Radeon R7 ! that's my SSD ! But wait . . .

What if you have two disks that are the same size and the same manufacturer?

Well, disks have this very interesting bit of information - how fast they rotate, and as we know SSD disks don't rotate.

$ sudo smartctl -a /dev/sda | grep 'Rotation Rate'                              
[sudo] password for xieerqi: 
Rotation Rate:    Solid State Device

Looks about right ?

Side-note: the smartmontools may need to be installed in order to use smartctl command.

For more info, read this post on Unix and Linux stackexchange site

Additional update:

There's one more method , as described here. Each drive has corresponding directory in /sys/class/block/ directory, and by doing

cat /sys/class/block/DEVICE_NAME/queue/rotational

you will get either 1 for hard drive or 0 for ssd. This approach is very convenient for usage in scripts

In fact, that's apparently the same approach that lsblk uses:

$ lsblk -o NAME,ROTA                                                                                                                  
NAME   ROTA
sda       0
└─sda1    0
sdb       1
├─sdb1    1
├─sdb2    1
├─sdb3    1
├─sdb4    1
├─sdb5    1
└─sdb6    1

A simple way to tell if your OS is installed on SSD or not is to run a command from a terminal window called lsblk -o name,rota. Look at the ROTA column of the output and there you will see numbers. A 0 means no rotation speed or SSD drive. A 1 would indicate a drive with platters that rotate. My Ubuntu is installed on my /dev/sdb drive, so we can see that one indicates a 0 which means it is installed on a SSD drive. I put after this example of how to tell where your OS is installed using df.

NOTE: Ubuntu that is installed as a client in either loop or VMs will show ROTA 1 regardless of host OS installation. Also, "solid-state hybrid drives" and USB flash drives will also show ROTA 1.

Example:

terrance@terrance-ubuntu:~$ lsblk -o name,rota
NAME   ROTA
sda       1
└─sda1    1
sdb       0
├─sdb1    0
├─sdb2    0
└─sdb5    0
sdc       1
└─sdc1    1
sdd       1
└─sdd1    1
sde       0
├─sde1    0
└─sde2    0
sdf       1
└─sdf1    1
sdg       1
└─sdg1    1
sdh       1
└─sdh1    1
sr0       1
sr1       1

Or you can do the check as a one liner script using -d to not show partitions:

lsblk -d -o name,rota | awk 'NR>1' | grep -v loop | while read CC; do dd=$(echo $CC | awk '{print $2}'); if [ ${dd} -eq 0 ]; then echo $(echo $CC | awk '{print $1}') is a SSD drive; fi; done

Example:

terrance@terrance-ubuntu:~$ lsblk -d -o name,rota | awk 'NR>1' | grep -v loop | while read CC; do dd=$(echo $CC | awk '{print $2}'); if [ ${dd} -eq 0 ]; then echo $(echo $CC | awk '{print $1}') is a SSD drive; fi; done
sdb is a SSD drive
sde is a SSD drive

To determine what drive your installation is on, run the command df / from a terminal window.

NOTE: Drives configured with LVM (Logical Volume Management) actually show the drive as /boot instead of /.

Examples:

LVM Drive:

df /
Filesystem                   1K-blocks      Used Available Use% Mounted on
/dev/mapper/xubuntu--vg-root 243352964 106945028 123976576  47% /

df /boot
Filesystem     1K-blocks   Used Available Use% Mounted on
/dev/sda1         720368 237220    430756  36% /boot

Non-LVM Drive:

df /
/dev/sdb1       222309012   38264268  172728984  19% /

UPDATE: lsblk can also be used to show where the OS is installed and if the drive is SSD all in one command:

lsblk -o NAME,MOUNTPOINT,MODEL,ROTA

Example:

terrance@terrance-ubuntu:~$ lsblk -o NAME,MOUNTPOINT,MODEL,ROTA
NAME   MOUNTPOINT         MODEL            ROTA
sda                       Backup+ Desk        1
└─sda1 /media/Seagate                         1
sdb                       WDC WD2500JD-00K    1
└─sdb1 /media/250GB_SHARE                     1
sdc                       WDC WD5000AAKS-4    1
└─sdc1 /media/500GB                           1
sdd                       ST500DM002-1BC14    1
└─sdd1 /media/320GB                           1
sde                       SanDisk SDSSDA24    0
├─sde1 /                                      0
├─sde2                                        0
└─sde5 [SWAP]                                 0
sdf                       WDC WD5000AAKX-2    1
└─sdf1 /media/WD500GB                         1
sdg                       WDC WD10EZEX-00W    1
└─sdg1 /media/1TB_SHARE                       1
sdh                       SanDisk SDSSDA24    0
├─sdh1                                        0
└─sdh2 /media/Windows                         0
sr0                       BD-RE  BH16NS40     1
sr1                       DVD-RAM GH40L       1

This is after a system reboot, so my drive designations changed again, but as you can see my SanDisk drives are SSDs and ROTA shows 0.


Hope this helps!


In the end your question isn't really a Ubuntu question. You have a Hard Drive with a small, relative to the size of the HD, amount of flash storage. This is managed automatically for you by the drive and tries to place the more frequently accessed files on the Flash portion rather than the HD portion. As far as I know there is no way to control or tell what files are on which portion. If you regularly use Ubuntu all the important files should end up in the flash portion of your drive but that's about it.