From 90daf5d5e37d247684e54463d51e9469b4f38953 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 14 May 2021 15:58:57 -0400 Subject: [PATCH] Further advance the confluent diskless support --- confluent_osdeploy/diskless/build/genimage | 27 ++++++++++++++++--- .../hooks/cmdline/10-confluentdiskless.sh | 4 ++- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/confluent_osdeploy/diskless/build/genimage b/confluent_osdeploy/diskless/build/genimage index 0240aede..1577d746 100644 --- a/confluent_osdeploy/diskless/build/genimage +++ b/confluent_osdeploy/diskless/build/genimage @@ -1,4 +1,5 @@ installroot=$1 +destdir=$2 touch $installroot/.testcap if setcap cap_net_raw+p $installroot/.testcap >& /dev/null; then @@ -7,9 +8,29 @@ else capsargs="--setopt=tsflags=nocapps" fi rm $installroot/.testcap -yum $capsargs --releasever=8 --installroot=/var/tmp/testgenimage/ --releasever=8.3 install '@minimal-environment' chrony kernel net-tools nfs-utils openssh-server rsync tar util-linux python3 tar dracut dracut-network ethtool parted openssl dhclient openssh-clients bash vim-minimal rpm iputils shim-x64 grub2-efi-x64 -dracut -v --xz -N -m "stateless base terminfo" -f boot/initramfs-diskless 4.18.0-240.22.1.el8_3.x86_64 +pkglist=$(cat $(dirname $0)/pkglist | tr "\r\n" " ") +mydir=$(dirname $0) +mkdir -p $installroot/proc $installroot/sys $installroot/dev +unshare -f -p -m bash -c " +mount -o bind /proc $installroot/proc +mount -o bind /sys $installroot/sys +mount -o bind /dev $installroot/dev +yum -y $capsargs --releasever=8 --installroot=$installroot install $pkglist +cp -a $dirname/dracut $installroot/usr/lib/dracut/modules.d/97diskless +chmod a+x $installroot/usr/lib/dracut/modules.d/97diskless/* +for kernel in $(ls $installroot/boot/vmlinuz-*|grep -v rescue|sed -e s/.*vmlinuz-//); do + echo -n "Creating diskless initramfs for $kernel" + chroot $installroot dracut -v --xz -N -m "diskless base terminfo" -f boot/initramfs-diskless-$kernel.img $kernel +done +" +latestkernel=$(ls $installroot/boot/vmlinuz-*|grep -v rescue|sed -e s/.*vmlinuz-//|tail -n 1) +mkdir -p $destdir/boot/efi/boot $destdir/boot/initramfs +cp $installroot/boot/vmlinuz-$latestkernel $destdir/boot/kernel +cp $installroot/boot/initramfs-diskless-$kernel.img $destdir/boot/initramfs/distribution +cp $installroot/boot/efi/EFI/BOOT/BOOTX64.EFI $destdir/boot/efi/boot +cp $installroot/boot/efi/EFI/centos/grubx64.efi $destdir/boot/efi/boot + # link kernel, initrd, grub, and shim as appropriate # use xz, minimize https burden and transfer penalty -mksquashfs -comp xz +mksquashfs $installroot $destdir/rootimg.sfs -comp xz diff --git a/confluent_osdeploy/diskless/initramfs/usr/lib/dracut/hooks/cmdline/10-confluentdiskless.sh b/confluent_osdeploy/diskless/initramfs/usr/lib/dracut/hooks/cmdline/10-confluentdiskless.sh index 03dbcb75..1b7ad4f6 100644 --- a/confluent_osdeploy/diskless/initramfs/usr/lib/dracut/hooks/cmdline/10-confluentdiskless.sh +++ b/confluent_osdeploy/diskless/initramfs/usr/lib/dracut/hooks/cmdline/10-confluentdiskless.sh @@ -129,8 +129,10 @@ for addr in $(grep ^MANAGER: /etc/confluent/confluent.info|awk '{print $2}'|sed confluent_urls="$confluent_urls $confluent_proto://$addr/confluent-public/os/$confluent_profile/rootimg.sfs" fi done +confluent_mgr=$(grep ^deploy_server: /etc/confluent/confluent.deploycfg| awk '{print $2}') +confluent_urls="$confluent_urls https://$confluent_mgr/confluent-public/os/$confluent_profile/rootimg.sfs" mkdir -p /mnt/remoteimg /mnt/remote /mnt/overlay -curlmount $confluent_urls /mnt/remoteimg +/opt/confluent/bin/urlmount $confluent_urls /mnt/remoteimg mount -o loop,ro /mnt/remoteimg/*.sfs /mnt/remote mount -t tmpfs overlay /mnt/overlay mkdir -p /mnt/overlay/upper /mnt/overlay/work