nvme-benchmark.sh

Xerxes Pi 2026 Carrier Board for Raspberry Pi CM4/CM5 Modules · File : nvme-benchmark.sh · Language : bash · Use case : Tester les performances de lecture/écriture du stockage NVMe M.2 M-key intégré.

Bash script to measure sequential and random throughput of the card's M.2 NVMe storage.

Requires root privileges for direct disk access. Install 'fio' for advanced random tests. The script creates a temporary 1GB file. Ensure the NVMe module is loaded (lsmod | grep nvme).

nvme-benchmark.sh

#!/bin/bash
# Benchmark NVMe sur Xerxes Pi
# Assurez-vous que le disque NVMe est monté ou accessible via /dev/nvme0n1

DISK="/dev/nvme0n1"
TEST_FILE="/tmp/nvme_test.bin"
SIZE="1G"

echo "Vérification du disque NVMe..."
if [ ! -b "$DISK" ]; then
    echo "Erreur: Disque NVMe non trouvé sur $DISK"
    exit 1
fi

echo "Test d'écriture séquentielle..."
sudo dd if=/dev/zero of=$TEST_FILE bs=1M count=1024 oflag=direct

echo "Test de lecture séquentielle..."
sudo dd if=$TEST_FILE of=/dev/null bs=1M iflag=direct

echo "Test d'écriture aléatoire (fio requis)..."
if command -v fio &> /dev/null; then
    fio --name=randwrite --ioengine=libaio --iodepth=32 --rw=randwrite --bs=4k --size=1G --numjobs=4 --runtime=10 --group_reporting
else
    echo "fio non installé. Installation: sudo apt install fio"
fi

rm -f $TEST_FILE
echo "Benchmark terminé."

← Back to the board