Skip to content

Commit

Permalink
Package ISO filesystem in an squashfs image to reduce ISO size
Browse files Browse the repository at this point in the history
Fixes #23
  • Loading branch information
Ratler committed Dec 4, 2017
1 parent 2d2d048 commit dcaa2f2
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 34 deletions.
3 changes: 1 addition & 2 deletions efiboot/loader/entries/lunariso-x86_64-cd.conf
@@ -1,5 +1,4 @@
title Lunar-%VERSION%, %CODENAME% (%DATE%), UEFI CD
linux /isolinux/linux

This comment has been minimized.

Copy link
@amgulshan

amgulshan Nov 14, 2019

source missing

initrd /isolinux/initrd
options root=LABEL=%LABEL% readonlyroot rootdelay=10 loglevel=3

options root=live:CDLABEL=%LABEL% rd.live.image readonlyroot rootdelay=10 loglevel=3
3 changes: 1 addition & 2 deletions efiboot/loader/entries/lunariso-x86_64-usb.conf
@@ -1,5 +1,4 @@
title Lunar-%VERSION%, %CODENAME% (%DATE%), UEFI USB
linux /EFI/lunariso/linux
initrd /EFI/lunariso/initrd
options root=LABEL=%LABEL% readonlyroot rootdelay=10 loglevel=3

options root=live:CDLABEL=%LABEL% rd.live.image readonlyroot rootdelay=10 loglevel=3
6 changes: 3 additions & 3 deletions isolinux/isolinux.cfg.i686
@@ -1,5 +1,5 @@
DEFAULT install
APPEND ro initrd=initrd root=LABEL=%LABEL% readonlyroot rootdelay=10 loglevel=3
APPEND ro initrd=initrd root=live:CDLABEL=%LABEL% rd.live.image readonlyroot rootdelay=10 loglevel=3
DISPLAY f1.txt
TIMEOUT 600
PROMPT 1
Expand All @@ -14,10 +14,10 @@ F8 f1.txt
F9 f1.txt
LABEL install
KERNEL linux
APPEND ro initrd=initrd root=LABEL=%LABEL% readonlyroot rootdelay=10 loglevel=3 vga=ask
APPEND ro initrd=initrd root=live:CDLABEL=%LABEL% rd.live.image readonlyroot rootdelay=10 loglevel=3 vga=ask
LABEL novga
KERNEL linux
APPEND ro initrd=initrd root=LABEL=%LABEL% readonlyroot rootdelay=10 loglevel=3 nomodeset
APPEND ro initrd=initrd root=live:CDLABEL=%LABEL% rd.live.image readonlyroot rootdelay=10 loglevel=3 nomodeset
LABEL memtest
KERNEL memtest
APPEND -
Expand Down
6 changes: 3 additions & 3 deletions isolinux/isolinux.cfg.x86_64
@@ -1,5 +1,5 @@
DEFAULT install
APPEND ro initrd=initrd root=LABEL=%LABEL% readonlyroot rootdelay=10 loglevel=3
APPEND ro initrd=initrd root=live:CDLABEL=%LABEL% rd.live.image readonlyroot rootdelay=10 loglevel=3
DISPLAY f1.txt
TIMEOUT 600
PROMPT 1
Expand All @@ -14,9 +14,9 @@ F8 f1.txt
F9 f1.txt
LABEL install
KERNEL linux
APPEND ro initrd=initrd root=LABEL=%LABEL% readonlyroot rootdelay=10 loglevel=3 vga=ask
APPEND ro initrd=initrd root=live:CDLABEL=%LABEL% rd.live.image readonlyroot rootdelay=10 loglevel=3 vga=ask
LABEL novga
KERNEL linux
APPEND ro initrd=initrd root=LABEL=%LABEL% readonlyroot rootdelay=10 loglevel=3 nomodeset
APPEND ro initrd=initrd root=live:CDLABEL=%LABEL% rd.live.image readonlyroot rootdelay=10 loglevel=3 nomodeset
# uncomment the following line to enable serial console booting
# SERIAL 0 38400
60 changes: 37 additions & 23 deletions mkfiles/iso.mk
@@ -1,4 +1,4 @@
.INTERMEDIATE: iso iso-target iso-modules iso-tools iso-files iso-strip iso-isolinux iso-efi
.INTERMEDIATE: iso iso-target iso-modules iso-tools iso-files iso-strip iso-isolinux iso-efi iso-sfs

iso: $(ISO_SOURCE)/lunar-$(ISO_VERSION).iso

Expand All @@ -19,6 +19,8 @@ iso-tools:
@which xorriso || lin libisoburn
@which isohybrid || lin syslinux
@which efitool-mkusb || lin efitools
@which mksquashfs || lin squashfs
@which rsync || lin rsync

# Remove non iso modules
include $(ISO_SOURCE)/conf/modules.iso
Expand Down Expand Up @@ -152,38 +154,50 @@ iso-efi:
@$(SHELL) -c true
endif

# Generate squashfs image
$(ISO_TARGET)/.iso-sfs: iso-target iso-strip
@echo "Preparing squashfs image"
@mkdir -p $(ISO_TARGET)/LiveOS
@touch $@

$(ISO_TARGET)/LiveOS/squashfs.img: $(ISO_TARGET)/.iso-sfs
@echo "Creating squashfs image"
@$(ISO_SOURCE)/scripts/make-squashfs

iso-sfs: $(ISO_TARGET)/LiveOS/squashfs.img

