Installing Ubuntu Server on M.2 Drives for Pi5 SBCs.


TL;DR.
This post is a guide to upgrading Pi5 SBCs (Raspberry Pi 5 Single Board Computers) from using micro-SD cards to employing M.2 drives.
Attributions:
None ↗.
An Introduction.
Upgrading from using a micro-SD card on a Pi5 SBC to using an M.2 drive on the same device can really open up the storage capability of the Raspberry Pi platform:
The purpose of this post is to demonstrate how to install an OS onto an M.2 drive for a Pi5 SBC.
The Big Picture.
There is a redundancy requirement when assembling an HA (High Availability) cluster. Many different flavours of Kubernetes (K8s, K3s, MicroK8s, K0s, and even Minikube) support HA clustering and I will use my Homelab hardware, such as it is, to practice the skills of deploying HA solutions. Using Pi5 SBCs as HA Master Nodes (sometimes called Control Planes) is fine due to the low resource requirements. Worker Nodes (sometimes called Data Planes), on the other hand, consumes many resources (CPU cycles, RAM, bandwidth, etc.) due to processing resource requests. Not only do Worker Nodes need to send a LOT of data, but they must also spin up more nodes when the demand increases. More nodes means more resources consumed.
For M.2 drives, there is a speed difference between the (older) SATA interface and the (newer) NVMe interface. The drives I use in this post are NVMe PCIe Gen3 x4 ↗. The enclosure I use also supports NVMe Drives. The hats that are installed in the Pi5 SBCs are also NVMe compatible. I also have a SATA M.2 enclosure but I am having trouble locating an M.2 2242 SATA drive to confirm this process works on older technologies. Comment below if you have tried using SATA M.2 drives. Enquiring minds are very curious.
For now, my focus is on installing a Linux distro on M.2 drives that will be used by Pi5 SBCs.
Prerequisites.
A Debian-based Linux distro (I use Ubuntu),
3 x Pi5 single board computers,
3 x Pi5 active coolers,
3 x Pi5 NVMe hats,
3 x M.2 drives,
An M.2 enclosure,
3 x CAT-5 Ethernet cables, and
Access to an Internet router, or a LAN switch that is connected to the Internet router.
Updating my Base System.
- From the (base) terminal, I update my (base) system:
sudo apt clean && \
sudo apt update && \
sudo apt dist-upgrade -y && \
sudo apt --fix-broken install && \
sudo apt autoclean && \
sudo apt autoremove -y
NOTE: The Ollama LLM manager is already installed on my (base) system.
What is the Raspberry Pi Imager?
Raspberry Pi Imager is a user-friendly application that allows me to easily install Raspberry Pi OS, or any other compatible operating system, onto a microSD card for use with Raspberry Pi devices. It simplifies the process of selecting the OS and writing it to the card, ensuring that the installation is done correctly.
Installing Pi Imager.
- From the terminal, I install the Raspberry Imager:
sudo apt install -y rpi-imager
Creating an Ubuntu Server M.2 Drive.
- I procure an M.2 drive:
- I install the M.2 drive into an M.2 enclosure:
- I connect the enclosure to my PC:
- I start the Raspberry Pi Imager:
- I select Raspberry Pi 5 as my Raspberry Pi Device:
- I select Ubuntu Server 24.04.2 LTS (64-bit) as the Operating System:
- I select the M.2 enclosure (Realtek with the TS512 M.2 drive) as the Storage:
- I click the
Next
button:
- From the
Use OS customisation?
dialog, I click theEdit Settings
button to open theOS Customisation
dialog:
- In the General tab, I use the following settings:
- In the
Services
tab, I use the following settings:
NOTE: Setting the public key encryption for SSH will be described in a later post.
- In the
Options
tab, I use the following settings:
I click the
Save
button to return to the previous dialog.Back in the
Use OS customisation?
dialog, I click the Yes button.In the
Warning
dialog, I click theYes
button:
I use the Raspberry Pi Imager to install Ubuntu Server onto the M.2 drive.
After the image has been written to the M.2 drive, the enclosure will automatically eject from my PC:
NOTE: The enclosure automatically ejects due to this setting that was enabled earlier:
I unplug the enclosure from my PC.
I remove the M.2 drive from the enclosure.
I install the M.2 drive into my Pi5 SBC.
I repeat this process 2 more times (along with making appropriate changes to the settings):
What is a Raspberry Pi?
A Raspberry Pi is an SBC (single-board computer) that is a little larger than a credit card, specifically 85mm x 56mm in size. It looks like a miniature motherboard but all the components, like the CPU, memory, wireless module, USB ports, and the network port are already (and permanently) installed. Hardware upgrades are enabled through the use of ‘hats’. A hat is a circuit board that is installed on top of, or below, the Raspberry Pi. Hats have pins that electrically connect to the header of the Pi, and may also include a ribbon cable that also provides a connection to the SBC.
Assembling a Pi5 that Supports an M.2 Drive.
If installed, I remove the passive heat sink from the Pi5 CPU.
I install the active cooler and attach the fan cable to the fan header of the Pi5.
I remove a specific screw from the active cooler fan.
I connect the NVMe hat to the Pi5 header and use the included long screw to attach it to the active cooler fan.
I use the NVMe ribbon cable to connect the NVMe hat to the Pi5.
I install the M.2 drive, the drive with Ubuntu Server 24.4 LTS installed, into the NVMe hat and use the included short screw to secure the drive.
On the case, I pop out the case fan because it will get in the way of the NVMe hat.
I install the assembled Pi5 into the Pi case.
I repeat this process 2 more times:
My Use Case.
My plan is to use PiLab1 as the primary control plane, PiLab2 as the secondary control plane, and PiLab3 as the backup control plane. PiLab3 will also be the principle data store, will use my NAS as a redundant back up for the data, and will be the host for Pi-hole.
Implementation details will continue in a later post.
The Results.
Transitioning from micro-SD cards to M.2 drives for my Pi5 SBCs significantly enhanced the storage capabilities and performance of my Raspberry Pi setup. By following the steps outlined in this post, I successfully installed Ubuntu Server 24.04 LTS on multiple M.2 drives, paving the way for more robust and efficient use of the Pi5 platform in various applications, including HA (high availability) clustering. This upgrade not only improved data handling and processing speed but also provided a more reliable and scalable solution for my projects. As I continue to explore and implement these technologies, I will adapt and customize my setup to meet my specific needs and objectives.
In Conclusion.
I learned how to enhance the storage capabilities my Raspberry Pi 5 SBCs by replacing micro-SD cards with M.2 drives. This post covered my prerequisites, the installation steps, and suggested a practical application where Pi5 SBCs can be used in an HA cluster. The Pi5 platform is a potentially strong and flexible, though expensive, resource for Homelab enthusiasts.
Until next time: Be safe, be kind, be awesome.
Hash Tags.
#RaspberryPi #Pi5 #SingleBoardComputer #M2Drive #UbuntuServer #ServerInstallation
#Kubernetes #HighAvailability #Homelab #StorageSolutions #OpenSource #DIYTech
#TechTutorial #TechUpgrade #TechEnthusiast
Subscribe to my newsletter
Read articles from Brian King directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Brian King
Brian King
Thank you for reading this post. My name is Brian and I'm a developer from New Zealand. I've been interested in computers since the early 1990s. My first language was QBASIC. (Things have changed since the days of MS-DOS.) I am the managing director of a one-man startup called Digital Core (NZ) Limited. I have accepted the "12 Startups in 12 Months" challenge so that DigitalCore will have income-generating products by April 2024. This blog will follow the "12 Startups" project during its design, development, and deployment, cover the Agile principles and the DevOps philosophy that is used by the "12 Startups" project, and delve into the world of AI, machine learning, deep learning, prompt engineering, and large language models. I hope you enjoyed this post and, if you did, I encourage you to explore some others I've written. And remember: The best technologies bring people together.