Skip to content

Prepare a USB flash drive

Chris edited this page May 7, 2022 · 2 revisions

On a Raspberry Pi it is critical to use external storage for the SQLite3 database. The Network Performance Monitor performs tens of thousands of database write operations per day. If the database is stored on the SD card it will reduce the lifespan of the card; SD cards are not designed to support so many write operations on a system that will be running 24/7. I use a 64GB USB 3 flash drive. A USB 3 SSD would be the best solution for external storage.

To set up a USB flash drive for this project, follow these steps:

Format the USB flash drive

Format the flash drive with an ext4 filesystem. I use GParted on my laptop for this task.

Do not use NTFS or FAT formats, as these will cause issues with file permissions later in the installation process.

Configure auto-mounting

Now we will configure Raspberry Pi OS to automatically mount the USB flash drive at boot time.

Find the UUID of the target partition on the flash drive. In my case, the device name of the USB flash drive is /dev/sda and the target partition is /dev/sda1:

sudo blkid -s UUID -o value /dev/sda1

Example output:

89cdb8e4-6539-45ff-aee3-f3a5a23e55e2

Create a mount point for the drive:

sudo mkdir /mnt/usb_storage

Add an fstab entry so that the drive mounts automatically on boot:

sudo nano /etc/fstab

Add a line for your USB flash drive, e.g.:

UUID=89cdb8e4-6539-45ff-aee3-f3a5a23e55e2 /mnt/usb_storage auto nosuid,nodev,nofail 0 0

You can mount the drive immediately by using the following command:

sudo mount -a

The USB flash drive will be automatically mounted at boot time, but only if it is connected to the RPi during the boot sequence. I suggest that you leave the USB flash drive permanently connected to the RPi.

Create a directory for application data

Create the directory for database and report storage:

sudo mkdir -p /mnt/usb_storage/netperf


Proceed to the next step: Install project files and required software packages

Clone this wiki locally