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.


12 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.

    Reply
    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.

      Reply
      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.

        Reply
  • 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

    Reply
    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.

      Reply
  • 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

    Reply
    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.

      Reply
  • 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!

    Reply
    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.

      Reply
  • 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

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

      Thanks for the information!

      Reply
  • more October 18, 2020 at 5:37 am

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

    Reply
  • Leave a Reply

    Your email address will not be published. Required fields are marked *

    *
    *

BACK TO TOP