Do you have a Raspberry Pi 2 or 3? Are you trying to figure out how to install CentOS on it? You are not alone. Many users who have reached out to me to help them with this and I have gladly obliged.

Advertisement

This article will give you step-by-step instructions so that CentOS installation on Raspberry Pi does not seem daunting to anyone. Let’s go through the steps now:

Gather everything you need

You are going to need your Raspberry Pi and its SD card. You will also need another device that comes with a SD card reader.

Download the media

Get online and download CentOS media or image. Make sure you acquire the latest, updated image. Once you download it, you must also extract it.

curl http://mirror.centos.org/altarch/7/isos/armhfp/CentOS-Userland-7-armv7hl-Minimal-1603-RaspberryPi3.img.xz
unxz centos.img.xz

Transfer the media to the SD card

Take the SD card for Raspberry Pi, connect it to your system, and copy the CentOS image to it. It is very important that you choose the appropriate SD card (the one that works with Raspberry Pi) because, otherwise, you will run into a lot of trouble through the process.

fdisk -l /dev/mmcblk0

Disk /dev/mmcblk0: 14.9 GiB, 15931539456 bytes, 31116288 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000000

Device         Boot Start      End  Sectors  Size Id Type
/dev/mmcblk0p1       8192 31116287 31108096 14.9G  c W95 FAT32 (LBA)

I also recommend that you check twice before going to the next step. The command that will help you check is as follows:

watch lsblk

if you are sure that everything is going smoothly, you can go ahead.

dd if=centos.img of=/dev/mmcblk0 bs=4M

Check by connecting a keyboard

You will now need a keyboard and a device with HDMI input to see if everything is working fine. Connect the SD card to your Raspberry Pi and check the working. You don’t really require a display here so don’t worry about it. If everything is okay, the SSHD will try to reach out for a DCHP address.

Remember, the root password is usually centos and the eth0 setting is DHCP.

uname -a

Linux skidmarks.funcamp.net 4.1.11-v7+ #822 SMP PREEMPT Fri Oct 23 16:22:18 BST 2015 armv7l armv7l armv7l GNU/Linux
cat /etc/redhat-release

Time to resize your disk

Use a root resizing tool to use the SD card’s space properly. CentOS itself comes with this tool so that you don’t bother wasting time looking for one or doing it manually.

touch /.rootfs-repartition
systemctl reboot

Reboot the Raspberry Pi

For the changes to appear you will need to reboot your Raspberry Pi. After this process, you will start using all the space in the SD card without compromise.

Setup the NTP manually now

Since NTP is not setup for you, you must work towards doing it manually.

yum install chrony
systemctl start chronyd

Setup Python-Pip

You will need to do this manually because Python-Pip is not included for CentOS.

curl https://dl.fedoraproject.org/pub/epel/7/x86_64/p/python-pip-7.1.0-1.el7.noarch.rpm > python-pip-7.1.0-1.el7.noarch.rpm
yum localinstall python-pip-7.1.0-1.el7.noarch.rpm -y

Install yum-utils

If you are looking to install additional noarch packages you may need to download yum-utils

yum install yum-utils -y
yumdownloader python-pip

If you have done everything right and are still unable to install CentOS on Raspberry Pi, there may be a few issues to look into. Let’s assess the possible, common problems:

1) Too much memory usage: This can be because of the irqbalance process. Simply restart every day to keep this bug at bay.

cat > /etc/cron.daily/irqbalance <<EOF
#!/bin/sh
/bin/systemctl restart irqbalance.service
EOF

2) Loose or wrong connection: Sometimes the reason is as simple as a bad connection. It is rampant when using Raspberry Pi because it is quite limited in the use of USB cables. Changing the USB could be the solution to your troubles!

3)Lack of packages: It may be difficult to find the packages you are looking for because official EPEL repositories don’t exist. You may end up compiling them yourself.

Have your say

I hope this guide was clear enough and was able to help you understand the entire process without hassle. I would love to hear from you once you have installed the CentOS. Please free to write to me and I will help you out with anything else that you need.

Share.

5 Comments

  1. I think currently only the CentOS-Userland-7-armv7hl-RaspberryPI-Minimal-4-1908-sda.raw.xz image works with Pi4. This is a minimal installation (no graphical desktop). But Gnome environment can be installed later via ‘yum install “GNOME Desktop”‘.

  2. I followed the instructions to copy the distribution from
    https://mirrors.xtom.com/centos-altarch/7.7.1908/isos/armhfp/
    onto the sd card.
    At the end, I can see:
    # fdisk -l /dev/sdc1

    Disk /dev/sdc1: 32.0 GB, 31950110720 bytes, 62402560 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk label type: dos
    Disk identifier: 0x00097f72

    Device Boot Start End Blocks Id System
    /dev/sdc1p1 * 8192 593919 292864 c W95 FAT32 (LBA)
    /dev/sdc1p2 593920 1593343 499712 82 Linux swap / Solaris
    /dev/sdc1p3 1593344 9406463 3906560 83 Linux

    When I load the sd card into my Pi4, nothing seems to happen on the attached screen.
    The raspberry OS that can with the Pi works fine.
    What have I missed?

  3. What if we don’t have a linux/unix install to grab the initial image with? I’m trying to install to an SD card using windows. I can’t find “image.xz” anywhere, which is what all the Windows guides are suggesting.

  4. Hey Niki, this is probably one of the best article explaining how to install centos on raspberry Pi thanks for share!

Leave A Reply

Exit mobile version