From 821c0f9620c4ec2431a913c2893b17e966374af6 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 2 Jul 2021 06:37:24 +0200 Subject: stage2: Add mkinitramfs w/ forced fsck types; journald.conf memory only etc settings; tmpfs overlay_mount (for now); loop_rootfs: single /boot fsck ...; Use overlay_mount on a tmpfs 64MiB (for now) loop_rootfs: single /boot fsck and add debug panic at end to validated results /etc/systemd/journald.conf - Storage=volatile - Compress=yes - RuntimeMaxUse=1M - ForwardToSyslog=no - ForwardToWall=no --- stage2/01-sys-tweaks/01-run.sh | 129 ++++++++++++----------- stage2/01-sys-tweaks/files/initramfs/fsck_custom | 40 +++++++ stage2/01-sys-tweaks/files/initramfs/loop_rootfs | 8 +- stage2/01-sys-tweaks/files/overlay_mount | 22 ++-- 4 files changed, 117 insertions(+), 82 deletions(-) create mode 100755 stage2/01-sys-tweaks/files/initramfs/fsck_custom diff --git a/stage2/01-sys-tweaks/01-run.sh b/stage2/01-sys-tweaks/01-run.sh index a8d088f..4b25a97 100755 --- a/stage2/01-sys-tweaks/01-run.sh +++ b/stage2/01-sys-tweaks/01-run.sh @@ -27,43 +27,55 @@ s/^#?[[:blank:]]*PasswordAuthentication[[:blank:]]*yes[[:blank:]]*$/PasswordAuth fi on_chroot << EOF -systemctl disable hwclock.sh -#systemctl disable nfs-common -systemctl disable rpcbind -if [ "${ENABLE_SSH}" == "1" ]; then - systemctl enable ssh -else - systemctl disable ssh -fi -systemctl enable regenerate_ssh_host_keys - -#mkdir -p /data/overlay_a -#cd /data/overlay_a -#mkdir -p etc/upper etc/work home/upper home/work srv/upper srv/work tmp/upper tmp/work var/upper var/work -# -#mkdir -p /data/overlay_b -#cd /data/overlay_b -#mkdir -p etc/upper etc/work home/upper home/work srv/upper srv/work tmp/upper tmp/work var/upper var/work -# -#cd /data -#ln -s overlay_a overlay -# -#systemctl enable overlay_mount - -systemctl disable overlay_mount -systemctl mask overlay_mount - -# Setup unique system folder /boot/sys_arm64_000 -mkdir -p /boot/sys_arm64_000 -mv /boot/*.dtb /boot/COPYING.linux /boot/LICENCE.broadcom /boot/initrd.img /boot/sys_arm64_000/ -mv /boot/issue.txt /boot/kernel8.img /boot/overlays /boot/rootfs.img /boot/sys_arm64_000/ - -mv /boot/config.txt /boot/config.txt.orig -mv /boot/cmdline.txt /boot/sys_arm64_000/cmdline.txt.orig -if [ -f /boot/initrd.img ]; then - mv /boot/initrd.img /boot/sys_arm64_000/initrd.img.orig -fi - + systemctl disable hwclock.sh + #systemctl disable nfs-common + systemctl disable rpcbind + if [ "${ENABLE_SSH}" == "1" ]; then + systemctl enable ssh + else + systemctl disable ssh + fi + systemctl enable regenerate_ssh_host_keys + + #mkdir -p /data/overlay_a + #cd /data/overlay_a + #mkdir -p etc/upper etc/work home/upper home/work srv/upper srv/work tmp/upper tmp/work var/upper var/work + # + #mkdir -p /data/overlay_b + #cd /data/overlay_b + #mkdir -p etc/upper etc/work home/upper home/work srv/upper srv/work tmp/upper tmp/work var/upper var/work + # + #cd /data + #ln -s overlay_a overlay + # + + systemctl unmask overlay_mount + systemctl enable overlay_mount + + #systemctl disable overlay_mount + #systemctl mask overlay_mount + + # Setup unique system folder /boot/sys_arm64_000 + mkdir -p /boot/sys_arm64_000 + + find /boot -maxdepth 1 -name \*.dtb -exec mv \{\} /boot/sys_arm64_000/ \; + + find /boot -maxdepth 1 -name kernel\*.img -exec mv \{\} /boot/sys_arm64_000/ \; + + for i in /boot/COPYING.linux /boot/LICENCE.broadcom /boot/sys_arm64_000/ \ + /boot/issue.txt /boot/overlays /boot/rootfs.img ; do + if [ -f "${i}" ]; then + mv "${i}" /boot/sys_arm64_000/ + fi + done + + for i in /boot/config.txt /boot/cmdline.txt /boot/initrd.img ; do + if [ -f "${i}" ]; then + mv "${i}" /boot/sys_arm64_000/"${i}.orig" + fi + done + + systemctl disable resize2fs_once EOF install -m 644 files/boot/sys_arm64_000/cmdline.txt "${ROOTFS_DIR}/boot/sys_arm64_000/" @@ -71,46 +83,35 @@ install -m 644 files/boot/sys_arm64_000/cmdline.txt "${ROOTFS_DIR}/boot/sys_arm install -m 644 files/boot/config.txt "${ROOTFS_DIR}/boot/" install -m 755 files/initramfs/loop_rootfs "${ROOTFS_DIR}/etc/initramfs-tools/scripts/init-premount/" +install -m 755 files/initramfs/fsck_custom "${ROOTFS_DIR}/etc/initramfs-tools/hooks/" # echo "squashfs" >> "${ROOTFS_DIR}/etc/modules" echo "squashfs" >> "${ROOTFS_DIR}/etc/initramfs-tools/modules" -sed -i -e 's/MODULES=most/MODULES=dep/g' -e 's/BUSYBOX=auto/BUSYBOX=y/g' "${ROOTFS_DIR}/etc/initramfs-tools/initramfs.conf" +sed -i -e 's/MODULES=most/MODULES=dep/g;s/BUSYBOX=auto/BUSYBOX=y/g' "${ROOTFS_DIR}/etc/initramfs-tools/initramfs.conf" -on_chroot << EOF -mkinitramfs -o /boot/sys_arm64_000/initrd.img -EOF +sed -i -e 's/#Storage=auto/Storage=volatile/g;s/#Compress=yes/Compress=yes/g;s/#RuntimeMaxUse=/RuntimeMaxUse=1M/g;s/#ForwardToSyslog=yes/ForwardToSyslog=no/g;s/#ForwardToWall=yes/ForwardToWall=no/g' "${ROOTFS_DIR}/etc/systemd/journald.conf" if [ "${USE_QEMU}" = "1" ]; then echo "enter QEMU mode" install -m 644 files/90-qemu.rules "${ROOTFS_DIR}/etc/udev/rules.d/" - on_chroot << EOF -systemctl disable resize2fs_once -EOF echo "leaving QEMU mode" -else - on_chroot << EOF -#systemctl enable resize2fs_once -systemctl disable resize2fs_once -EOF - echo "leaving normal mode" fi on_chroot <&2 + fi +done diff --git a/stage2/01-sys-tweaks/files/initramfs/loop_rootfs b/stage2/01-sys-tweaks/files/initramfs/loop_rootfs index 381666e..cd986ff 100755 --- a/stage2/01-sys-tweaks/files/initramfs/loop_rootfs +++ b/stage2/01-sys-tweaks/files/initramfs/loop_rootfs @@ -157,9 +157,9 @@ log_begin_msg "loop_rootfs" mkdir -p ${BOOT_DIR} # force fix verbose fseek, using undocumented options '-f', '-y' -while ! fsck -f -y -V -t vfat "${BOOT_PART}"; do - panic "The vfat filesystem on ${BOOT_PART} requires a manual fsck" -done +if ! fsck -f -y -V -t vfat "${BOOT_PART}"; then + log_failure_msg "The vfat filesystem on ${BOOT_PART} seems to require a manual fsck, continuing" +fi if ! mount ${BOOT_PART} ${BOOT_DIR}; then panic "loop_rootfs could not mount /boot." @@ -231,6 +231,8 @@ fi log_success_msg "loop_rootfs attached ${OS_PREFIX}, ${ROOTFSTYPE} file ${IMAGE_FILE} to loop-device ${ROOT}." +panic "loop_rootfs debug break point." + log_end_msg exit 0 diff --git a/stage2/01-sys-tweaks/files/overlay_mount b/stage2/01-sys-tweaks/files/overlay_mount index 0ecbcce..a107bf7 100755 --- a/stage2/01-sys-tweaks/files/overlay_mount +++ b/stage2/01-sys-tweaks/files/overlay_mount @@ -11,21 +11,13 @@ case "$1" in start) log_daemon_msg "Starting overlay_mount" - /bin/mount -t ext4 DATADEV -odefaults,noatime /data && - if [ -f /data/overlay/ERASE ]; then \ - log_progress_msg "erasing overlay" ; \ - rm -f /data/overlay/ERASE ; \ - cd /data/overlay ; \ - rm -rf etc home srv tmp var ; \ - mkdir -p etc/upper etc/work home/upper home/work srv/upper srv/work tmp/upper tmp/work var/upper var/work ; \ - else \ - log_progress_msg "keeping overlay" ; \ - fi && - /bin/mount -t overlay overlay -odefaults,noatime,lowerdir=/etc,upperdir=/data/overlay/etc/upper,workdir=/data/overlay/etc/work /etc && - /bin/mount -t overlay overlay -odefaults,noatime,lowerdir=/home,upperdir=/data/overlay/home/upper,workdir=/data/overlay/home/work /home && - /bin/mount -t overlay overlay -odefaults,noatime,lowerdir=/srv,upperdir=/data/overlay/srv/upper,workdir=/data/overlay/srv/work /srv && - /bin/mount -t overlay overlay -odefaults,noatime,lowerdir=/tmp,upperdir=/data/overlay/tmp/upper,workdir=/data/overlay/tmp/work /tmp && - /bin/mount -t overlay overlay -odefaults,noatime,lowerdir=/var,upperdir=/data/overlay/var/upper,workdir=/data/overlay/var/work /var && + /bin/mount -t tmpfs -o rw,suid,dev,exec,nouser,async,noatime,mode=0777,size=64M tmpfs /tmp && + /bin/mkdir -p /tmp/overlay/etc/upper /tmp/overlay/etc/work \ + /tmp/overlay/home/upper /tmp/overlay/home/work \ + /tmp/overlay/var/upper /tmp/overlay/var/work && + /bin/mount -t overlay overlay -odefaults,noatime,lowerdir=/etc,upperdir=/tmp/overlay/etc/upper,workdir=/tmp/overlay/etc/work /etc && + /bin/mount -t overlay overlay -odefaults,noatime,lowerdir=/home,upperdir=/tmp/overlay/home/upper,workdir=/tmp/overlay/home/work /home && + /bin/mount -t overlay overlay -odefaults,noatime,lowerdir=/var,upperdir=/tmp/overlay/var/upper,workdir=/tmp/overlay/var/work /var && log_end_msg $? ;; *) -- cgit v1.2.3