A couple days ago, my early birthday gift arrived in the mail...The Raspberry Pi 4 (Model B 4GB RAM). I got the RPI because I am learning Linux and wanted to experiment with and experience an actual Linux machine versus playing with virtual machines running in VirtualBox.
After completing the LPI Linux Essensials Certifications course by the amazing Michael Christian Jr. on Linux Academy , I wanted to apply what I learned on a RedHat based distro and so I decided to install CentOs on my new Raspberry Pi.
It only took 5 minutes to realize that CentOS has not yet released an official image to support the new RPI 4, which was really disappointing. However, it took me another 30 minutes to find some workarounds to help solve this problem.
In this article I gathered my findings to share them with you in a step-by-step process so that you can get CentOS up and running on your Raspberry Pi 4 without having to wait for the official release.
Things you'll need:
- Raspberry Pi 4 + Micro HDMI to HDMI cable.
- 4GB or more Micro SD card + Micro SD card Reader.
- Another machine (Windows, mac or Linux).
- USB Keyboard ( a USB wireless keyboard works too).
Formatting the SD card
To be able to install CentOs on the SD Card, first we need to make sure that the memory card is properly formatted.
If you are using Windows, you need to use one of the following applications based on the size of your memory card:
- If your memory card is 32GB or smaller, use SD Memory Card Formatter .
- If you memory card is 64GB or larger, use FAT32format .
Note: The 64GB Micro SD card I was using had been previously partitioned. I was not able to format it using the FAT32format tool right away as it wasn't able to merge all partitions together and format from scratch. To overcome this issue, I first used the SD Memory Card Formatter tool first to wipe all partitions, then I used to FAT32format.
For Linux or MacOS just use your default formatting tools found on your machine.
Download CentOS Minimal for Raspberry pi 4
As I have mentioned above, the official CentOS for the Raspberry Pi 4 has not been released yet. But the community was able to come up with something that will get you up and running for now. I honestly don't know what the limitations of this unofficial image are, other than the fact that wifi does not work outside of the box, but that is ok with me as I am using an Ethernet cable to connect. To download the CentOS 7 Minimal image, grab it form here .
This is the link to the thread on the CentOS forums if you want to check it out. I also found some comments on it regarding the Wifi and how to enable it.
After downloading the file you will notice that it's a .xz compressed file. You can extract the file using any extracting tool. You will end you with a .raw file, which you will flash onto the Micro SD card in the next step.
Flash CentOS to the SD card
The most straight forward method to flash your Micro SD card is to use an awesome tool called Etcher . Etcher is available for Windows, Linux and MacOS.
Run Etcher and select the the .raw file you just extracted, then attach your Micro SD card to your machine and Etcher will detect it automatically. Just make sure the correct drive is selected. Finally, click "Flash".You might get a message that asks if you are fine with Etcher making changes to your SD card, select yes for this.
After a few minutes, your SD card is ready, and you can move forward.
Initial boot
Now that you have flashed CentOS on your SD card, it is time it running on your Raspberry pi 4 :
- Insert the Micro SD card into your Raspberry pi.
- Connect a keyboard to the USB port.
- Connect a monitor to the Raspberry pi using the Micro HDMI to HDMI cable. Make sure you are using the HDMI port 0 on your Raspberry Pi.
- Run the Raspberry Pi and it will start to boot.
In a couple of minutes CentOS will be running on your Raspberry Pi 4. The screen will prompt you for a username and password. The defaults are:
Username: root
Password: centos
Once you are logged in, you would want to change your password. You can do that by running the passwd
command.
Expand the Root partition
By default when flashing CentOS on the SD card it will only create a root directory of a size around 1.4GB and you won't be able to use the rest of the space on your Micro SD card. This is a common issue with Linux distros on Raspberry pi.
To see your disk space usage, run df -h
As you can see, In my case, in my root partition I only had 461MB left from my 64GB Micro SD. To be able to resize and manipulate partitions in our system we would usually do it manually using tools such as GParted and fdisk. But fortunately you won't have to deal with that now, as the awesome people who developed this image provided us with a simple bash script that does all the work in the back ground.
If you run ls
in your home directory, you will find a README file. Run cat README
to read its content.
By running rootfs-expand
you have reclaimed the rest of the space on your Micro SD. To double check, run df -h
again:
"SSH"ing
By default, SSH is enabled on the Minimal CentOS. So you don't have to worry about enabling it. All you need is an Ethernet cable connected to your router or switch, and your Raspberry Pi's IP address on the network. To get the latter run ifconfig
.
More configuration
There are many other things you might want to configure after your first boot. If you want go deeper into setting up your fresh CentOS, check out these two links:
Using CentOS 7.2.1511 Minimal on the Raspberry PI 3
Installing CenOS on the Raspberry pi
Conclusion
Thank you for reading, I hope this step by step guide was helpful in helping you install CentOS on your "not yet supported" Raspberry Pi 4.