M2 SSD Hard Drive

This document describes the complete process of partitioning, formatting, mounting, and performance testing an NVMe solid-state drive (using /dev/nvme0n1 as an example) in a Linux system, applicable to Quectel Pi H1.

Hardware Interface

image-20251126135111447

Quick Start

First, install 3 nylon standoffs and fix them at the bottom with 3 short screws. Then install the GPIO adapter by pressing firmly to ensure all pins are fully seated. Next, fully and evenly insert the PCIe riser cable into the single-board computer's PCIe interface, then push down the PCIe interface bracket from both sides to firmly secure the PCIe riser cable in place.

  • Front view after installation:
image-20251017154640006
  • Back view after installation:
image-20251017174920100
  • Side view after installation:
image-20251017155047092
  • Finally, place the M.2HAT+ on top of the nylon standoffs and secure it in place with 3 long screws.

Function Usage

Partition the NVMe device using the fdisk tool with the following steps:

Enter the Partitioning Interactive Interface

Execute the following command to launch fdisk and specify the target NVMe device:

fdisk /dev/nvme0n1

Interactive Interface Operation Steps

After entering fdisk interactive mode, execute commands in the following order:

Create a GPT Partition Table

Enter g and press Enter to create a GUID Partition Table (GPT), suitable for large-capacity devices (recommended):

Command (m for help): g
Created a new GPT disklabel (GUID: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX)

Create a New Partition

Enter n and press Enter to create a new partition. Keep the subsequent parameters (partition number, start sector, end sector) as default (the entire available space will be used by default):

Command (m for help): n
Partition number (1-128, default 1): 
First sector (2048-xxxxxxxxx, default 2048): 
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-xxxxxxxxx, default xxxxxx): 
Created a new partition 1 of type 'Linux filesystem' and of size XX GiB.

Write the Partition Table and Exit

Enter w and press Enter to write the partition configuration to the device and exit fdisk:

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

After completion, the system will generate a new partition /dev/nvme0n1p1 (p1 indicates the first partition).

Format the Partition (EXT4 Format)

Use the mkfs.ext4 tool to format the new partition into the EXT4 file system (suitable for most Linux environments):

mkfs.ext4 /dev/nvme0n1p1

After execution, the formatting progress will be displayed, and similar information will be output upon completion:

mke2fs 1.46.5 (30-Dec-2021)
Creating filesystem with 12345678 4k blocks and 3456789 inodes
Filesystem UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Superblock backups stored on blocks: 
  32768, 98304, 163840, ...
Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (65536 blocks): done
Writing superblocks and filesystem accounting information: done

Manually Mount the Partition

Create a Mount Directory

Use the mkdir command to create a directory for mounting the SSD (example path: /mnt/myssd):

mkdir -p /mnt/myssd

Mount the Partition

Mount the /dev/nvme0n1p1 partition to the /mnt/myssd directory:

mount /dev/nvme0n1p1 /mnt/myssd

You can verify that the mounting was successful using the df -h command. If the output includes /dev/nvme0n1p1 and /mnt/myssd, the mounting is working correctly:

df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/nvme0n1p1  100G   5G   95G   5% /mnt/myssd

Configure Automatic Mounting (Effective After Reboot)

Implement automatic mounting of the partition during system startup by modifying the /etc/fstab file:

Edit the fstab File

Open /etc/fstab using the nano editor (other editors like vim can also be used):

Add Mount Configuration

Add the following line at the end of the file to specify the partition, mount point, file system type, and mount parameters:

/dev/nvme0n1p1  /mnt/myssd  ext4  defaults  0  2

Performance Testing (Read/Write Speed Verification)

Use the dd command to test the read/write performance of the SSD (ensure the partition is mounted during testing):

Read Speed Test

Create a temporary test file and test the read speed by reading the file to the null device (/dev/null):

dd if=/mnt/myssd/testfile of=/dev/null bs=1G iflag=direct # iflag=direct: bypass system cache to test the real read speed
1+0 records in
1+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 0.852345 s, 1.3 GB/s

Write Speed Test

Generate a 1GB empty file (/dev/zero as the source of zero data) to test the write speed:

dd if=/dev/zero of=/mnt/myssd/testfile bs=1G count=1 oflag=direct
1+0 records in
1+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 1.245678 s, 862 MB/s

After testing, you can delete the temporary file:

rm /mnt/myssd/testfile