Setting up RHEL8 XEN guests from the cloud image

Requriements

RHEL8 does not ship a XEN-capable network installer anymore. This is why it is now best to simply grab the latest cloud image.

cd /data_local/
wget https://cloud.centos.org/centos/8-stream/x86_64/images/CentOS-Stream-GenericCloud-8-latest.x86_64.qcow2

du -sh CentOS-Stream-GenericCloud-8-latest.x86_64.qcow2
# 1.9G

ln -s CentOS-Stream-GenericCloud-8-latest.x86_64.qcow2 centos8.qcow2

Skeleton

guest=centos8


mkdir -p ~/guests/$guest/
cd ~/guests/$guest/

what is the max amount of cores you can share with the guest?

grep ^proc /proc/cpuinfo | tail -1

booting the cloud image with rescue mode so you can reset root password

vi $guest
kernel = "/data/kernels/5.2.21.domureiser4.vmlinuz"
root = "/dev/xvda1 ro console=hvc0 net.ifnames=0 biosdevname=0 mitigations=off"
extra = "init=/bin/bash"

name = "centos8"
vcpus = 3
maxvcpus = 31
memory = 1024
#memory = 7168
disk = ['qcow2:/data_local/centos8.qcow2,xvda,w']
vif = [ 'bridge=guestbr0, vifname=centos8.0' ]
type = "pvh"

note we are not trying to enable pvgrub here, as PVH does not support it

Single-user mode fixup

get into the rescue mode shell

xl create centos8 -c

export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
mount -o remount,rw /

mount -t proc none /proc
cat /proc/partitions

you should then proceed similarly to the system preparation but there’s a few differences. first, there are more services to disable.

for sv in \
    cloud-config \
    cloud-final \
    cloud-init-local \
    cloud-init \
    cloud-config.target \
    NetworkManager \
    kdump \
    ; do
    # self-verbose
    echo disabling $sv
    systemctl disable $sv || echo FAILED
    echo
done; unset sv

you would also need to grab modules for your custom kernel, if any (e.g. TMEM here)

dhclient -v eth0
ping -c1 opendns.com
yum update -y
yum install network-scripts wget mlocate -y

systemctl list-unit-files | grep network
systemctl enable network

wget https://lab.nethence.com/nunux/5.2.21.domureiser4.modules.tar.gz
tar xzf 5.2.21.domureiser4.modules.tar.gz -C /lib/modules/
rm -f 5.2.21.domureiser4.modules.tar.gz
echo tmem > /etc/modules-load.d/tmem.conf

that cloud image also has additional shit to get rid of

ls -l /etc/motd.d/cockpit
ls -l /etc/issue.d/cockpit.issue
ls -l /etc/sysconfig/network-scripts/ifcfg-*

rm -f /etc/motd.d/cockpit
rm -f /etc/issue.d/cockpit.issue
rm -f /etc/sysconfig/network-scripts/ifcfg-ens3

eventually initialize the root password

#passwd root

–or– push your ssh pubkey there

mkdir /root/.ssh/
cat > /root/.ssh/authorized_keys <<EOF
...
EOF
chmod 700 /root/
chmod 700 /root/.ssh/
chmod 600 /root/.ssh/authorized_keys

when finished, shutdown the guest

sync
halt -p

#xl des centos8
reset

and disable the extra init

vi centos8

#extra = "init=/bin/bash"
extra = "ip=10.1.0.9::10.1.0.254:255.255.255.0:centos8:eth0:none"

you’re now good to go for acceptance testing

xl create centos8 -c

Template

warning: since we don’t mount and edit the QCOW2 disk from the host, we also need to be careful about the SSH host keys. Those should be removed before generating the template.

eventually make a template out of it

tar cSf /data/templates/centos.qcow2.tar centos.qcow2

Resources

https://www.centos.org/download/mirrors/

https://wiki.centos.org/action/show/Sources

https://pagure.io/centos-kernel-rpm/blob/c8/f/SOURCES/kernel-x86_64.config

https://pagure.io/centos-kernel-rpm/blob/c8/f/SOURCES

Bug 1663812 - document method to disable motd message https://bugzilla.redhat.com/show_bug.cgi?id=1663812

Is there a way to permanently remove the cockpit.socket message? https://forums.centos.org/viewtopic.php?t=72303

Strange message on ssh login https://lists.fedoraproject.org/archives/list/users@lists.fedoraproject.org/thread/AQH3F2KY5RUP2RC7EDDXRTMW3AVP2DZJ/

CHAPTER 3. MANAGING KERNEL MODULES https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/managing_monitoring_and_updating_the_kernel/managing-kernel-modules_managing-monitoring-and-updating-the-kernel

anaconda boot options

https://anaconda-installer.readthedocs.io/en/latest/boot-options.html

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/installation_guide/chap-anaconda-boot-options


HOME | GUIDES | LECTURES | LAB | SMTP HEALTH | HTML5 | CONTACT
Copyright © 2024 Pierre-Philipp Braun