How To Benchmark A Raspberry Pi Storage Device

26, Nov 2024 | Raspberry Pi

Recommended Hardware & Tools

Check out my official Amazon Storefront to browse the exact parts, tools, and gear I use in my tutorials and videos.

As an Amazon Associate I earn from qualifying purchases.

Benchmarking The Raspberry Pi Storage

In this tutorial we will be showing you how to benchmark your Raspberry Pi's storage device. We will show you some manual methods and follow up with an automated all in one script to do most of the same benchmark tests.

In this example we are benchmarking a Raspberry Pi 5 using an SD card. These benchmark methods work for all raspberry pi models.

Boot Time Benchmark Test

First up, we’ll measure the SD card boot time. We’re going to use the systemd-analyze command to check how long the system takes to boot.

We will do this straight after a clean boot. This will give us an overview of the total boot time, splitting it into kernel and user-space initialization.

Reboot your Raspberry Pi.

Once your Raspberry Pi has fully rebooted.

Open up a terminal window via the Desktop menu or via SSH and input the following command.

systemd-analyze

Running this command shows us how quickly the Raspberry Pi 5 is able to get up and running using the Micro SD card.

Drive Read and Write Bookmark Test

Using hdparm Tool:

Next, we’ll move on to the read speed test. For this, we’ll use the hdparm tool.

You will need to install the hdparm application before you can use it. To install the hdparm application from a terminal use the following command:

sudo apt install hdparm -y

Now we have the hdparm tool installed run the following command to run a benchmark test.

Note: Replace /dev/sdcard with the correct identifier for your SD card.

sudo hdparm -t --direct /dev/sdcard

This command measures sequential read speeds, giving us insight into how fast data can be read from the storage device.

The output will provide a result in megabytes per second, showing us the raw read speed.

Using dd Command:

Now, let’s talk about write speed. We’ll use the dd command to create and write a 1 GB file filled with zeroes. This will help us see how fast data can be written to the storage.

dd if=/dev/zero of=test_file bs=1M count=1024 conv=fdatasync

This simple command will create a temporary test file, and we’ll measure the time it takes to write that file. To clean up after, don’t forget to remove the file with the rm command.

rm test_file

Using fio Tool:

For the next test, we’ll use fio, an excellent tool for simulating real-world read and write operations. This command will give us a deeper look at how the storage device performs under typical load scenarios.

fio --name=seq_rw_test --rw=readwrite --size=1G --direct=1 --bs=1M --numjobs=1 --runtime=60 --group_reporting

We’ll run this with a block size of 1 MB, and it will test both reading and writing, so we can see how the storage performs over a continuous period.

Using ioping Tool

Before using the ioping tool you will need to install the application.

Open a terminal and use the following command to install ioping.

sudo apt install ioping -y

Next, we’re going to check the latency of the storage with ioping. This tool performs random I/O operations to measure how quickly the system can access the storage.

ioping -c 10 .

Running this command 10 times will give us a reliable average latency for each type of storage.

Pibenchmarks Script Tool:

And finally, we’ll run a comprehensive test using the PiBenchmarks script. This will execute multiple tests invcluding many we have shown in this article. This tool provides a full benchmark overview. It also gives you a benchmark score.

sudo curl https:\/\/addictedtotech.net//staging.addictedtotech.net//raw.githubusercontent.com/TheRemote/PiBenchmarks/master/Storage.sh | sudo bash

This script is a great way to round off our benchmark tests and compare our results with others on pibenchmarks.com.

Here is an example of the output from a pibenchmark test.

Conclusion

Benchmarking your Raspberry Pi storage device can give you a good indication of its current performance. If you run the benchmark tests before you upgrade the storage from a Micro SD Card to a USB device or an NVMe you can re-run the benchmark tests to display the improvements in boot times and read and write speeds. You can even compare the benchmark scores with other storage drives on the pibenchmark.com.

Support My Work!

Buy Me A Coffee

Click The Image To Go To Site

Buy Me A Coffee

I Am An Affiliate!

Just so you know, we may collect a share of sales or other compensation from the links on this page. As an Amazon Associate, I earn from qualifying purchases.

The affiliate link recommendations come at no extra cost to you.

We hope you love the products we recommend!

Thank you if you use our links; we really appreciate the support!

0 Comments

Support My Work!

Buy Me A Coffee

Click The Image To Go To Site

Buy Me A Coffee

I Am An Affiliate!

Just so you know, we may collect a share of sales or other compensation from the links on this page. As an Amazon Associate, I earn from qualifying purchases.

The affiliate link recommendations come at no extra cost to you.

We hope you love the products we recommend!

Thank you if you use our links; we really appreciate the support!