Installation of Centos 8 on Raspberry Pi 4 8Gb Model

Buy Raspberry Pi 4

I recommend to buy a Raspberry Pi 4 tool kit instead of just the board. Because you need to buy other accessories anyway and the cost is not likely to be less enough to justify the effort. I bought the 8GB version because I’m going to use it as a server. You can buy the standard 4GB version and that should be enough for normal use. 

Buy Raspberry Pi 4 8Gb Model Here

Buy Raspberry Pi 4 4Gb Model Here

Install Centos 8

  • Download centos 8 for raspberry pi
  • Burn to the micro SD card with etcher. If you don’t have a micro SD card reader, you can buy a good one here.
  • Insert the micro SD card into your Raspberry Pi.
  • Connect your Raspberry Pi to the router with a cable.
  • Start it!
  • Find your IP from your home router.
  • ssh to it with user: root, password: centos
  • Run df -h. If it shows smaller disk size than the actual size of the SD card, expand it to all available. However we don’t have /usr/bin/rootfs-expand in the image. So copy paste the following script and run:

#!/bin/bash
clear
part=$(mount |grep '^/dev.* / ' |awk '{print $1}')
if [ -z "$part" ];then
    echo "Error detecting rootfs"
    exit -1
fi
dev=$(echo $part|sed 's/[0-9]*$//g')
devlen=${#dev}
num=${part:$devlen}
if [[ "$dev" =~ ^/dev/mmcblk[0-9]*p$ ]];then
    dev=${dev:0:-1}
fi
if [ ! -x /usr/bin/growpart ];then
    echo "Please install cloud-utils-growpart (sudo yum install cloud-utils-growpart)"
    exit -2
fi
if [ ! -x /usr/sbin/resize2fs ];then
    echo "Please install e2fsprogs (sudo yum install e2fsprogs)"
    exit -3
fi
echo $part $dev $num

echo "Extending partition $num to max size ...."
growpart $dev $num
echo "Resizing ext4 filesystem ..."
resize2fs $part
echo "Done."
df -h |grep $part

  • Mount some heavy writing directories to ram by adding e.g. the following line to /etc/fstab then do mount -a to reload:

tmpfs   /var/log    tmpfs    defaults,noatime,nosuid,mode=0755,size=100m    0 0

  • Update the system with yum update

Network Configuration

  • If you want static IP instead of DHCP, put the following in /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
PREFIX=24
IPADDR=192.168.1.200
GATEWAY=192.168.1.1
DNS1=192.168.1.1

For wifi, use nmtui which comes with Centos8. It can also be used for ethernet configuration.

  • Allow some traffic in firewalld

$ firewall-cmd --zone=public --permanent --add-port=8080/tcp
$ firewall-cmd --zone=public --permanent --add-service=http
$ firewall-cmd --reload

Install Packages


$ yum install -y java-11-openjdk-devel python3-devel python3-pip tmux tcpdump maven telnet postgresql-server wget nodejs git make bzip2 tar cockpit

Other Configuration

  • Change root password by running passwd root
  • Create a new user and add to sudoer:

$ useradd reallyappreciate
$ passwd reallyappreciate
$ usermod -aG wheel reallyappreciate

  • Un-comment the following line in /etc/sudoers/ for password-less sudo:

%wheel ALL = (ALL) NOPASSWD: ALL

  • Change hostname with hostnamectl set-hostname raspberrypi.local
  • Update ~/.ssh/config

Host *
  StrictHostKeyChecking no
  UserKnownHostsFile /dev/null

Host github.com
  HostName github.com
  User git
  AddKeysToAgent yes
  #UseKeychain yes
  IdentityFile ~/.ssh/github

  • Set timezone with timedatectl set-timezone America/New_York
  • Install monitoring tool cockpit

$ systemctl enable cockpit.socket
$ systemctl start cockpit.socket

You are all set! Visit http://your-raspberry-pi-ip:9090 for system status.


22 thoughts on “Installation of Centos 8 on Raspberry Pi 4 8Gb Model

  • smallphd August 13, 2020 at 3:50 am

    The “CentOS 8” is not a vanilla CentOS 8. It’s kernel is a newer one, not the original 4.18.0-193.el8.

    1. Really Appreciate August 13, 2020 at 10:40 pm

      yeah. You are right. I was using centos 7 and a lot packages are outdated. This one fits my needs me well.

      1. Ola Dunk September 4, 2020 at 10:48 pm

        Nice work. Works like a charm on my RPi 4 with 4G memory. Is it normal to have 10 Rpi’s at home ?
        Thanks for sharing.

  • Andi August 20, 2020 at 12:36 pm

    Do you know if and which EPEL repo is usable?
    I found this one https://copr.fedorainfracloud.org/coprs/aminasyan/epel-8-aarch64/repo/epel-8/aminasyan-epel-8-aarch64-epel-8.repo but I don’t if it works with your CentOS8 installation …
    Thx
    Andi

    1. Really Appreciate August 21, 2020 at 3:17 am

      I did not use any EPEL repo. The repos come with the distribution have the packages I need for now. Please let me know if the repo you listed is good with the distribution.

  • Dennis September 15, 2020 at 6:25 pm

    Hello,

    Thanks for tutorial, but can you please help me on how to install CentOS 8 on SSD and boot from it. .thanks

    1. Really Appreciate September 17, 2020 at 2:46 am

      Steps:
      1. With another computer, download the centos 8 image I posted in the article.
      2. Put your sd card in an usb sd card reader and insert into the computer.
      3. Download the burner tool from https://www.balena.io/etcher/
      4. Launch the tool, burn the centos 8 image into the sd card. The tool is very intuitive so you should be able to easily use it.
      5. Insert the sd card into your raspberry pi and start.

  • Derk September 23, 2020 at 10:18 pm

    Hello and thank you for the tutorial, but I also have a question. You say that when it is showing a smaller disc size you have to copy past and run the following script. How do I do that? I don’t have any way to create a bash file yet, at least that is what I think you mean. And does it matter where I create the file? I am quite new to this so sorry for the ignorance. Thank you in advance!

    1. Really Appreciate September 24, 2020 at 2:17 am

      Steps:
      1. Insert the burned SD card into the RPi and boot it up
      2. Connect RPi with your home router with a network cable
      3. With another computer, ssh to RPi with user: root, password: centos (you should be able to find the IP of RPi from your router management page)
      4. in the ssh window, under any directory, do “cat > script.sh”
      5. Paste the content
      6. Press Ctrl + d to save.
      7. Run “sh ./scripts.sh”
      8. All done.

  • Bartłomiej September 25, 2020 at 7:04 am

    This partition resizing script may not work if a timezone other than English is set.

    I propose to do:
    1. Upload this script (e.g. under the name changepartsize.sh)
    2. Run it like this:
    LANG=C bash changepartsize.sh

    OR the second option, change the line in the script
    growpart $dev $num
    on
    LANG=C growpart $dev $num

    1. Really Appreciate September 26, 2020 at 9:44 pm

      Thanks for the information!

  • more October 18, 2020 at 5:37 am

    Kudos for detailing this subject. Do you have plans to continue?

  • Graham Foster October 31, 2020 at 12:07 am

    Great job, thanks for doing this. No matter what I tried I could not get the expand script to run. What did work for me was after flashing the image, I opened Paragon partition manager, (free), clicked on the ext4 partition and clicked on expand and job’s a good ‘un!
    All installed and now sitting in the desktop setting up tigerVNC. Raspberry Pi 4 8GB.

  • Bryan Haering November 18, 2020 at 5:39 pm

    Thank you for the auspicious writeup. It in fact was a amusement account it. Look advanced to far added agreeable from you! By the way, how can we communicate?

  • soft_xiang November 20, 2020 at 3:54 pm

    wifi can not used?

  • Make your Raspberry Pi 4 a Media Server with Plex | Really Appreciate November 21, 2020 at 4:12 am

    […] we give a easy-to-follow, step-by-step instruction on how to install Centos 8 on Raspberry Pi 4. Installation of Centos 8 on Raspberry Pi 4 8Gb Model A common usage of Raspberry Pi is to make it a media server. There are plenty of articles on how to […]

  • Thomas December 14, 2020 at 12:21 pm

    Hey, just a brief note to let you know this post is very helpful, great and that it saved my day.
    It works like a charm for me on a Pi4b 4GB and gives me what I may describe as the best flavor of a linux server OS currently available for Rpi4. ( I tried Ubuntu LTS server but was VERY disappointed I must say. But being a fedora user, I’m maybe biased when it comes to DEB-based distros anyway)

    Well, this one here works extremely nice, stable and snappy.
    Thanks for putting this online!
    Cheers, Thomas

    1. Really Appreciate December 17, 2020 at 2:47 am

      Thank you! I like rhel based distribution too.

  • PinkFish January 23, 2021 at 6:19 pm

    can you make a tutorial of install rhel8 on raspberry pi 4b

    1. Really Appreciate January 24, 2021 at 10:55 pm

      RHEL 8 is very similar to centos. So the installation process should be almost the same. Probably you can search for an arm based rhel 8 and give it a try.

  • Lawrence February 6, 2021 at 9:27 pm

    Nice one.
    This got me up quickly with Raspberry PI 4 and Centos. Which was great as I was able to get a new IPA server running without much shenanigans

  • Installation of Centos 8 on Raspberry Pi 4 8Gb Model – Really Appreciate – Technology July 25, 2021 at 9:23 am

    […] Source: Installation of Centos 8 on Raspberry Pi 4 8Gb Model – Really Appreciate […]

  • Comments are closed.

BACK TO TOP