Running CentOS on the Raspberry Pi

 

CentOS is a Linux distribution that provides a free, community-supported operating system.

It is the free and open-source version of its upstream source, Red Hat Enterprise Linux.

CentOS is one of the most used operating systems for web hosting. One of the reasons for this is that each release has a very long support schedule. For instance, CentOS 7 was released in 2014 but will have continued support until at least 2024.

The long term support means you can continually run the same operating system for an extended period without having to do a full upgrade.

This allows you to maintain longer uptimes without worrying about packages becoming no longer supported as security and bug fixes are commonly backported.

Equipment

Below is the equipment that we used to install CentOS on to the Raspberry Pi.

Recommended

 Raspberry Pi

 Micro SD Card

 Ethernet Cable or WiFi dongle (Pi 3 and newer has WiFi inbuilt)

 Power Adapter

Optional

 Raspberry Pi Case

 USB Keyboard

 USB Mouse

 

We tested this tutorial on a Raspberry Pi 4 and a Raspberry Pi 3B+.

For the Raspberry Pi 4, we were running the minimal version of CentOS. For the Raspberry Pi 3B+, we were running CentOS with the GNOME desktop interface.

 

 

 

Downloading CentOS for the Raspberry Pi

In this section, we will show you where you can download the official releases for CentOS on the Raspberry Pi.

1. To download CentOS for our Raspberry Pi, we will need to go to the official CentoOS website.

On this page you will find a list of CentOS mirrors, you can use any of these. However, the one at the top is typically the best mirror for your region.

2. Once you are on a CentOS mirror website, you will have a couple of choices to make.

The first choice you need to make is depending on what Raspberry Pi you are using. The Pi 4 only has access to the minimal version of CentOS.

Raspberry Pi 4

Sadly for the Raspberry Pi 4, you will have a limited choice on what version of CentOS that you can use.

On the mirror page, you need to find the minimal version of CentOS that contains the number 4 in its filename.

For example, the filename CentOS-Userland-7-armv7hl-RaspberryPI-Minimal-4-2003-sda.raw.xz contains the phrase “Minimal-4” within it.

This text indicates that it has support for the Raspberry Pi 4’s hardware. Other builds will not function on the Pi 4.

Raspberry Pi 3

If you are running a Raspberry Pi 3, then you have a few more choices in what version of CentOS that you can download.

You can download Centos 7 for the Raspberry Pi that contains the GNOME desktop interface.

This iso file will be named something like “CentOS-Userland-7-armv7hl-RaspberryPI-GNOME-2003-sda.raw.xz“.

Alternatively, you can download the minimal version of Centos 7 for the Raspberry Pi.

The minimal version of the OS does not feature a desktop interface, so it is best for those familiar with navigating an OS using the terminal.

This file will be noted by the text minimal in it, for example, CentOS-Userland-7-armv7hl-RaspberryPI-Minimal-2003-sda.raw.xz.

3. Once you have a copy of CentOS 7 downloaded to your device, we can now write it to an SD Card.

 

 

 

Writing CentOS to an SD Card

In this section of the guide, we will show you how to write the CentOS image to your Raspberry Pi’s SD card.

To write the image to the SD card, we will be making use of the BalenaEtcher software.

1. With Etcher opened on your device, click the “Select image” button.

Clicking this button will bring up a file dialog box that will allow you to select the CentOS image that you want to write.

2. Next, we get to select the drive that we want to write the image to.

Click the “Select target” button to select the SD card to write the image to.

If you only have one compatible drive plugged in, the Etcher software will automatically select it.

3. To begin the process of flashing the image, click the “Flash!” button.

4. Once the image has been written to your SD card, you can plug it into your Raspberry Pi.

 

 

 

First boot of CentOS GNOME on the Raspberry Pi

In this section, we will walk you through your first boot of CentOS running the GNOME desktop interface.

If you are using CentOS minimal on your Raspberry Pi, be sure to skip to the next section.

1. When you start up your Raspberry Pi, you will be greeted with the CentOS setup welcome screen.

You can select the language that you want to use for CentOS (1.).

Once you have a language selected, click the “Next” button in the top-right corner.

2. Next, you will be asked to select the keyboard layout (1.).

Make sure you select the correct layout; otherwise, you may run into issues with typing.

Once selected, click the “Next” button to proceed with the setup process.

3. If you are not using an ethernet connection and need to connect to Wi-Fi, now is your chance.

Using the box here, you can select and connect to your Wi-Fi network (1.).

Alternatively, you can skip this step by clicking the “Skip” button.

4. On this next screen, you can control some of the privacy settings of CentOS.

Currently, the only option you can switch on or off is the location services (1.). To disable the location services, you need to click the toggle.

Once you have made your selections, click the “Next” button to proceed (2.).

5. We can now select the timezone for your device.

CentOS will attempt to select this using your network connection automatically. However, if it has chosen the wrong timezone, you can use the textbox to search for your city (1.).

With the time zone selected correctly, click the “Next” button to continue(2.).

6. You can now connect any online accounts you might have to your CentOS installation (1.).

Connecting accounts allow CentOS to synchronize things like your email, calenders, or contacts to your device.

If you don’t want to connect any accounts, click the “Skip” button (2.).

7. Finally, we can move on to setting up an account for CentOS on your Raspberry Pi.

Within this page, you can enter both a name and a username for your account (1.).

CentOS will automatically try to work out a username based on your full name. However, you can set your own.

