Install CentOS 7 on your favourite ARMv8 ARM64 AArch64 board
With the beginning of 2016 the first affordable ARM64 single board computers became available to the public. While playing with Ubuntu, Debian and Archlinux I was courious to know how much effort would it take to get CentOS 7 up and running on my ODROID-C2 and my Pine64. At the end if have automated this tasks, so you will be able to get your Docker enabled CentOS 7 within a couple of minutes.
The Alternative Architecture Centos SIG already prepared a CentOS 7 disk image for ARM64 server boards:
curl -sSL http://mirror.centos.org/altarch/7/isos/aarch64/CentOS-aarch64.img.xz | unxz > CentOS-aarch64.img
This image comes with all the bells and whistles (EFI boot loader, GPT partition table) which are usually not applicable to single board computers based on mobile or tablet SoCs.
parted
provides a look inside the CentOS disk image.
$ /sbin/parted -s CentOS-aarch64.img unit b print
Model: (file)
Disk /home/debian/CentOS-aarch64.img: 12884901888B
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1048576B 105906175B 104857600B fat16 EFI System Partition boot, esp
2 105906176B 525336575B 419430400B xfs Linux filesystem
3 525336576B 2622488575B 2097152000B Linux swap
4 2622488576B 12479102975B 9856614400B xfs Linux filesystem
If you want to extract the file system contents, your kernel needs to have support included for the XFS file system. You might need to compile your own XFS enabled Linux kernel.
The kpartx
utility helps you to set up appropriate loopback devices needed to access the partitions inside:
sudo kpartx -g -a -v CentOS-aarch64.img
Now you are able to mount the AArch64 root file system ...
sudo mount -t xfs /dev/mapper/loop0p4 /mnt
... and to copy the contents to your destination device:
cd /mnt
sudo find . | sudo cpio -dump /media/<target>
You may want to wipe out the root user password in /etc/shadow
in order to set a new root password afterwards. You need to modify the contents of /media/<target>/etc/fstab
as well in order to reflect the UUID change (sudo blkid
will tell you the right UUID).
Most ARM single board computers are shipped with a vendor specific bootloader (mostly u-boot) and Linux kernel image. You may take an existing Debian/Ubuntu/Archlinux disk image and replace the root file system contents (but leaving the kernel image (/boot
), the kernel modules (/lib/modules
) and the firmware files (/lib/firmware
) untouched).
After having rebooted into your CentOS 7 environment, you may perform some configuration changes, like:
sudo timedatectl set-timezone Europe/Berlin
sudo localectl set-locale LANG=en_GB.UTF-8
sudo hostnamectl set-hostname c2 --static
sudo hostnamectl set-hostname "ODROID-C2" --pretty
Automated setup procedure: z2d
I've prepared a github repository containing a collection of scripts helping you to set up Ubuntu Core 16.04 / Debian 8 Jessie and CentOS 7 (and Docker) for various ARM devices.
After cloning the repository you will find the scripts in the respective subdirectory, e.g. for the ODROID-C2, the set up is done on the ODROID-C2 via
$ git pull https://github.com/umiddelb/z2d
$ cd z2d/odroid-c2
$ vi centos-00.sh # adjust the target device
$ sh centos-00.sh
$ sh centos-01.sh
$ sudo init 6 # reboot into CentOS 7
# login with user centos
$ sudo bash
# cd /
# sh centos-03.sh
Note: For convenience reasons, this setup uses a precompiled kernel image and extracts the root file system from an archive created as described in step 3.