# Generate the actual image
$(ISO_SOURCE)/lunar-$(ISO_VERSION).iso: iso-tools iso-files iso-isolinux iso-efi iso-strip installer
$(ISO_SOURCE)/lunar-$(ISO_VERSION).iso: iso-tools iso-files iso-isolinux iso-efi iso-strip iso-sfs installer
@echo iso
@xorriso -as mkisofs \
-iso-level 3 \
-full-iso9660-filenames \
-full-iso9660-filenames \
-o $@.tmp -l \
-eltorito-boot isolinux/isolinux.bin \
-eltorito-catalog isolinux/boot.cat \
-no-emul-boot -boot-load-size 4 -boot-info-table \
-isohybrid-mbr $(ISO_TARGET)/isolinux/isohdpfx.bin \
$(XORRISO_EFI_OPTS) \
$(XORRISO_EFI_OPTS) \
-m '$(ISO_TARGET)/.*' \
-m '$(ISO_TARGET)/boot/*' \
-m '$(ISO_TARGET)/etc/lunar/local/*' \
-m '$(ISO_TARGET)/tmp/*' \
-m '$(ISO_TARGET)/var/tmp/*' \
-m '$(ISO_TARGET)/var/spool/*' \
-m '$(ISO_TARGET)/var/log/*' \
-m '$(ISO_TARGET)/usr/lib/locale' \
-m '$(ISO_TARGET)/usr/share/locale' \
-m '$(ISO_TARGET)/usr/share/man/man2' \
-m '$(ISO_TARGET)/usr/share/man/man3' \
-m '$(ISO_TARGET)/usr/share/man/*/man2' \
-m '$(ISO_TARGET)/usr/share/man/*/man3' \
-m '$(ISO_TARGET)/usr/share/info' \
-m '$(ISO_TARGET)/usr/share/gtk-doc' \
-m '$(ISO_TARGET)/usr/include' \
-m '$(ISO_TARGET)/usr/src' \
-m '$(ISO_TARGET)/var/state/lunar/module_history' \
-m 'doc' \
-publisher "Lunar Linux - http://www.lunar-linux.org/" \
-m '$(ISO_TARGET)/boot' \
-m '$(ISO_TARGET)/bin' \
-m '$(ISO_TARGET)/sbin' \
-m '$(ISO_TARGET)/usr' \
-m '$(ISO_TARGET)/dev' \
-m '$(ISO_TARGET)/etc' \
-m '$(ISO_TARGET)/home' \
-m '$(ISO_TARGET)/lib*' \
-m '$(ISO_TARGET)/root' \
-m '$(ISO_TARGET)/var' \
-m '$(ISO_TARGET)/media' \
-m '$(ISO_TARGET)/mnt' \
-m '$(ISO_TARGET)/opt' \
-m '$(ISO_TARGET)/run' \
-m '$(ISO_TARGET)/proc' \
-m '$(ISO_TARGET)/srv' \
-m '$(ISO_TARGET)/sys' \
-m '$(ISO_TARGET)/tmp' \
-publisher "Lunar Linux - http://www.lunar-linux.org/" \
-volid '$(ISO_LABEL)' \
-appid 'Lunar-$(ISO_VERSION)' $(ISO_TARGET)
@mv $@.tmp $@
51 changes: 51 additions & 0 deletions scripts/make-squashfs
@@ -0,0 +1,51 @@
#!/bin/bash

set -e

# !!! DO NOT CHANGE THE IMG NAMES !!!
# Dracut requires a very specific fs hiearchy for squashfs
# /LiveOS
# |- squashfs.img
# !(mount)
# /LiveOS
# |- rootfs.img
ROOTFSMNTDIR=$(mktemp -d /tmp/rootfs-XXXXXX)
SFSDIR=$ISO_SOURCE/_SFS
ROOTFSIMGDIR=$SFSDIR/LiveOS
ROOTFSIMG=$ROOTFSIMGDIR/rootfs.img

finishScript() {
umount -d $ROOTFSMNTDIR || true
rmdir $ROOTFSMNTDIR
rm -rf "$SFSDIR"
}

trap finishScript 0 2 3 15

mkdir -p $ROOTFSIMGDIR
truncate -s 16G $ROOTFSIMG
mkfs.ext4 -O ^has_journal,^resize_inode -E lazy_itable_init=0 -m 0 -F "$ROOTFSIMG"
tune2fs -i 0 -c 0 $ROOTFSIMG &> /dev/null
mount $ROOTFSIMG $ROOTFSMNTDIR
rsync -av $ISO_TARGET/ $ROOTFSMNTDIR --exclude ".*" \
--exclude boot/* \
--exclude isolinux/ \
--exclude EFI/ \
--exclude etc/lunar/local/* \
--exclude tmp/* \
--exclude var/tmp/* \
--exclude var/spool/* \
--exclude var/log/* \
--exclude usr/include \
--exclude usr/lib/locale \
--exclude usr/share/locale \
--exclude usr/share/man \
--exclude usr/share/info \
--exclude usr/share/doc \
--exclude usr/share/gtk-doc \
--exclude usr/share/vim \
--exclude usr/src \
--exclude var/state/lunar/module_history
umount $ROOTFSMNTDIR
mkdir -p $ISO_TARGET/LiveOS
mksquashfs "$SFSDIR" "$ISO_TARGET/LiveOS/squashfs.img" -noappend -comp "xz" -no-progress
3 changes: 2 additions & 1 deletion template/etc/dracut.conf.d/02-lunar-live.conf
@@ -1,2 +1,3 @@
# Dracut config file for Lunar Linux CD
add_dracutmodules+=" lunar-live "
add_dracutmodules+=" dmsquash-live lunar-live "
compress="xz"

0 comments on commit dcaa2f2

Please sign in to comment.