Once you have a username and full name set, click the “Next” button (2.).

8. Our final task is to set a password for your new account.

Enter, then re-enter a strong password for this account (1.).

Once you have set a secure password, click the “Next” button (2.).

9. You have now finished setting up CentOS on your Raspberry Pi.

All you need to do to get to the desktop is click the “Start Using CentOS Linux” button.

10. You should now see the CentOS GNOME desktop interface.

 

 

 

 

First Boot of CentOS Minimal on the Raspberry Pi

This section will walk you through the short process of booting up CentOS minimal on a Raspberry Pi.

1. When you first boot up your Raspberry Pi running CentOS, you will be asked to log in.

The default user on your new CentOS installation is root.

The default password for the root user is centos. We highly recommend that you change this password once you have logged in.

2. To change the password for the root user, you can use the following command.

passwd

Make sure you set the password to something secure as the root user has full access to all parts of the operating system.

3. You should now have the minimal version of CentOS up and running on your Raspberry Pi.

In our next section, we will quickly walk you through installing packages using CentOS’s package manager.

 

 

 

 

Using the Package Manager on CentOS

Unlike Raspberry Pi OS, which uses the apt package manager, CentOS makes use of yum.

yum is a package management tool that is very similar to apt.

Just like with apt, you can use this to install, update, and uninstall packages.

Installing Packages from the Repository with yum

Installing a package using yum is a very simple process.

All we need to do is reference yum followed by install, then the package name.

yum install PACKAGENAME

For example, if we wanted to use yum to install git, you would run the following command.

yum install git

Using yum to Uninstall Packages

Like installing a package, uninstalling one is also incredibly simple.

To uninstall a package, you need to reference yum, followed by remove than the package name.

yum remove PACKAGENAME

For example, if we decided we wanted to remove the git package, we can use the command below.

yum remove git

Updating Packages using yum

Updating all of the currently installed packages is a straightforward process.

All you need to do to update everything is run the following command with yum, followed by update.

yum update

If you wanted to update a specific package instead of all of them, you could append the package name to the end.

For example, if we wanted to update git, we can type in the command below.

yum update git

Hopefully, by this stage, you will now have a good understanding of how to install and use CentOS on the Raspberry Pi.

 


 

How to Install CentOS 7 on a Virtualbox using Pre-installed Image

As part of my upcoming HowTo tutorials on my blog, I will need to install CentOS 7 on a virtualbox to accomplish this tasks. So for this reason, I will be showing you the fastest way to have a CentOS 7 machine up and running without incurring any cost. Thanks to the awesome work done by the team at OSBoxes, they have done more than 80% of the work for us by providing a ready-to-go VDI Image file for the major Linux Distros and all are up to the latest stable builds.

For those who may not know this, VirtualBox is a free, open source virtualization software that allows users to run multiple operating systems on their machine from within a single machine. In other words, you can spin up multiple virtual machines of any desired OS within minutes of each other as long as the underlining machine machine spec can handle the load.

Install CentOS 7 on VritualBox

  • First install a VirtualBox on your machine (Windows or Linux)

Install latest VirtualBox VM on Linux

  • Download the latest Virtualbox VDI Image file from OSBoxes. Unzip the file using 7zip to a dedicated folder

Please ONLY use these image files for testing purposes and not on a LIVE environment

  • Start your Virtualbox > Click on New and Enter details as follows
    • Name: Enter name for your machine
    • Type: Select Linux
    • Version: Select Red Hat (64bit) or Red Hat (32bit) depending on the Image file version downloaded earlier

CentOS 7

  • On Next, enter desired memory size (recommend 1024mb)
  • On Next, select “Use an existing virtual hard disk file”. Click the small folder icon and navigate to the image file directory where you unzipped it to. Click Create

CentOS 7

  • Start the virtual machine > Ensure the first option as seen below is select

CentOS 7

  • Next login with the password provided when you downloaded the image file. Its usually “osboxes.org”

CentOS 7

  • Click on your desired Language / Keyboard Layout

CentOS 7

CentOS 7

  • You can skip the sign-in bit and start using your OS

CentOS 7

Install Guest Additions On CentOS 7

  • You need to install the Guest Additions to allow you move your mouse freely between your VM and your physical desktop machine and also resize the VM desktop resolution.

Note: To move your mouse put of the VM desktop, simply press the following keys on your keyboard once at the same time “AltGr” + “Ctrl” (both keys on your right hand side)

  • Let’s start. Open your terminal and change to root user
su -
  • Update to latest kernel
yum update kernel*
reboot
  • Install following packages
rpm -Uvh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-9.noarch.rpm
yum install gcc kernel-devel kernel-headers dkms make bzip2 perl

CentOS 7

  • Mount the Guest Additions CD by clicking on Devices > Insert Guest Additions CD image. Cancel the promt displayed

CentOS 7

CentOS 7

  • Run the following commands
mkdir /media/VirtualBoxGuestAdditions
mount -r /dev/cdrom /media/VirtualBoxGuestAdditions
cd /media/VirtualBoxGuestAdditions
./VBoxLinuxAdditions.run

CentOS 7

  • Reboot the machine and you should now be able to move your mouse between the screens. As seen also, the scrollbar at the edge of the screen now gone

CentOS 7


Change Root Password on CentOS 7

  • First change to root user
su -
  • Run the following command and enter new password
passwd

CentOS 7