From c4e56592179af02da12ab87abafd956f860371cb Mon Sep 17 00:00:00 2001 From: Michael Hudson-Doyle Date: Thu, 13 Dec 2018 10:47:54 +1300 Subject: [PATCH 1/6] do not include kernel in base install for ubuntu-server:live this actually makes things closer to the non-live server build and so makes things a bit simpler --- live-build/auto/config | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/live-build/auto/config b/live-build/auto/config index 9c39acbb..21cba94d 100755 --- a/live-build/auto/config +++ b/live-build/auto/config @@ -145,20 +145,15 @@ case $IMAGEFORMAT in ;; plain) - INITRAMFS_TYPE=none case $PROJECT:${SUBPROJECT:-} in ubuntu-server:live) - # Stop lb installing casper into filesystem.squashfs - # by skipping lb_chroot_live-packages. - skip_lb_stage chroot_live-packages - INITRAMFS_TYPE=auto touch config/universe-enabled ;; *) PREINSTALLED=true ;; esac - OPTS="${OPTS:+$OPTS }--initramfs $INITRAMFS_TYPE --chroot-filesystem $IMAGEFORMAT" + OPTS="${OPTS:+$OPTS }--initramfs none --chroot-filesystem $IMAGEFORMAT" ;; ubuntu-image) @@ -519,9 +514,6 @@ case $PROJECT in add_task install standard add_task install server LIVE_TASK='cloud-image' - case $ARCH in - amd64) add_package live linux-signed-generic ;; - esac ;; esac COMPONENTS='main' @@ -837,8 +829,6 @@ case $ARCH in esac case $PROJECT:${SUBPROJECT:-} in - ubuntu-server:live) - ;; ubuntu-server:*|ubuntu-base:*|ubuntu-touch:*|ubuntu-touch-custom:*) OPTS="${OPTS:+$OPTS }--linux-packages=none --initramfs=none" KERNEL_FLAVOURS=none From e3e2e5f9ffa9d3820ab0dd9525a77bf819dfce94 Mon Sep 17 00:00:00 2001 From: Michael Hudson-Doyle Date: Thu, 13 Dec 2018 11:10:44 +1300 Subject: [PATCH 2/6] do not unmount the installer overlay in 032-installer-squashfs.binary so that a new hook can create yet further overlays on top of it --- .../hooks/032-installer-squashfs.binary | 31 ++++++++----------- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/live-build/ubuntu-server/hooks/032-installer-squashfs.binary b/live-build/ubuntu-server/hooks/032-installer-squashfs.binary index bab6ab76..63edba4f 100755 --- a/live-build/ubuntu-server/hooks/032-installer-squashfs.binary +++ b/live-build/ubuntu-server/hooks/032-installer-squashfs.binary @@ -24,13 +24,14 @@ fi . config/functions . config/common -SQUASH_ROOT=binary/boot/squashfs.dir +FILESYSTEM_ROOT=binary/boot/squashfs.dir +INSTALLER_ROOT=binary/boot/installer.squashfs.dir OVERLAY_ROOT=binary/overlay -mkdir -p "$OVERLAY_ROOT" +mkdir -p "$INSTALLER_ROOT" "$OVERLAY_ROOT" # Create an installer squashfs layer -mount_overlay "$SQUASH_ROOT/" "$OVERLAY_ROOT/" "$SQUASH_ROOT/" +mount_overlay "$FILESYSTEM_ROOT/" "$OVERLAY_ROOT/" "$INSTALLER_ROOT/" setup_mountpoint binary/boot/squashfs.dir @@ -40,8 +41,8 @@ setup_mountpoint binary/boot/squashfs.dir # It would be better to have this in ../includes.binary/overlay but # you can't have backslashes in filenames in bzr branches! DEVICE_UNIT_NAME='dev-disk-by\x2duuid-00c629d6\x2d06ab\x2d4dfd\x2db21e\x2dc3186f34105d.device' -mkdir -p "$SQUASH_ROOT/etc/systemd/system/$DEVICE_UNIT_NAME.d" -cat > "$SQUASH_ROOT/etc/systemd/system/$DEVICE_UNIT_NAME.d/override.conf" < "$INSTALLER_ROOT/etc/systemd/system/$DEVICE_UNIT_NAME.d/override.conf" < Date: Thu, 13 Dec 2018 11:18:55 +1300 Subject: [PATCH 3/6] add hook to create kernel/initrd/modules for ISO --- .../hooks/033-kernel-bits.binary | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 live-build/ubuntu-server/hooks/033-kernel-bits.binary diff --git a/live-build/ubuntu-server/hooks/033-kernel-bits.binary b/live-build/ubuntu-server/hooks/033-kernel-bits.binary new file mode 100644 index 00000000..9a193b52 --- /dev/null +++ b/live-build/ubuntu-server/hooks/033-kernel-bits.binary @@ -0,0 +1,66 @@ +#!/bin/bash -eux +# vi: ts=4 noexpandtab +# +# Generate a squashfs root and manifest + +echo "033-kernel-bits.binary" + +case ${IMAGE_TARGETS-} in + ""|*squashfs*) + ;; + *) + echo "Skipping squashfs build" + exit 0 + ;; +esac + +if [ -n "${SUBARCH-}" ]; then + echo "Skipping rootfs build for subarch flavor build" + exit 0 +fi + +. config/functions +. config/common + +INSTALLER_ROOT=binary/boot/installer.squashfs.dir + +KERNEL_BITS_ROOT=binary/boot/kernel-bits.dir +KERNEL_BITS_OVERLAY=binary/boot/overlay-kernel-bits + +#variants='ga hwe' +variants='ga' + +for variant in $variants; do + if [ "$variant" = "ga" ]; then + kernel_metapkg=linux-generic + flavor=generic + elif [ "$variant" = "hwe" ]; then + kernel_metapkg=linux-generic-hwe-$(lsb_release -sc) + flavor=generic-hwe + else + echo "bogus variant: $variant" + exit 1 + fi + + # Make preparations + mkdir -p $KERNEL_BITS_ROOT $KERNEL_BITS_OVERLAY + mount_overlay "$INSTALLER_ROOT/" "$KERNEL_BITS_OVERLAY/" "$KERNEL_BITS_ROOT/" + setup_mountpoint $KERNEL_BITS_ROOT + + # Install the kernel! + env DEBIAN_FRONTEND=noninteractive chroot $KERNEL_BITS_ROOT apt-get -y install ${kernel_metapkg} + + # Fish out generated kernel image and initrd + mv "$KERNEL_BITS_ROOT"/boot/initrd.img-* ${PWD}/livecd.${PROJECT}.initrd-$flavor + mv "$KERNEL_BITS_ROOT"/boot/vmlinu?-* ${PWD}/livecd.${PROJECT}.kernel-$flavor + + # Create squashfs containing all the modules + modules_squashfs_path="${PWD}/livecd.${PROJECT}.modules.squashfs-$flavor" + (cd "$KERNEL_BITS_ROOT/lib/modules" && + mksquashfs . $modules_squashfs_path -no-progress -xattrs -comp xz) + + # And clean up + teardown_mountpoint $KERNEL_BITS_ROOT + umount $KERNEL_BITS_ROOT + rm -rf $KERNEL_BITS_ROOT $KERNEL_BITS_OVERLAY +done From 7167e3718bf3f8b4cf7b42c6dde4a44a67fd2229 Mon Sep 17 00:00:00 2001 From: Michael Hudson-Doyle Date: Thu, 13 Dec 2018 11:22:34 +1300 Subject: [PATCH 4/6] add initramfs hook to record kernel metapackage & mount modules --- .../hooks/033-kernel-bits.binary | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/live-build/ubuntu-server/hooks/033-kernel-bits.binary b/live-build/ubuntu-server/hooks/033-kernel-bits.binary index 9a193b52..af67924d 100644 --- a/live-build/ubuntu-server/hooks/033-kernel-bits.binary +++ b/live-build/ubuntu-server/hooks/033-kernel-bits.binary @@ -47,6 +47,27 @@ for variant in $variants; do mount_overlay "$INSTALLER_ROOT/" "$KERNEL_BITS_OVERLAY/" "$KERNEL_BITS_ROOT/" setup_mountpoint $KERNEL_BITS_ROOT + # Configure initramfs creation + mkdir -p "$KERNEL_BITS_ROOT"/etc/initramfs-tools/conf.d/ + if [ -n "$LB_INITRAMFS_COMPRESSION" ]; then + echo "COMPRESS=$LB_INITRAMFS_COMPRESSION" > "$KERNEL_BITS_ROOT"/etc/initramfs-tools/conf.d/livecd-rootfs.conf + fi + echo "CASPER_GENERATE_UUID=1" > "$KERNEL_BITS_ROOT"/etc/initramfs-tools/conf.d/casper.conf + + # Add a hook to record which kernel was booted and mount the + # modules.squashfs created below. + cat < "$KERNEL_BITS_ROOT"/etc/initramfs-tools/scripts/init-bottom/live-server +#!/bin/sh +case \$1 in +prereqs) exit 0;; +esac + +echo ${kernel_metapkg} > /run/kernel-meta-package +mkdir -p \$rootmnt/lib/modules +mount \$rootmnt/cdrom/casper/extras/modules.squashfs-$flavor \$rootmnt/lib/modules +EOF + chmod +x "$KERNEL_BITS_ROOT"/etc/initramfs-tools/scripts/init-bottom/live-server + # Install the kernel! env DEBIAN_FRONTEND=noninteractive chroot $KERNEL_BITS_ROOT apt-get -y install ${kernel_metapkg} From 460332296b4befc77166933ffbb274ce92553aa9 Mon Sep 17 00:00:00 2001 From: Michael Hudson-Doyle Date: Thu, 13 Dec 2018 11:23:15 +1300 Subject: [PATCH 5/6] remove cloud-initramfs-copymods before installing kernel --- live-build/ubuntu-server/hooks/033-kernel-bits.binary | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/live-build/ubuntu-server/hooks/033-kernel-bits.binary b/live-build/ubuntu-server/hooks/033-kernel-bits.binary index af67924d..5ebfd1d9 100644 --- a/live-build/ubuntu-server/hooks/033-kernel-bits.binary +++ b/live-build/ubuntu-server/hooks/033-kernel-bits.binary @@ -47,6 +47,10 @@ for variant in $variants; do mount_overlay "$INSTALLER_ROOT/" "$KERNEL_BITS_OVERLAY/" "$KERNEL_BITS_ROOT/" setup_mountpoint $KERNEL_BITS_ROOT + # Our initramfs hook implements a kind of extreme version of + # cloud-initramfs-copymods, so remove that and prevent duelling hooks + env DEBIAN_FRONTEND=noninteractive chroot $KERNEL_BITS_ROOT apt-get -y remove cloud-initramfs-copymods ubuntu-server || true + # Configure initramfs creation mkdir -p "$KERNEL_BITS_ROOT"/etc/initramfs-tools/conf.d/ if [ -n "$LB_INITRAMFS_COMPRESSION" ]; then From 71c04ecfebc6439134bbed11590d5cebaa999f4e Mon Sep 17 00:00:00 2001 From: Michael Hudson-Doyle Date: Thu, 13 Dec 2018 11:51:11 +1300 Subject: [PATCH 6/6] changelog --- debian/changelog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/debian/changelog b/debian/changelog index 7224cf0d..308a0626 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,11 @@ livecd-rootfs (2.550) UNRELEASED; urgency=medium * Fix typo preventing builds of ubuntu-core images. + * Changes to kernel handling for live-server: do not include kernel/initrd + in filesystem.squashfs but rather install it in a throwaway layer on top + of installer.squashfs and fish kernel, initrd and modules out of that with + an initrd hook that records kernel metapackage name in /run and mounts + /lib/modules from a squashfs on the ISO. -- Michael Hudson-Doyle Wed, 12 Dec 2018 15:09:28 +1300