anaconda, lorax: drop rootfs.img inside squashfs

Package root filesystem directly as squashfs image. The most important
gain is getting rid of greatly unreproducible ext4 image creation. But
also it makes the output image slightly smaller, and the build faster.
Also, dmsquash-live dracut module is not needed anymore, which reduce
initramfs size.
This commit is contained in:
Marek Marczykowski-Górecki 2018-10-04 21:46:15 +02:00
parent 285516599a
commit 332be8e1e3
4 changed files with 72 additions and 5 deletions

View File

@ -101,13 +101,30 @@ anaconda_live_root_dir() {
anaconda_mount_sysroot $img
}
anaconda_mount_root_squashfs() {
local img="$1"
ROOTFLAGS="$(getarg rootflags)"
modprobe squashfs || die "squashfs not supported"
modprobe overlay || die "overlayfs not supported"
mkdir -m 0755 -p /run/overlayfs
mkdir -m 0755 -p /run/rootfsbase
mkdir -m 0755 -p /run/ovlwork
mount -r "$img" /run/rootfsbase
printf 'mount -t overlay LiveOS_rootfs -o%s,%s %s\n' "$ROOTFLAGS" \
'lowerdir=/run/rootfsbase,upperdir=/run/overlayfs,workdir=/run/ovlwork' \
"$NEWROOT" > $hookdir/mount/01-$$-live.sh
# satisfy wait_for_dev /dev/root
ln -s /dev/null /dev/root
}
anaconda_mount_sysroot() {
local img="$1"
if [ -e "$img" ]; then
/sbin/dmsquash-live-root $img
# dracut & systemd only mount things with root=live: so we have to do this ourselves
# See https://bugzilla.redhat.com/show_bug.cgi?id=1232411
printf 'mount /dev/mapper/live-rw %s\n' "$NEWROOT" > $hookdir/mount/01-$$-anaconda.sh
anaconda_mount_root_squashfs "$img"
fi
}

View File

@ -7,7 +7,7 @@ check() {
}
depends() {
echo img-lib dmsquash-live
echo img-lib
case "$(uname -m)" in
s390*) echo cms ;;
esac

View File

@ -0,0 +1,48 @@
From cfc809df64e2778e51d47dc8b4466cf98efe8a2b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?=
<marmarek@invisiblethingslab.com>
Date: Wed, 3 Oct 2018 20:00:19 +0200
Subject: [PATCH] Drop inner rootfs.img layer
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Organization: Invisible Things Lab
Cc: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Make runtime directly into squashfs image. This reduces largely
unreproducible ext4 layer, but requires dracut module modification to
properly mount the image.
Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
---
src/pylorax/treebuilder.py | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/src/pylorax/treebuilder.py b/src/pylorax/treebuilder.py
index 5d4f8b7..b804c2f 100644
--- a/src/pylorax/treebuilder.py
+++ b/src/pylorax/treebuilder.py
@@ -212,17 +212,11 @@ class RuntimeBuilder(object):
generate_module_info(moddir+kver, outfile=moddir+"module-info")
def create_runtime(self, outfile="/var/tmp/squashfs.img", compression="xz", compressargs=None, size=2):
- # make live rootfs image - must be named "LiveOS/rootfs.img" for dracut
compressargs = compressargs or []
- workdir = joinpaths(os.path.dirname(outfile), "runtime-workdir")
- os.makedirs(joinpaths(workdir, "LiveOS"))
+ os.makedirs(os.path.dirname(outfile))
- imgutils.mkrootfsimg(self.vars.root, joinpaths(workdir, "LiveOS/rootfs.img"),
- "Anaconda", size=size)
-
- # squash the live rootfs and clean up workdir
- imgutils.mksquashfs(workdir, outfile, compression, compressargs)
- remove(workdir)
+ # squash the rootfs
+ imgutils.mksquashfs(self.vars.root, outfile, compression, compressargs)
def finished(self):
""" Done using RuntimeBuilder
--
2.17.1

View File

@ -20,6 +20,7 @@ Patch1: 0001-Allow-specify-gpg-key-for-a-repository.patch
Patch2: 0002-verify-packages-signature.patch
Patch3: 0003-Update-package-verification-for-dnf-API.patch
Patch4: 0004-Remove-branding-code.patch
Patch5: 0005-Drop-inner-rootfs.img-layer.patch
BuildRequires: python3-devel
@ -126,6 +127,7 @@ Lorax templates for creating the boot.iso and live isos are placed in
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%build