getting started with centos7 on raspberry pi 3 b+

My notes on getting these bootstrapped.

Get image onto SD card

  • Example is for centos 7.6, released 2018-10 (1810)
  • centos docs
img=CentOS-Userland-7-armv7hl-RaspberryPI-Minimal-1810-sda.raw
unxz ${img}.xz
sudo dd if=./${img} of=/dev/mmcblk1 status=progress bs=8192 ; sudo sync

At time of writing, this was a Centos 7.6 image, and by default had a 1.4gb ext4 root partition with 421mb free, a vfat boot partition.  It also has a 500mb swap partition.

Reset root password

defaults to ‘centos’

passwd root

ssh key

ssh-copy-id root@<ip>

Set hostname

hostnamectl set-hostname foo.domain

Disable wifi

echo 'blacklist brcmfmac' > /etc/modprobe.d/brcmfmac.conf

/tmp tmpfs

systemctl enable tmp.mount

patch

yum update

Grow root partition

The procedure on the internet is to amend the partition table with fdisk, and then grow the filesystem. I subsequently tracked down the command to do this on the faq page

/usr/bin/rootfs-expand

That’s the easiest way to grow root to the entire disk.

I generally don’t ..

fdisk seems to be displaying in blocks of 1kb;  we have a 1.4gb partition.  sfdisk is using 512byte sectors.

# fdisk -l /dev/mmcblk0

Disk /dev/mmcblk0: 15.5 GB, 15489564672 bytes, 30253056 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: 0x000cc7a5

Device Boot Start End Blocks Id System
/dev/mmcblk0p1 * 2048 1370111 684032 c W95 FAT32 (LBA)
/dev/mmcblk0p2 1370112 2369535 499712 82 Linux swap / Solaris
/dev/mmcblk0p3 2369536 5298175 1464320 83 Linux

# sfdisk -d /dev/mmcblk0 | tee -a /root/mmcblk0_sfdisk_orig
# partition table of /dev/mmcblk0
unit: sectors

/dev/mmcblk0p1 : start= 2048, size= 1368064, Id= c, bootable
/dev/mmcblk0p2 : start= 1370112, size= 999424, Id=82
/dev/mmcblk0p3 : start= 2369536, size= 2928640, Id=83
/dev/mmcblk0p4 : start= 0, size= 0, Id= 0

Let us go with six gb or so.

# expr 6000 \* 1024 \* 2
12288000
# cat /root/mmcblk0_sfdisk_orig | \
      sed 's~ 2928640~12288000~g' > /root/mmcblk0_sfdisk_new
# sfdisk -f /dev/mmcblk0 < /root/mmcblk0_sfdisk_new
# reboot

And assuming it comes back 🙂

# mount | grep 'on / '
/dev/mmcblk0p3 on / type ext4 (rw,noatime,seclabel,data=ordered)

resize2fs /dev/mmcblk0p3

packages

I add these via my puppet baseline.

yum install wget which file lsof unzip

logical volume manager, /home

  • also installs device-mapper
yum install lvm2
  • prepare to add a fourth partition for LVM
# sfdisk -T | grep -i lvm
8e  Linux LVM
# fdisk -l /dev/mmcblk0

Disk /dev/mmcblk0: 15.5 GB, 15489564672 bytes, 30253056 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: 0x000cc7a5

        Device Boot      Start         End      Blocks   Id  System
/dev/mmcblk0p1   *        2048     1370111      684032    c  W95 FAT32 (LBA)
/dev/mmcblk0p2         1370112     2369535      499712   82  Linux swap / Solaris
/dev/mmcblk0p3         2369536    14657535     6144000   83  Linux
# egrep -v '^/dev/mmcblk0p4' /root/mmcblk0_sfdisk_new > /root/mmcblk0_sfdisk_lvm
# p3end=14657535   # from partition 3 end sector 
# sectors=30253056  # from total sectors of device
# pstart=$(expr ${p3end} + 1) 
# psize=$(expr ${sectors} - ${pstart} ) 

# echo "/dev/mmcblk0p4 : start= ${pstart}, size= ${psize}, Id=8e" >> /root/mmcblk0_sfdisk_lvm

check file; apply change

cat /root/mmcblk0_sfdisk_lvm
sfdisk -f /dev/mmcblk0 < /root/mmcblk0_sfdisk_lvm
reboot

Set up volume group, home filesystem.

vgcreate rootvg /dev/mmcblk0p4
lvcreate --name lv00hom00 --size 1G rootvg
mkfs.xfs /dev/rootvg/lv00hom00
echo "/dev/rootvg/lv00hom00   /home  xfs defaults,noatime 0 0" >> /etc/fstab
mount /home

 

Puppet

Here!

 

Revisions

2019-04-10 added default root password, and changed /home from ext4 to xfs

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s