Is there a way to benchmark the read/write performance of SSD? Using Ubuntu 18.04 with GNOME
Does the newest Ubuntu come with a utility called
Here’s a quick few commands.
Use hdparm to test read speeds
- Get a list of your disks and paritions.
Look for the nvme device
nvme0n1 259:0 0 232.9G 0 disk ├─nvme0n1p1 259:1 0 268M 0 part /boot ├─nvme0n1p2 259:2 0 31.6G 0 part / ├─nvme0n1p3 259:3 0 31.6G 0 part [SWAP] └─nvme0n1p4 259:4 0 169.6G 0 part /home
Yes I did some crazy things with the swap partition, that’s why it’s so big.
Now install hdparm
sudo apt-get install hdparm
Confirm all the steps
Run the tool against your partition or disk you found earlier with lsblk:
sudo hdparm -Tt /dev/nvme0n1
Gnome disk utility
There’s also a graphical UI method!
- Open the Gnome disk utility from the launcher
- Select your hard disk in the left pane.
- Click “Benchmark – Measure Drive Performance” button in right pane by clicking on the circular gear icon.
A new window with charts opens.You will find and two buttons. One is for “Start Read Only Benchmark” and another one is “Start Read/Write Benchmark”. When you click on anyone button it starts benchmarking the NVMe disk
Example images to illustrate what you should see
Gnome Disk utility UI
Be careful with the write test as it can potentially overwrite data.
Using DD to test read/write speeds
Alternatively you can use dd. Be careful with this as this is a data firehose, if you point it at the wrong drive you can obliterate the existing data
So how does the dd command work?
It has a
if Input File parameter, and an
of Output File. Data flows from input to output. and then we can specify a few control parameters as well to control that flow. We are going to be using
bs Block Size (how big chunks of data we want) and
count , count is the amount of blocks we want to copy.
Navigate to the root of the nvme disk, if your os is installed on the nvme,
cd / should work.
Now flush buffers with sync, this makes sure that all cached data in ram is first written out to disk, then write a 1GB file of data zero’s to disk.
sync; dd if=/dev/zero of=tempfile bs=1M count=1024; sync
Note instead of
/dev/zero you can also use some other sufficiently large file on your system as the
if parameter, but you need to first copy it into /tmp so it is loaded in ram and not slowing down the disk you are benchmarking by simultaneously reading from it.
If you want to do that do that do the following instead
cp path_to_largefile /tmp/tempfile sync; dd if=/tmp/tempfile of=tempfile bs=1M; sync
This will give you a speed result when it’s done.
Test read speeds
First clear caches so that our system isn’t just reading from ram/ ‘cheating’
$ sudo /sbin/sysctl -w vm.drop_caches=3 vm.drop_caches = 3
BTW supplementary info
Setting drop_caches frees pagecache, d entries and inodes
Next read the file we wrote earlier back into the null device.
$ dd if=tempfile of=/dev/null bs=1M count=1024
This should give you a read speed result once done.
check out fio - https://github.com/axboe/fio