More tuning to CentOS LUKS image

This commit is contained in:
fnux 2020-06-29 17:46:48 +02:00
parent 91ed6d57f2
commit 4682ed9a3a

View file

@ -20,7 +20,7 @@ LUKS_PASSPHRASE=secret
LUKS_DEVICE_NAME=cryptroot
LUKS_DEVICE="/dev/mapper/$LUKS_DEVICE_NAME"
ONE_CONTEXT_RPM_URL="https://github.com/OpenNebula/addon-context-linux/releases/download/v5.10.0/one-context-5.10.0-1.el7.noarch.rpm"
ONE_CONTEXT_RPM_URL="https://github.com/OpenNebula/addon-context-linux/releases/download/v5.10.0/one-context-5.10.0-1.el$RELEASE.noarch.rpm"
ONE_CONTEXT_RPM_PATH=/root/one-context.rpm
cleanup() {
@ -81,10 +81,12 @@ mkdir /mnt/boot
mount "${LOOPBACK_DEVICE}p1" /mnt/boot
# AppStream landed in CentOS 8.
if [ $RELEASE >= 8 ]; then
if [ $RELEASE -ge 8 ]; then
enabled_repos="--enablerepo=BaseOS --enablerepo=AppStream --enablerepo=extras"
release_specific_packages="systemd-udev"
else
enabled_repos="--enablerepo=Base --enablerepo=extras"
enabled_repos="--enablerepo=base --enablerepo=extras"
release_specific_packages="dnf"
fi
dnf -y \
@ -93,7 +95,7 @@ dnf -y \
--disablerepo='*' \
$enabled_repos \
--setopt=install_weak_deps=False install \
bash basesystem systemd systemd-udev dnf centos-release
bash basesystem systemd dnf centos-release cryptsetup $release_specific_packages
mount --bind /dev /mnt/dev
mount --bind /dev/pts /mnt/dev/pts
@ -119,7 +121,9 @@ EOF
# See https://github.com/OpenNebula/addon-context-linux/issues/121 for details.
# network-scripts.x86_64 : Legacy scripts for manipulating of network devices
run_root dnf -y install network-scripts
if [ $RELEASE -ge 8 ]; then
run_root dnf -y install network-scripts
fi
# Install (magic?) one-context RPM and hope things works as expected.
curl -L "$ONE_CONTEXT_RPM_URL" > "/mnt$ONE_CONTEXT_RPM_PATH"
@ -147,7 +151,7 @@ cat > /mnt/etc/dracut.conf.d/virtio-blk.conf <<EOF
add_drivers="virtio-blk"
EOF
kernel_version=$(ls /mnt/boot | grep "vmlinuz.*.$ARCH" | cut -d- -f2-)
run_root dracut --force --kver $kernel_version
run_root dracut -v --force --kver $kernel_version
# Configure grub2.
luks_uuid=$(blkid --match-tag UUID --output value "${LOOPBACK_DEVICE}p2")