Installing Raspberry Pi OS

After the assembly is complete, we will start installing the system for the Raspberry Pi. Regardless of whether you want to install the system on the NVMe SSD or not, you need to install the system on an SD card or USB flash drive first.

Analysis

  1. First of all, make sure you can enter the Raspberry Pi OS via SD card or U drive.

  2. After booting the Raspberry Pi, you can use it to flash the OS image directly onto the NVMe SSD. Alternatively, you can purchase an NVMe SSD to USB adapter and flash the image using USB on Windows or macOS, much like you would for an SD card or USB drive.

  3. With this analysis in mind, we can systematically carry out the necessary steps.

Raspberry Pi models manufactured at different times might not boot up in the same way as described, but that’s okay; just follow our guide to proceed.

There are various ways to burn the Raspberry Pi OS to SSD, each requiring different hardware tools.

Ways

Ways of burning

Requirements

1

Use Raspberry Pi to burn the OS. This requires that you can successfully boot up the Raspberry Pi via SD card or U disk. (Recommended, described in this tutorial)

An SD card or a U disk that can access the Raspberry Pi OS.

2

Purchase an NVMe SSD to USB adapter and flash the image just like you would with an SD card or USB drive.

NVME SSD to USB adapter (need to be bought separately)

3

If there are spare M.2 NVME interface on the motherboard of your PC, you can insert the SSD to it to flash the OS.

PC with M.2 NVME interface

Caution: Incompatible SSDs

The recognition and read/write operations of the NVMe SSD are handled by the drivers of the Raspberry Pi 5. If you find that your SSD cannot be recognized by Pi 5 or is not readable/writable, please try to find a driver suitable for your SSD and install it on the Raspberry Pi, or replace the SSD, or purchase the adapter kit that comes with the SSD.

1 Flashing OS to SD Card or USB Drive

Based on the analysis above, our first step should be to install the Raspberry Pi operating system onto an SD card or USB drive, with a capacity of at least 16GB. If you are already able to boot the Raspberry Pi using an SD card or USB drive, you can skip this section and move on to the next section.

1.1 Component List

Required Components

Raspberry Pi 5 x 1

Install04

One 27W power adapter (or a power adapter compatible with Raspberry Pi official one that can output 5.1V/5A)

Install05

Micro SD Card(TF Card)x1, Card Reader x1

Install06

1.2 Raspberry Pi OS

Without Screen - Use Raspberry Pi - under Windows PC:

With Screen - Use Raspberry Pi - under Windows PC:

Manually Methed

After installing the Imager Tool in the link above. You can also download the system manually first. (Note: Unless necessary, it is not recommended to manually download the offline installation package.)

Visit https://www.raspberrypi.com/software/operating-systems/

../../../_images/Install07.png

Choose Raspberry Pi Device

First, put your Micro SD card into card reader and connect it to USB port of PC.

../../../_images/Install08.png

Open Raspberry Pi Imager.

Select Raspberry Pi 5 under Device, and then click NEXT.

../../../_images/Install09.png

Choose Operating System

Click OS, scroll down to locate and click Raspberry Pi OS (other), and then select Raspberry Pi OS Full(64-bit). Click NEXT.

../../../_images/Install10.png

Choose Storage Devide

Choose the SD card and click on Next.

../../../_images/Install11.png

Customisation

Step 1: Input the hostname, which is “raspberrypi” by default. Then click NEXT.

../../../_images/Install12.png

Step 2: Select your location, timezone and keyboard layout. Then click NEXT.

../../../_images/Install13.png

Step 3: Configure your username and passowrd. The password needs to re-enter to confirm. The default username is pi and the default password is raspberry. Then click NEXT.

../../../_images/Install14.png

Step 4: Input the SSID and password of your wireless network. The passwords needs to re-enter to confirm. Then click NEXT.

../../../_images/Install15.png

Step 5: Enable SSH for ssh remote and click NEXT.

../../../_images/Install16.png

Step 6: Click NEXT.

../../../_images/Install17.png

Writing System to Micro SD Card

After finishing customisation configuration, the interface will show all the configuration you have made. Click WRITE to write the OS to your SD card after confirming everything is correct.

../../../_images/Install18.png

Warning: Before starting the write process, ensure you have backed up all data on the storage device. This operation will permanently erase all data on the device. If you have completed the backup, click I UNDERSTAND, ERASE AND WRITE to continue.

