0

I'm using pxeboot and kickstart to automate the installation of CentOS 8.

For some reason the resulting systems have a readonly / filesystem after install and its driving me nuts. What might be causing this?

Nothing stands out to me in dmesg, and this behavior is 100% consistent. all hardware targets act the same. it's not just a coincidental bad drive. it's not failing sectors, it's the system configuration not 'wanting' to go rw like its supposed to during boot.

Here's the kickstart since that's the most obviously likely place to have an error.

# Use network installation
url --url="http://mirror.centos.org/centos/8/BaseOS/x86_64/os/"

#Default Lang to English, US, and time to GMT
lang en_US.UTF-8
keyboard --vckeymap=us --xlayouts='us'
timezone Etc/UTC --utc

# Network information
network --hostname=hostnayme
#Static NIC Config will be written in kickstart %post

# Root PW
rootpw --iscrypted $6$O9mlsOUywHhashredactedPRmYFfUmQhUP8/

# Disable firstboot
firstboot --disable

# System services
services --enabled="chronyd"

# Disk Setup
zerombr
clearpart --all
autopart --type=lvm
bootloader --location=mbr

#Reboot when done
reboot

#run anaconda in text mode (faster, no vga req)
text

##Package Selection
%packages --default
@core
@^Minimal Install
#-aic94xx-firmware*
#-alsa-*
#-iwl*firmware
chrony
vim
rsync
%end

%pre
echo "Signaling back to installnode that install is starting..."
curl -s 'http://installserver/installstarting.php?ip=192.168.13.98&netmask=255.255.255.0&foobarbazquux' -o /dev/null
%end

%post
export PriNicFile="$( grep '^ONBOOT="*yes"*$' /etc/sysconfig/network-scripts/ifcfg-* -l | grep -v 'ifcfg-lo$' | sort -n | head -n 1 )"
echo "Found primary nic: ${PriNicFile}"
sed -i 's/BOOTPROTO="*dhcp"*/BOOTPROTO=static/' "${PriNicFile}"
sed -i 's/DHCP_HOSTNAME.*//' "${PriNicFile}"
cat <<'EOF' >> "${PriNicFile}"
IPADDR=192.168.13.98
NETMASK=255.255.255.0
GATEWAY=192.168.13.1
DNS1=8.8.8.8
DNS2=8.8.4.4
EOF

#Update system software
yum -y install screen
yum -y update

#Install SSH Key
mkdir /root/.ssh/
echo 'ssh-rsa AAAAB3sshkeyredactedforstackexchange+s= keyame' > /root/.ssh/authorized_keys
chown -R root:root /root/.ssh
chmod -R go-rwx /root/.ssh


#Purge resolv.conf from installer session so that true resolv.conf is generated on boot
rm /etc/resolv.conf

#Delete ruminants of kickstart env
rm -rf /var/lib/yum/history/????-??-??/?/config-repos

sync

%end

%post --nochroot
curl -s 'http://Installserver/installcomplete.php?ip=192.168.13.98&netmask=255.255.255.0&foobarbazquux' -o /dev/null 
sync
reboot
%end

%addon com_redhat_kdump --disable
%end
1
  • I'm on the trail... Forgot one of the sagest bits of advise: When in doubt, blame selinux. Well I was reading through EVERY BLOODY LINE of dmesg one by one and came across a selinux looking error. just one. And elsewhere I saw something about unable to read /etc/fstab sure enough /etc/fstab's selinux context didn't match everything else in /etc/ . Funny enough just popping a .autorelabel in / is a hilarious fail because with / being mounted readonly, the auto-relabeler can't remove the file so it enters a reboot loop of relabeling over and over! Need to fix contexts in install env. Apr 13, 2021 at 11:54

1 Answer 1

0

Apparently, the CentOS8 installer uses selinux permissive mode. And it doesn't set all the selinux contexts properly all the time

Add a

restorecon -vR /

to the end of your post script. That will correct all the selinux contexts. Then on next good, fstab will be readable, and so all filesystems will mount read-write as expected.

Kind of bizarre that this is needed, but it sure solves the problem.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .