The purpose of this article is to describe how to install CentOS 7.2.1511 or 1603 Minimal on the Raspberry PI 3 B+ for use as a starting point to install light-weight services such as DNS, NTP, DHCP, Apache, etc.
[root@centos-rpi3b ~]# export LANG=C [root@centos-rpi3b ~]# /usr/bin/rootfs-expand /dev/mmcblk0p3 /dev/mmcblk0 3 Extending partition 3 to max size .... CHANGED: partition=3 start=2369536 old: size=2928640 end=5298176 new: size=28746719,end=31116255 Resizing ext4 filesystem ... resize2fs 1.42.9 (28-Dec-2013) Filesystem at /dev/mmcblk0p3 is mounted on /; on-line resizing required old_desc_blocks = 1, new_desc_blocks = 2 The filesystem on /dev/mmcblk0p3 is now 3593339 blocks long.
Done.
手动扩展RootFS
There is a /README file that describes remaining steps to complete the Raspbery PI 3 setup including how to expand the root (/) partition to capacity of the media. I tried it and it resulted in a kernel panic.
Below is the method I used to expand the root filesystem.
Disk /dev/mmcblk0: 63.9 GB, 63864569856 bytes, 124735488 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: 0x000a4da3
Device Boot Start End Blocks Id System /dev/mmcblk0p1 2048 616447 307200 c W95 FAT32 (LBA) /dev/mmcblk0p2 616448 1665023 524288 82 Linux swap / Solaris /dev/mmcblk0p3 1665024 5859327 2097152 83 Linux [root@centos-rpi3 ~]# fdisk /dev/mmcblk0 Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them. Be careful before using the write command.
Command (m forhelp): p
Disk /dev/mmcblk0: 63.9 GB, 63864569856 bytes, 124735488 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: 0x000a4da3
Device Boot Start End Blocks Id System /dev/mmcblk0p1 2048 616447 307200 c W95 FAT32 (LBA) /dev/mmcblk0p2 616448 1665023 524288 82 Linux swap / Solaris /dev/mmcblk0p3 1665024 5859327 2097152 83 Linux
Command (m forhelp): d Partition number (1-3, default 3): 3 Partition 3 is deleted
Command (m forhelp): n Partition type: p primary (2 primary, 0 extended, 2 free) e extended Select (default p): p Partition number (3,4, default 3): First sector (1665024-124735487, default 1665024): Using default value 1665024 Last sector, +sectors or +size{K,M,G} (1665024-124735487, default 124735487): Using default value 124735487 Partition 3 of type Linux and of size 58.7 GiB is set
Command (m forhelp): w The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy. The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8) Syncing disks. [root@centos-rpi3 ~]# reboot
After reboot, resize the file system using resize2fs.
1 2 3 4 5
[root@centos-rpi3 ~]# resize2fs /dev/mmcblk0p3 resize2fs 1.42.9 (28-Dec-2013) Filesystem at /dev/mmcblk0p3 is mounted on /; on-line resizing required old_desc_blocks = 1, new_desc_blocks = 8 The filesystem on /dev/mmcblk0p3 is now 15422208 blocks long.
Services
Immediately after installation, execute systemctl and note the two failing services network and kdump. To fix, I did the following:
network.service
Executing systemctl start network resulted with an error like “Failed to start LSB: Bring up/down networking.” Not terribly helpful. The solution was pretty simple, however. Execute echo "NETWORKING=yes" > /etc/sysconfig/network for the “network” file is absent.
kdump.service
Executing systemctl start kdump then journalctl -xe shows the message “Kdump not supported on this kernel.” Disable the service by executing systemctl disable kdump.
systemd-tmpfiles-setup.service
Periodically, I saw an error with systemd-tmpfiles-setup.service. It would come and go, so I ignored it. Further research is needed.
Disable Wifi/BT
I have no use for the wireless adapter nor bluetooth. Disabling the devices will increase security and reduce electrical / heat.
1
[root@centos-rpi3 ~]# vi /etc/modprobe.d/raspi-blklst.conf
Add
1 2 3 4 5 6 7
#wifi blacklist brcmfmac blacklist brcmutil
#bt blacklist btbcm blacklist hci_uart
Since I have no intention of using wireless, disable the wpa_suplicant service using systemctl disable wpa_supplicant.service.
================================================================================ Package Arch Version Repository Size ================================================================================ Installing: iptables-services armv7hl 1.4.21-16.el7 base 49 k
Total download size: 49 k Installed size: 24 k Is this ok [y/d/N]: y Downloading packages: warning: /var/cache/yum/armhfp/7/base/packages/iptables-services-1.4.21-16.el7.armv7hl.rpm: Header V4 RSA/SHA1 Signature, key ID 62505fe6: NOKEY Public key for iptables-services-1.4.21-16.el7.armv7hl.rpm is not installed iptables-services-1.4.21-16.el7.armv7hl.rpm | 49 kB 00:00 Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 Importing GPG key 0xF4A80EB5: Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>" Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5 Package : centos-userland-release-7-2.1511.el7.centos.0.4.armv7hl (@centos-base_rbf) From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 Is this ok [y/N]: y Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-AltArch-Arm32 Importing GPG key 0x62505FE6: Userid : "CentOS AltArch SIG - Arm32 (https://wiki.centos.org/SpecialInterestGroup/AltArch/Arm32) <security@centos.org>" Fingerprint: 4d9e 39f1 499c a21d d289 77f8 cafe f11b 6250 5fe6 Package : centos-userland-release-7-2.1511.el7.centos.0.4.armv7hl (@centos-base_rbf) From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-AltArch-Arm32 Is this ok [y/N]: y Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : iptables-services-1.4.21-16.el7.armv7hl 1/1 Verifying : iptables-services-1.4.21-16.el7.armv7hl 1/1
Complete! [root@centos-rpi3 ~]# systemctl enable iptables Created symlink from /etc/systemd/system/basic.target.wants/iptables.service to /usr/lib/systemd/system/iptables.service. [root@centos-rpi3 ~]# systemctl enable network network.service is not a native service, redirecting to /sbin/chkconfig. Executing /sbin/chkconfig network on
If you reboot at this point without completing the next step, execute dhclient to obtain an IP address.
Network Interface
I use static IP addresses for infrastructure related services. As such, we need to update ifcfg-eth0.
search myhost.mydomain.net nameserver 64.6.64.6 # Verisign: Reston, Virginia nameserver 64.6.65.6 # Verisign: Reston, Virginia
Host Name
Use hostnamectl to set host name.
1 2 3 4 5 6 7 8 9 10
[root@centos-rpi3 ~]# hostnamectl set-hostname myhost.mydomain.net [root@centos-rpi3 ~]# hostnamectl Static hostname: myhost.mydomain.net Icon name: computer Machine ID: c86851c595a149019a820550c3ccec08 Boot ID: 9d27034c55c84cbda2d7dcf8f7f229e2 Operating System: CentOS Linux 7 (Core) CPE OS Name: cpe:/o:centos:centos:7 Kernel: Linux 4.1.19-v7 Architecture: arm
After reboot verify changes using ping -n 5 www.google.com.
Results
1 2 3 4 5 6 7 8 9
[root@myhost ~]# ping -c3 www.google.com PING www.google.com (172.217.5.100) 56(84) bytes of data. 64 bytes from sfo03s07-in-f4.1e100.net (172.217.5.100): icmp_seq=1 ttl=51 time=26.6 ms 64 bytes from sfo03s07-in-f4.1e100.net (172.217.5.100): icmp_seq=2 ttl=51 time=26.7 ms 64 bytes from sfo03s07-in-f4.1e100.net (172.217.5.100): icmp_seq=3 ttl=51 time=26.5 ms
--- www.google.com ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2003ms rtt min/avg/max/mdev = 26.594/26.682/26.765/0.201 ms
Time & Date
Use timedatectl to set time, timezone, and/or date.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
[root@myhost ~]# timedatectl list-timezones | grep -i angeles America/Los_Angeles [root@myhost ~]# timedatectl set-timezone America/Los_Angeles [root@myhost ~]# timedatectl Local time: Mon 2016-10-24 19:44:45 PDT Universal time: Tue 2016-10-25 02:44:45 UTC RTC time: n/a Time zone: America/Los_Angeles (PDT, -0700) NTP enabled: yes NTP synchronized: yes RTC inlocal TZ: no DST active: yes Last DST change: DST began at Sun 2016-03-13 01:59:59 PST Sun 2016-03-13 03:00:00 PDT Next DST change: DST ends (the clock jumps one hour backwards) at Sun 2016-11-06 01:59:59 PDT Sun 2016-11-06 01:00:00 PST
yum
Check for yum update using yum update yum, then install preferred packages. For example, I install yum related packages and tmux.
yum install yum-utils deltarpm tmux.
Results
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
================================================================================ Package Arch Version Repository Size ================================================================================ Installing: deltarpm armv7hl 3.6-3.el7 base 81 k tmux armv7hl 1.8-4.el7 base 211 k yum-utils noarch 1.1.31-34.el7 base 113 k Installing for dependencies: libevent armv7hl 2.0.21-4.el7 base 189 k python-chardet noarch 2.2.1-1.el7_1 base 227 k python-kitchen noarch 1.1.1-5.el7 base 267 k
Raspberry PI does not have a hardware clock. Mine showed year 1969 on every boot if NTP was unavailable. To correct this behavior, purchase a hardware clock or RTC. I have experimented with both DS1307 and DC3231. Both work well, so buy whatever is cheapest.
My notes on the installation after the hardware installation bit are:
================================================================================ Package Arch Version Repository Size ================================================================================ Installing: i2c-tools armv7hl 3.1.0-13.el7 base 69 k Installing for dependencies: perl armv7hl 4:5.16.3-292.el7 base 7.9 M perl-Carp noarch 1.26-244.el7 base 19 k perl-Encode armv7hl 2.51-7.el7 base 1.1 M perl-Exporter noarch 5.68-3.el7 base 28 k perl-File-Path noarch 2.09-2.el7 base 26 k perl-File-Temp noarch 0.23.01-3.el7 base 56 k perl-Filter armv7hl 1.49-3.el7 base 75 k perl-Getopt-Long noarch 2.40-2.el7 base 55 k perl-HTTP-Tiny noarch 0.033-3.el7 base 38 k perl-PathTools armv7hl 3.40-5.el7 base 82 k perl-Pod-Escapes noarch 1:1.04-292.el7 base 50 k perl-Pod-Perldoc noarch 3.20-4.el7 base 86 k perl-Pod-Simple noarch 1:3.28-4.el7 base 216 k perl-Pod-Usage noarch 1.63-3.el7 base 26 k perl-Scalar-List-Utils armv7hl 1.27-248.el7 base 34 k perl-Socket armv7hl 2.010-4.el7 base 47 k perl-Storable armv7hl 2.45-3.el7 base 72 k perl-Text-ParseWords noarch 3.29-4.el7 base 13 k perl-Time-HiRes armv7hl 4:1.9725-3.el7 base 44 k perl-Time-Local noarch 1.2300-2.el7 base 24 k perl-constant noarch 1.27-2.el7 base 18 k perl-libs armv7hl 4:5.16.3-292.el7 base 596 k perl-macros armv7hl 4:5.16.3-292.el7 base 43 k perl-parent noarch 1:0.225-244.el7 base 12 k perl-podlators noarch 2.5.1-3.el7 base 111 k perl-threads armv7hl 1.87-4.el7 base 48 k perl-threads-shared armv7hl 1.43-6.el7 base 37 k