../../../_images/Install19.png

Wait for it to finish writing and verifying.

../../../_images/Install20.png

Done

Congratulations! The Raspberry Pi OS has been successfully written to the SD card. All your custom configurations have taken effect. Click FINISH to complete the process.

../../../_images/Install21.png

1.3 HDMI Monitor desktop

If you do not have a spare monitor, please skip to next section Remote desktop & VNC. If you have a spare monitor, please follow the steps in this section.

Connect the Raspberry Pi 5 to your display via the HDMI interface, attach your mouse and keyboard through the USB ports, and finally, connect your power supply (making sure that it meets the specifications required by your RPi Module Version. Your RPi should start (power up). Later, after setup, you will need to enter your user name and password to login. The default user name: pi; password: raspberry. After login, you should see the following screen.

../../../_images/Install22.png

Congratulations! You have successfully installed the RASPBERRY PI OS on your RPi.

Raspberry Pi 5 integrates a Wi-Fi adaptor. You can use it to connect to your Wi-Fi. Then you can use the wireless remote desktop to control your RPi. This will be helpful for the following work.

../../../_images/Install23.png

1.4 Remote desktop & VNC

If you don’t have a spare display, mouse and keyboard for your RPi, you can use a remote desktop to share a display, keyboard, and mouse with your PC. Below is how to use:

MAC OS remote desktop and Windows OS remote desktop.

Mac OS Remote desktop

Open the terminal and type following command.

If you have set your own hostname during writing the OS, please modify it accordingly.

If this command doesn’t work, please move to next page.

ssh pi@raspberrypi.local

The password is raspberry by default, case sensitive.

../../../_images/Install24.png

You may need to type yes during the process.

../../../_images/Install25.png

You can also use the IP address to log in Pi.

Enter router client to inquiry IP address named “raspberry pi”. For example, I have inquired to my RPi IP address, and it is “192.168.1.131”.

Open the terminal and type following command.

ssh pi@192.168.1.131

When you see pi@raspberrypi:~ $, you have logged in Pi successfully. Then you can skip to next section.

../../../_images/Install26.png

Then you can skip to VNC Viewer.

Windows OS remote desktop

If you are using win10, you can use follow way to login Raspberry Pi without desktop.

Press Win+R. Enter cmd. Then use this command to check IP:

ping -4 raspberrypi.local
../../../_images/Install27.png

Then 192.168.1.147 is my Raspberry Pi IP.

Or enter router client to inquiry IP address named “raspberrypi”. For example, I have inquired to my RPi IP address, and it is “192.168.1.147”.

ssh pi@xxxxxxxxxxx(IP address)

Enter the following command:

ssh pi@192.168.1.147
../../../_images/Install28.png

1.5 VNC Viewer & VNC

Enable VNC

Enter the following commands: select Interface Options -> I3 VNC -> Enter -> Yes -> OK. You may need to restart the Raspberry Pi 5 here, select OK, and then open the VNC interface.

sudo raspi-config
../../../_images/Install29.png

Set Resolution

You can also set other resolutions. If you don’t know what to set, you can set it as 800x600 first.

../../../_images/Install30.png ../../../_images/Install31.png

Then download and install VNC Viewer according to your computer system by click following link:

https://www.realvnc.com/en/connect/download/viewer/

After installation is completed, open VNC Viewer. And click File -> New Connection. Then the interface is shown below.

../../../_images/Install32.png

Enter ip address of your Raspberry Pi and fill in a name. Then click OK.

Then on the VNC Viewer panel, double-click new connection you just created,

../../../_images/Install33.png

Then the following dialog box pops up.

Enter username: pi and Password: raspberry.

If you have set your own username and password, please input them accordingly. Then click OK.

../../../_images/Install34.png

Here, you have logged in to Raspberry Pi successfully by using VNC Viewer.

../../../_images/Install35.png

If there is black window, please set another resolution.

../../../_images/Install36.png

In addition, your VNC Viewer window may zoom your Raspberry Pi desktop. You can change it. On your VNC View control panel, click right key. And select Properties->Options label->Scaling. Then set proper scaling.

../../../_images/Install37.png

Here, you have logged in to Raspberry Pi successfully by using VNC Viewer and operated proper setting.

Raspberry Pi 5 integrates a Wi-Fi adaptor.If you did not connect Pi to WiFi. You can connect it to wirelessly control the robot.

../../../_images/Install38.png

2 Flashing OS to NVMe SSD

This step is to install the Raspberry Pi OS into the NVME SSD.

2.1 SSD Detection

(Note: Not all SSDs are supported by Pi5.)

Booting the Rpi 5 from SD card, and run the following command in the Terminal to check whether SSD is detected.

Note that the information varies among SSDs.

lspci
../../../_images/Install39.png
lsblk
../../../_images/Install40.png

As shown in the figure above, the device ‘nvme0n1’ with a capacity of 476.9GBytes shows up, indicating that the SSD has been correctly recognized. The detected capacity will depend on the size of your SSD. If your drive has been previously partitioned, you may also see some partition information displayed.

Please note: Installing the system will format the SSD, erasing all data. If necessary, please back up any data on your SSD before proceeding.

2.2 Enable PCIe 3.0(on OS written into SD Card)

If your SSD with Phison controller, you may need to enable PCIE 3.0. (This step is strongly recommended; without this step, the later process may fail.)

If it is not with Phison controller, you do not need to enable PCIE 3.0. You may skip this section.

Run the command lspci to check the controller.

../../../_images/Install41.png

(The above screenshot is the result of a 128GB SSD with Phison as main controller.)

Enable PCIe Gen 3.0

Add the line dtparam=pciex1_gen=3 to /boot/firmware/config.txt to enable PCIe Gen3.0.

As shown below, enter the command to open the file.

sudo nano /boot/firmware/config.txt

Add the line dtparam=pciex1_gen=3 to the end of the file, as shown below:

../../../_images/Install42.png

Press Ctrl-O to save the file, Enter to confirm, and Ctrl-X to exit.

Reboot your Raspberry Pi.

sudo reboot

2.3 SSD Partitioning and Formatting

This step is not a must-do, but it can further test whether the SSD perform normally on Raspberry Pi to ensure smooth performance in later steps.

At this point, the hard drive cannot be seen in the file manager as the disk has not been partitioned yet.

../../../_images/Install43.png

Install a disk management tool with the following command:

sudo apt-get install gparted
../../../_images/Install44.png

Open gparted with the command:

sudo gparted
../../../_images/Install45.png

Click on the dropdown menu in the upper right corner and switch to NVME SSD.

../../../_images/Install46.png

Click Device on the menu bar and select Create Partition Table.

../../../_images/Install47.png

You will see the prompt that data will be erased. It is recommended to select gpt for partition table type. Click Apply.

../../../_images/Install48.png

Click Partition on the menu bar, choose New.

../../../_images/Install49.png

As shown in the figure below, the size of partition can be adjusted by dragging the mouse left and right, or by entering the size directly. The other options can be left as default setting. Here, we allocate all the capacity to a single partition. Click on Add.

../../../_images/Install50.png

Click the check icon ✔ to save the partition just built, as illustrated below.

../../../_images/Install51.png

Click on Apply.

../../../_images/Install52.png

Wait for it to complete and click on Close.

../../../_images/Install53.png

At this point, you can mount the disk using the mount command and then access the disk space through the file manager. Use the following command to mount the SSD:

mkdir pi
sudo mount /dev/nvme0n1p1 /media/pi
../../../_images/Install54.png

Open the file manager, as shown below.

../../../_images/Install55.png

If you plan to use the SSD as a standard storage device, you can conclude the process here. However, if you want to further proceed with installing an operating system on the SSD, please read on.

2.4 Flashing the OS

Install the OS to SSD with the method similar to that in the previous section on installing a system onto an SD card. This time, operate on the Raspberry Pi.

Install rpi-imager with the following command:

sudo apt install rpi-imager
../../../_images/Install56.png

Open rpi-imager:

sudo rpi-imager
../../../_images/Install57.png

By this point, you should be quite familiar with the process.

Select the Raspberry Pi 5 as your device and choose the online download for the operating system. (It is recommended to use a 64-bit Raspberry Pi system with recommended software). Choose your NVME SSD as the storage device. Click NEXT.

../../../_images/Install58.png

Enter the hostname.

../../../_images/Install59.png

Select your location, timezone and keyboard layout. Then click NEXT.

../../../_images/Install60.png

Configure your username and passowrd. The password needs to re-enter to confirm.

../../../_images/Install61.png

Step 4: Input the SSID and password of your wireless network. The passwords needs to re-enter to confirm. Then click NEXT.

../../../_images/Install62.png

Enable SSH for ssh remote and click NEXT.

../../../_images/Install63.png

After finishing customisation configuration, the interface will show all the configuration you have made. Click WRITE to write the OS to your SD card after confirming everything is correct.

../../../_images/Install64.png

Warning: Before starting the write process, ensure you have backed up all data on the storage device. This operation will permanently erase all data on the device. If you have completed the backup, click I UNDERSTAND, ERASE AND WRITE to continue.

../../../_images/Install65.png

Wait for it to finish writing and verifying.

../../../_images/Install66.png

Congratulations! You have done the trickiest and the time-consuming part. Now that you have successfully installed the operating system onto the NVMe SSD, you are very close to achieving a triumph.

../../../_images/Install67.png

Next, boot into the system from SSD.

2.5 Enable PCIe 3.0 (on system written into SSD)

Note: This section does not apply to the Dual-NVMe Adapter Board or the Quad-NVMe Adapter Board, as they do not support the PCIe 3.0 protocol. If enabled, it may fail to boot from SSD.

If you have confirmed that SSD is with Phison controller in step 2, then you also need to enable PCIE3.0 on the system written into SSD.

If the controller of your SSD is not from Phison, you can skip this section.

The operation is as below:

Run the command lsblk to check the partitions of the SSD with Raspberry Pi OS written, as shown below:

../../../_images/Install68.png

(The above screenshot is the result of a 128GB SSD with Phison as main controller.)

Run the following commands one by one to mount partition 1 of the SSD to the directory of /media/pi.

sudo mkdir /media/pi
sudo mount /dev/nvme0n1p1 /media/pi
../../../_images/Install69.png

If it mounts successfully, you’ll see the following disk icon on the desktop.

../../../_images/Install70.png

Open and modify the config.txt file with the following command.

sudo nano /media/pi/config.txt
../../../_images/Install71.png

Add the line dtparam=pciex1_gen=3 to the end of the file, as shown below:

../../../_images/Install72.png

Press Ctrl-O to save the file, Enter to confirm, and Ctrl-X to exit.

2.6 Booting from SSD

After finishing flashing the OS to SSD, shutdown Raspberry Pi, remove the power supply, and remove the SD card. Then connect the power, the Raspberry Pi will boot from SSD.

The default boot order of Raspberry Pi is SD card -> SSD -> USB, Therefore, when the SD card is removed, the Raspberry Pi cannot detect the SD card, it will boot from SSD. By far, the Raspberry Pi can boot successfully from NVME SSD.

../../../_images/Install73.png

If you want the Raspberry Pi to boot from the SSD first, please continue with the following steps to modify the boot order. The boot order is saved in the Pi’s EEPROM, so it does not matter whether you modify the boot order on SD card system or SSD system.

If you do not want to change the boot order, please skip this chapter.

Configuring the Boot Order

Type the following command in the Terminal.

sudo raspi-config
../../../_images/Install74.png

Using the keyboard’s arrow keys and the Enter key, select the options in sequence.

“6 Advanced Options” -> “A4 Boot Order” -> “B2 NVME/USB Boot …”

../../../_images/Install75.png

Select “OK” -> “Finish” -> “Yes”, and reboot your Raspberry Pi.

../../../_images/Install76.png

At this point, upon restarting, the Raspberry Pi will boot from the NVME SSD first. If you are using an external monitor, you will see that the Raspberry Pi has booted up correctly. If your SD card is still inserted, you will also see an icon on the desktop as shown below.

With this, the process of booting the Raspberry Pi from the NVME SSD has been fully completed.

../../../_images/Install77.png

If you use VNC viewer, you will need to repeat the previous steps to activate the VNC service as it is not yet enabled in the new system on the SSD. Here, we take Windows as an example.

Run the following command:

ssh pi@raspberrypi.local
../../../_images/Install78.png

Once successfully ssh into Raspberry Pi, run the following command to open the configuration and enable VNC.

sudo raspi-config

Select “3 Interface Options” -> “I2 VNC” -> “Yes” -> “Finish”.

../../../_images/Install79.png

Now you should be able to access Raspberry Pi via VNC.