diff options
Diffstat (limited to 'stage2')
-rw-r--r-- | stage2/01-sys-tweaks/00-packages-nr | 2 | ||||
-rw-r--r-- | stage2/01-sys-tweaks/00-packages-sys-debian | 1 | ||||
-rw-r--r-- | stage2/01-sys-tweaks/00-packages-sys-raspi | 4 | ||||
-rw-r--r-- | stage2/01-sys-tweaks/00-packages-sys-raspi-bullseye | 4 | ||||
-rw-r--r-- | stage2/01-sys-tweaks/00-patches/07-resize-init.diff | 5 | ||||
-rwxr-xr-x | stage2/01-sys-tweaks/01-run.sh | 60 | ||||
-rwxr-xr-x | stage2/01-sys-tweaks/files/boot/sys_arm64_000/cmdline-rootfs_ro.txt | 2 | ||||
-rwxr-xr-x | stage2/01-sys-tweaks/files/boot/sys_arm64_000/cmdline-rootfs_rw.txt | 2 | ||||
-rw-r--r-- | stage2/01-sys-tweaks/files/grub/custom-rootfs_ro.cfg (renamed from stage2/01-sys-tweaks/files/grub/custom.cfg) | 2 | ||||
-rwxr-xr-x | stage2/01-sys-tweaks/files/initramfs/fsck_custom | 2 | ||||
-rwxr-xr-x | stage2/01-sys-tweaks/files/initramfs/loop_rootfs-bottom | 12 | ||||
-rwxr-xr-x | stage2/01-sys-tweaks/files/initramfs/loop_rootfs-premount | 85 | ||||
-rwxr-xr-x | stage2/01-sys-tweaks/files/initramfs/test/reset_initrd.sh | 13 | ||||
-rwxr-xr-x[-rw-r--r--] | stage2/01-sys-tweaks/files/resize2fs_once | 4 | ||||
-rw-r--r-- | stage2/01-sys-tweaks/files/resize2fs_once.service | 15 |
15 files changed, 156 insertions, 57 deletions
diff --git a/stage2/01-sys-tweaks/00-packages-nr b/stage2/01-sys-tweaks/00-packages-nr index fe2145c..5919d70 100644 --- a/stage2/01-sys-tweaks/00-packages-nr +++ b/stage2/01-sys-tweaks/00-packages-nr @@ -1,2 +1,2 @@ #cifs-utils - +lsof diff --git a/stage2/01-sys-tweaks/00-packages-sys-debian b/stage2/01-sys-tweaks/00-packages-sys-debian index b70f274..d8cdf6f 100644 --- a/stage2/01-sys-tweaks/00-packages-sys-debian +++ b/stage2/01-sys-tweaks/00-packages-sys-debian @@ -1,2 +1,3 @@ sysfsutils +xfsprogs grub-pc diff --git a/stage2/01-sys-tweaks/00-packages-sys-raspi b/stage2/01-sys-tweaks/00-packages-sys-raspi index d355fc8..4352d73 100644 --- a/stage2/01-sys-tweaks/00-packages-sys-raspi +++ b/stage2/01-sys-tweaks/00-packages-sys-raspi @@ -9,3 +9,7 @@ libpam-chksshpwd #python3 python3-rpi.gpio python3-gpiozero python-minimal python-rpi.gpio python-gpiozero fake-hwclock +plymouth +plymouth-label +plymouth-themes +rpd-plym-splash diff --git a/stage2/01-sys-tweaks/00-packages-sys-raspi-bullseye b/stage2/01-sys-tweaks/00-packages-sys-raspi-bullseye index 29261f8..e1e0b92 100644 --- a/stage2/01-sys-tweaks/00-packages-sys-raspi-bullseye +++ b/stage2/01-sys-tweaks/00-packages-sys-raspi-bullseye @@ -9,3 +9,7 @@ libpam-chksshpwd python3-minimal python3-rpi.gpio python3-gpiozero #python-minimal python-rpi.gpio python-gpiozero fake-hwclock +plymouth +plymouth-label +plymouth-themes +rpd-plym-splash diff --git a/stage2/01-sys-tweaks/00-patches/07-resize-init.diff b/stage2/01-sys-tweaks/00-patches/07-resize-init.diff deleted file mode 100644 index 8c41357..0000000 --- a/stage2/01-sys-tweaks/00-patches/07-resize-init.diff +++ /dev/null @@ -1,5 +0,0 @@ ---- stage2.orig/rootfs/boot/cmdline.txt -+++ stage2/rootfs/boot/cmdline.txt -@@ -1 +1 @@ --console=serial0,115200 console=tty1 root=ROOTDEV rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait -+console=serial0,115200 console=tty1 root=ROOTDEV rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet init=/usr/lib/raspi-config/init_resize.sh diff --git a/stage2/01-sys-tweaks/01-run.sh b/stage2/01-sys-tweaks/01-run.sh index 98b900d..34cee22 100755 --- a/stage2/01-sys-tweaks/01-run.sh +++ b/stage2/01-sys-tweaks/01-run.sh @@ -10,7 +10,8 @@ sed -i "s/OVERLAY_TMPFS_SIZE/${ROOTFS_RO_OVERLAY_TMPFS_SIZE}/g" "${ROOTFS_DIR}/e install -m 644 files/rotatelog_init_rootfs.service "${ROOTFS_DIR}/lib/systemd/system/" install -m 755 files/rotatelog_init_rootfs "${ROOTFS_DIR}/etc/init.d/" -install -m 755 files/resize2fs_once "${ROOTFS_DIR}/etc/init.d/" +install -m 644 files/resize2fs_once.service "${ROOTFS_DIR}/lib/systemd/system/" +install -m 755 files/resize2fs_once "${ROOTFS_DIR}/etc/init.d/" install -d "${ROOTFS_DIR}/etc/systemd/system/rc-local.service.d" install -m 644 files/ttyoutput.conf "${ROOTFS_DIR}/etc/systemd/system/rc-local.service.d/" @@ -41,12 +42,19 @@ fi on_chroot << EOF if [ "${TARGET_RASPI}" = "1" ]; then systemctl disable hwclock.sh + plymouth-set-default-theme pix + else + # No packages, still make sure + systemctl disable plymouth + systemctl mask plymouth fi - # /boot and ROOT are mounted via our 'loop_rootfs' script - # without having a live mapping in /etc/fstab. - systemctl disable systemd-remount-fs - systemctl mask systemd-remount-fs + if [ "${ROOTFS_RO}" = "1" ] ; then + # /boot and ROOT are mounted via our 'loop_rootfs' script + # without having a live mapping in /etc/fstab. + systemctl disable systemd-remount-fs + systemctl mask systemd-remount-fs + fi systemctl disable rsync systemctl mask rsync @@ -115,10 +123,10 @@ on_chroot << EOF fi done - # Allow this partition to be found by loop_rootfs - touch /boot/loop_rootfs.id - if [ "${ROOTFS_RO}" = "1" ] ; then + # Allow this partition to be found by loop_rootfs + touch /boot/loop_rootfs.id + systemctl disable resize2fs_once systemctl mask resize2fs_once @@ -142,16 +150,18 @@ on_chroot << EOF sed -i -e 's/BUSYBOX=auto/BUSYBOX=y/g;s/COMPRESS=gzip/COMPRESS=lzop/g' /etc/initramfs-tools/initramfs.conf fi + # Adding both codepage 437 (FAT_CODEPAGE) and 850 to be safe, as fsck.vfat may misbehave if [ "${TARGET_RASPI}" = "1" ]; then - KMODULES="squashfs" + KMODULES="nls_cp437 nls_cp850 nls_ascii squashfs fat vfat drm vc4" else - KMODULES="nls_cp437 nls_ascii fat vfat squashfs loop usb-common usbcore libahci ahci libata scsi_mod sd_mod usb-storage" + KMODULES="nls_cp437 nls_cp850 nls_ascii fat vfat squashfs loop usb-common usbcore libahci ahci libata scsi_mod sd_mod usb-storage drm" fi for i in \${KMODULES} ; do echo "\$i" >> /etc/modules echo "\$i" >> /etc/initramfs-tools/modules done else + systemctl unmask resize2fs_once systemctl enable resize2fs_once fi EOF @@ -159,10 +169,12 @@ EOF if [ "${ROOTFS_RO}" = "1" ] ; then if [ "${TARGET_RASPI}" = "1" ]; then install -m 644 files/boot/config-rootfs_ro.txt "${ROOTFS_DIR}/boot/config.txt" - install -m 644 files/boot/config-rootfs_ro.txt "${ROOTFS_DIR}/boot/sys_arm64_000/config.txt" - install -m 644 files/boot/sys_arm64_000/cmdline-rootfs_ro.txt "${ROOTFS_DIR}/boot/sys_arm64_000/cmdline.txt" + install -m 644 files/boot/config-rootfs_ro.txt "${ROOTFS_DIR}/boot/sys_${TARGET_ARCH}_000/config.txt" + install -m 644 files/boot/sys_arm64_000/cmdline-rootfs_ro.txt "${ROOTFS_DIR}/boot/sys_${TARGET_ARCH}_000/cmdline.txt" + sed -i "s/sys_arm64_000/sys_${TARGET_ARCH}_000/g" "${ROOTFS_DIR}/boot/config.txt" + sed -i "s/sys_arm64_000/sys_${TARGET_ARCH}_000/g" "${ROOTFS_DIR}/boot/sys_${TARGET_ARCH}_000/config.txt" else - install -m 644 files/grub/custom.cfg "${ROOTFS_DIR}/boot/grub/custom.cfg" + install -m 644 files/grub/custom-rootfs_ro.cfg "${ROOTFS_DIR}/boot/grub/custom.cfg" sed -i "s/sys_amd64_000/sys_${TARGET_ARCH}_000/g" "${ROOTFS_DIR}/boot/grub/custom.cfg" cp "${ROOTFS_DIR}/boot/grub/custom.cfg" "${ROOTFS_DIR}/boot/sys_${TARGET_ARCH}_000/" sed -i 's/GRUB_DEFAULT=.*$/GRUB_DEFAULT=loop_rootfs/g;s/GRUB_TIMEOUT=.*$/GRUB_TIMEOUT=0/g;s/#GRUB_TERMINAL=.*$/GRUB_TERMINAL=console/g;s/#GRUB_DISABLE_LINUX_UUID=.*$/GRUB_DISABLE_LINUX_UUID=true/g' "${ROOTFS_DIR}/etc/default/grub" @@ -178,7 +190,9 @@ if [ "${ROOTFS_RO}" = "1" ] ; then fi install -m 755 files/initramfs/loop_rootfs-premount "${ROOTFS_DIR}/etc/initramfs-tools/scripts/init-premount/loop_rootfs" - sed -i 's/sys_arm64_000/sys_${TARGET_ARCH}_000/g' "${ROOTFS_DIR}/etc/initramfs-tools/scripts/init-premount/loop_rootfs" + sed -i "s/sys_arm64_000/sys_${TARGET_ARCH}_000/g" "${ROOTFS_DIR}/etc/initramfs-tools/scripts/init-premount/loop_rootfs" + sed -i "s/BOOT_FSTYPE=.*$/BOOT_FSTYPE=${BOOT_FSTYPE}/g" "${ROOTFS_DIR}/etc/initramfs-tools/scripts/init-premount/loop_rootfs" + sed -i "s/BOOT_FSOPTIONS=.*$/BOOT_FSOPTIONS=${BOOT_FSOPTIONS}/g" "${ROOTFS_DIR}/etc/initramfs-tools/scripts/init-premount/loop_rootfs" if [ "${TARGET_RASPI}" != "1" ]; then sed -i 's/USES_RASPI_CONFIG=1/USES_RASPI_CONFIG=0/g' "${ROOTFS_DIR}/etc/initramfs-tools/scripts/init-premount/loop_rootfs" fi @@ -188,8 +202,8 @@ if [ "${ROOTFS_RO}" = "1" ] ; then else if [ "${TARGET_RASPI}" = "1" ]; then install -m 644 files/boot/config-rootfs_rw.txt "${ROOTFS_DIR}/boot/config.txt" - install -m 644 files/boot/config-rootfs_rw.txt "${ROOTFS_DIR}/boot/sys_arm64_000/config.txt" - install -m 644 files/boot/sys_arm64_000/cmdline-rootfs_rw.txt "${ROOTFS_DIR}/boot/sys_arm64_000/cmdline.txt" + install -m 644 files/boot/config-rootfs_rw.txt "${ROOTFS_DIR}/boot/sys_${TARGET_ARCH}_000/config.txt" + install -m 644 files/boot/sys_arm64_000/cmdline-rootfs_rw.txt "${ROOTFS_DIR}/boot/sys_${TARGET_ARCH}_000/cmdline.txt" fi fi @@ -210,8 +224,10 @@ on_chroot <<EOF setupcon --force --save-only -v usermod --pass='*' root + KVERSION=\$(ls /lib/modules/ | tail -n 1) if [ "${ROOTFS_RO}" = "1" ]; then - KVERSION=\$(ls /lib/modules/ | tail -n 1) + rm -f /boot/sys_${TARGET_ARCH}_000/initrd.img + if [ "${TARGET_RASPI}" = "1" ]; then echo "mkinitramfs for kernel version: \${KVERSION}" /usr/sbin/mkinitramfs -o /boot/sys_${TARGET_ARCH}_000/initrd.img \${KVERSION} @@ -235,10 +251,18 @@ on_chroot <<EOF find /boot/ -maxdepth 1 -type f \ -exec cp -d --preserve=all \{\} /data/sdcard/ \; cp -a /boot/sys_${TARGET_ARCH}_000 /data/sdcard/ + else + if [ "${TARGET_RASPI}" != "1" ]; then + update-initramfs -u -k \${KVERSION} + fi fi if [ "${TARGET_RASPI}" != "1" ]; then update-grub - grub-install --force-file-id --modules="gzio part_msdos fat" /dev/${NBD_DEV} + if [ "${ROOTFS_RO}" = "1" ] ; then + grub-install --force-file-id --modules="gzio part_msdos fat" /dev/${NBD_DEV} + else + grub-install --force-file-id --modules="gzio part_msdos fat ext2" /dev/${NBD_DEV} + fi # Remove storage device related 'search.fs_uuid' and allow multi homing rm -f /boot/grub/i386-pc/load.cfg diff --git a/stage2/01-sys-tweaks/files/boot/sys_arm64_000/cmdline-rootfs_ro.txt b/stage2/01-sys-tweaks/files/boot/sys_arm64_000/cmdline-rootfs_ro.txt index 015beb1..6218f03 100755 --- a/stage2/01-sys-tweaks/files/boot/sys_arm64_000/cmdline-rootfs_ro.txt +++ b/stage2/01-sys-tweaks/files/boot/sys_arm64_000/cmdline-rootfs_ro.txt @@ -1 +1 @@ -dwc_otg.lpm_enable=0 console=tty3 root=file elevator=deadline fsck.repair=no rootwait quiet +dwc_otg.lpm_enable=0 console=tty3 root=file ro elevator=deadline fsck.repair=no loglevel=3 logo.nologo splash quiet plymouth.ignore-serial-consoles vt.global_cursor_default=0 diff --git a/stage2/01-sys-tweaks/files/boot/sys_arm64_000/cmdline-rootfs_rw.txt b/stage2/01-sys-tweaks/files/boot/sys_arm64_000/cmdline-rootfs_rw.txt index c321838..42962cc 100755 --- a/stage2/01-sys-tweaks/files/boot/sys_arm64_000/cmdline-rootfs_rw.txt +++ b/stage2/01-sys-tweaks/files/boot/sys_arm64_000/cmdline-rootfs_rw.txt @@ -1 +1 @@ -dwc_otg.lpm_enable=0 console=tty3 root=ROOTDEV rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet +dwc_otg.lpm_enable=0 console=tty3 root=ROOTDEV rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait loglevel=3 logo.nologo splash quiet plymouth.ignore-serial-consoles vt.global_cursor_default=0 diff --git a/stage2/01-sys-tweaks/files/grub/custom.cfg b/stage2/01-sys-tweaks/files/grub/custom-rootfs_ro.cfg index 7ba9eea..16157f6 100644 --- a/stage2/01-sys-tweaks/files/grub/custom.cfg +++ b/stage2/01-sys-tweaks/files/grub/custom-rootfs_ro.cfg @@ -3,7 +3,7 @@ menuentry 'Debian GNU/Linux loop_rootfs' --id loop_rootfs { insmod part_msdos insmod fat echo 'Loading Linux ...' - linux /sys_amd64_000/vmlinuz root=file ro quiet + linux /sys_amd64_000/vmlinuz console=tty3 root=file ro elevator=none fsck.repair=no echo 'Loading initial ramdisk ...' initrd /sys_amd64_000/initrd.img } diff --git a/stage2/01-sys-tweaks/files/initramfs/fsck_custom b/stage2/01-sys-tweaks/files/initramfs/fsck_custom index 133d26e..4fbc1c4 100755 --- a/stage2/01-sys-tweaks/files/initramfs/fsck_custom +++ b/stage2/01-sys-tweaks/files/initramfs/fsck_custom @@ -21,7 +21,7 @@ fi . /usr/share/initramfs-tools/scripts/functions . /usr/share/initramfs-tools/hook-functions -fsck_types="ext4 squashfs vfat" +fsck_types="xfs ext4 ext2 vfat" copy_exec /sbin/fsck copy_exec /sbin/logsave diff --git a/stage2/01-sys-tweaks/files/initramfs/loop_rootfs-bottom b/stage2/01-sys-tweaks/files/initramfs/loop_rootfs-bottom index e852b57..73e1121 100755 --- a/stage2/01-sys-tweaks/files/initramfs/loop_rootfs-bottom +++ b/stage2/01-sys-tweaks/files/initramfs/loop_rootfs-bottom @@ -16,8 +16,20 @@ esac . /scripts/functions +. /conf/param.conf + readonly BOOT_DIR="/mnt/boot" +# cleanup logging jobs +if [ -n "${LOOP_ROOTFS_LOG_PIDS}" ]; then + for i in ${LOOP_ROOTFS_LOG_PIDS} ; do + if [ -d "/proc/${i}" ]; then + kill $i + fi + done +fi +echo "LOOP_ROOTFS_LOG_PIDS=\"\"" >> /conf/param.conf + # move BOOT_DIR to the rootfs; fall back to util-linux mount that does # not understand -o move mount -n -o move ${BOOT_DIR} "${rootmnt:?}/boot" || mount -n --move ${BOOT_DIR} "${rootmnt}/boot" diff --git a/stage2/01-sys-tweaks/files/initramfs/loop_rootfs-premount b/stage2/01-sys-tweaks/files/initramfs/loop_rootfs-premount index 7805e17..3b0b5bc 100755 --- a/stage2/01-sys-tweaks/files/initramfs/loop_rootfs-premount +++ b/stage2/01-sys-tweaks/files/initramfs/loop_rootfs-premount @@ -21,7 +21,11 @@ esac . /scripts/functions -readonly BOOT_FSTYPE="vfat" +# codepage is hardcoded in 'loop_rootfs' and scripts, as well as required by pi-gen build +# Note: fsck.vfat '-c ${FAT_CODEPAGE}' leads to usage page despite being a valid argument, using 850 for fsck.vfat only. +readonly FAT_CODEPAGE="437" +readonly BOOT_FSTYPE=vfat +readonly BOOT_FSOPTIONS=rw,noatime,fmask=0022,dmask=0022,codepage=${FAT_CODEPAGE},iocharset=ascii,shortname=mixed,errors=remount-ro readonly BOOT_DIR="/mnt/boot" readonly USES_RASPI_CONFIG=1 @@ -85,6 +89,10 @@ mylog_warning_msg() { _mylog "Warning: %s\\n" "$*" } +mylog_info_msg() { + _mylog "Info: %s\\n" "$*" +} + mylog_begin_msg() { _mylog "Begin: %s ... " "$*" } @@ -95,16 +103,17 @@ mylog_end_msg() { find_partition_base() { local fstype_exp="$1" - local mnt_dir="$2" - local file_exp="$3" - local blkparts=$(lsblk -l | grep part | cut -d" " -f1) + local mnt_opts="$2" + local mnt_dir="$3" + local file_exp="$4" + local blkparts=$(lsblk -l | grep part | cut -d" " -f1 | tr '\n' ' ') local part_dev="" if [ -z "${blkparts}" ]; then # May take some time on PC's after loading device modules (usb, ..) local blkpartwait=180 - mylog_warning_msg "Waiting up to ${blkpartwait} seconds for block devices to become online ..." + mylog_info_msg "Waiting up to ${blkpartwait} seconds for block devices to become online ..." while [ "$(time_elapsed)" -lt "$blkpartwait" ]; do - blkparts=$(lsblk -l | grep part | cut -d" " -f1) + blkparts=$(lsblk -l | grep part | cut -d" " -f1 | tr '\n' ' ') if [ -n "${blkparts}" ]; then break fi @@ -122,15 +131,43 @@ find_partition_base() { if [ "${fs_type}" = "${fstype_exp}" ]; then part_dev="/dev/$i" # force fix verbose fseek, using undocumented options '-f', '-y' - if ! fsck -f -y -V -t ${fs_type} "${part_dev}" >&2 ; then - mylog_warning_msg "The ${fs_type} filesystem on ${part_dev} seems to require a manual fsck, continuing" + case ${fs_type} in + xfs) + # a NOP + mylog_info_msg "Running: fsck.xfs ${part_dev}" + fsck.xfs ${part_dev} >&2 + ;; + ext4) + mylog_info_msg "Running: fsck.ext4 -p ${part_dev}" + fsck.ext4 -p ${part_dev} >&2 + ;; + ext2) + mylog_info_msg "Running: fsck.ext2 -p ${part_dev}" + fsck.ext2 -p ${part_dev} >&2 + ;; + vfat) + # Note: fsck.vfat '-c ${FAT_CODEPAGE}' leads to usage page despite being a valid argument, using 850 for fsck.vfat only. + # mylog_info_msg "Running: fsck.vfat -a -w -c ${FAT_CODEPAGE} ${part_dev}" + # fsck.vfat -a -w -c ${FAT_CODEPAGE} ${part_dev} >&2 + mylog_info_msg "Running: fsck.vfat -a -w ${part_dev}" + fsck.vfat -a -w ${part_dev} >&2 + ;; + *) + mylog_info_msg "Running: fsck -f -y -t ${fs_type} ${part_dev}" + fsck -f -y -t ${fs_type} ${part_dev} >&2 + ;; + esac + if [ $? -ne 0 ]; then + mylog_warning_msg "fsck ${fs_type}: Filesystem on ${part_dev} seems to require a manual fsck, continuing" + else + mylog_success_msg "fsck ${fs_type}: Filesystem on ${part_dev} OK" fi - if ! mount -t ${fs_type} ${part_dev} ${mnt_dir} >&2 ; then - mylog_warning_msg "Could not mount ${fs_type} from ${part_dev} on ${mnt_dir}, continuing." + if ! mount -t ${fs_type} -o ${mnt_opts} ${part_dev} ${mnt_dir} >&2 ; then + mylog_warning_msg "Could not mount ${fs_type} with '${mnt_opts}' from ${part_dev} on ${mnt_dir}, continuing." part_dev="" continue fi - mylog_success_msg "Mounted ${fs_type} from ${part_dev} on ${mnt_dir} ..." + mylog_success_msg "Mounted ${fs_type} with '${mnt_opts}' from ${part_dev} on ${mnt_dir} ..." if [ -f "${mnt_dir}/${file_exp}" ] ; then mylog_success_msg "Found "${mnt_dir}/${file_exp}" on mounted ${fs_type} from ${part_dev}, done!" break @@ -145,13 +182,13 @@ find_partition_base() { } find_partition() { - local part_dev=$(find_partition_base "$1" "$2" "$3") + local part_dev=$(find_partition_base $*) if [ -z "${part_dev}" ]; then # May take some time on PC's after loading device modules (usb, ..) local blkpartwait=180 - mylog_warning_msg "Retrying up to ${blkpartwait} seconds finding ${BOOT_FSTYPE} partition for ${BOOT_DIR} ..." + mylog_info_msg "Retrying up to ${blkpartwait} seconds finding ${BOOT_FSTYPE} partition for ${BOOT_DIR} ..." while [ "$(time_elapsed)" -lt "$blkpartwait" ]; do - part_dev=$(find_partition_base "$1" "$2" "$3") + part_dev=$(find_partition_base $*) if [ -n "${part_dev}" ]; then break fi @@ -177,11 +214,12 @@ check_fsfile() { fi mylog_success_msg "Image file ${fsfile} of type ${FILE_FSTYPE}." - if ! fsck -n -V -t "${FILE_FSTYPE}" "${fsfile}"; then - mylog_failure_msg "Image file ${fsfile} fsck failed." + mylog_info_msg "Running: fsck -f -y -t ${FILE_FSTYPE} ${fsfile}" + if ! fsck -f -y -t ${FILE_FSTYPE} ${fsfile} >&2 ; then + mylog_failure_msg "fsck ${FILE_FSTYPE}: Image file ${fsfile} fsck failed." return 1 fi - mylog_success_msg "Image file ${fsfile} fsck OK." + mylog_success_msg "fsck ${fs_type}: Image file ${fsfile} OK" if [ "${FILE_FSTYPE}" = "squashfs" ]; then if ! unsquashfs -l "${fsfile}" > /dev/null ; then @@ -297,20 +335,21 @@ fallback_rootfs() { tee_date() { ( while IFS= read -p -r line; do - printf '%s %s\n' "$(date -u +"%Y-%m-%d %H:%M:%S")" "$line" + printf '%s %s\n' "$(/usr/bin/date -u +"%Y-%m-%d %H:%M:%S")" "$line" done ) | tee -a $1 } add_date() { ( while IFS= read -r line; do - printf '%s %s\n' "$(date -u +"%Y-%m-%d %H:%M:%S")" "$line" + printf '%s %s\n' "$(/usr/bin/date -u +"%Y-%m-%d %H:%M:%S")" "$line" done ) >> $1 } +LOOP_ROOTFS_LOG_PIDS="" mylog_begin_msg "loop_rootfs" mkdir -p ${BOOT_DIR} -BOOT_PART=$(find_partition ${BOOT_FSTYPE} ${BOOT_DIR} "loop_rootfs.id") +BOOT_PART=$(find_partition ${BOOT_FSTYPE} ${BOOT_FSOPTIONS} ${BOOT_DIR} "loop_rootfs.id") if [ "${ROOT}" != "file" ]; then mylog_success_msg "Skip loop for non file ROOT ${ROOT}" @@ -336,6 +375,7 @@ if [ -f ${BOOT_DIR}/init_debug.log ]; then fi if [ -f /run/initramfs/initramfs.debug ]; then add_date ${BOOT_DIR}/init_debug.log < /run/initramfs/initramfs.debug & + LOOP_ROOTFS_LOG_PIDS="${LOOP_ROOTFS_LOG_PIDS} $!" fi quiet_orig="${quiet}" @@ -360,6 +400,8 @@ else tee_date ${BOOT_DIR}/init_rootfs.log < "${FIFO_OUT}" & # tee_date ${BOOT_DIR}/init_rootfs.log < "${FIFO_ERR}" >&2 & fi +LOOP_ROOTFS_LOG_PIDS="${LOOP_ROOTFS_LOG_PIDS} $!" + exec >${FIFO_OUT} 2>&1 if [ "${USES_RASPI_CONFIG}" = "1" ]; then @@ -445,6 +487,9 @@ if ! attach_rootfs "${IMAGE_FILE}"; then exit 1 fi +LOOP_ROOTFS_LOG_PIDS=${LOOP_ROOTFS_LOG_PIDS##*( )} +echo "LOOP_ROOTFS_LOG_PIDS=\"${LOOP_ROOTFS_LOG_PIDS}\"" >> /conf/param.conf + mylog_success_msg "Attached ${OS_PREFIX}, ${ROOTFSTYPE} file ${IMAGE_FILE} to loop-device ${ROOT}." mylog_end_msg diff --git a/stage2/01-sys-tweaks/files/initramfs/test/reset_initrd.sh b/stage2/01-sys-tweaks/files/initramfs/test/reset_initrd.sh index 77b2f0a..17fb1ca 100755 --- a/stage2/01-sys-tweaks/files/initramfs/test/reset_initrd.sh +++ b/stage2/01-sys-tweaks/files/initramfs/test/reset_initrd.sh @@ -1,10 +1,9 @@ #!/bin/sh -set -x +#dest="root@zaf502" +dest="root@virtl09" -cd /etc/initramfs-tools/ -cp /home/pi/loop_rootfs scripts/init-premount/loop_rootfs -mkinitramfs -o /home/pi/initrd.img 5.10.17-v8+ -cp /home/pi/initrd.img /boot/sys_arm64_000/initrd.img -cp /home/pi/initrd.img /boot/sys_arm64_001/initrd.img -sync +scp extra_execs ${dest}:/etc/initramfs-tools/hooks/ +scp loop_rootfs-bottom ${dest}:/etc/initramfs-tools/scripts/init-bottom/loop_rootfs +scp loop_rootfs-premount ${dest}:/etc/initramfs-tools/scripts/init-premount/loop_rootfs +echo mkinitramfs -o /boot/sys_arm64_000/initrd.img 5.10.17-v8+ diff --git a/stage2/01-sys-tweaks/files/resize2fs_once b/stage2/01-sys-tweaks/files/resize2fs_once index 0754f2c..f8e45a6 100644..100755 --- a/stage2/01-sys-tweaks/files/resize2fs_once +++ b/stage2/01-sys-tweaks/files/resize2fs_once @@ -1,9 +1,9 @@ #!/bin/sh ### BEGIN INIT INFO # Provides: resize2fs_once -# Required-Start: +# Required-Start: mountkernfs # Required-Stop: -# Default-Start: 3 +# Default-Start: S # Default-Stop: # Short-Description: Resize the root filesystem to fill partition # Description: diff --git a/stage2/01-sys-tweaks/files/resize2fs_once.service b/stage2/01-sys-tweaks/files/resize2fs_once.service new file mode 100644 index 0000000..0c755a8 --- /dev/null +++ b/stage2/01-sys-tweaks/files/resize2fs_once.service @@ -0,0 +1,15 @@ +[Unit] +Description=Resize the root filesystem to fill partition +DefaultDependencies=no +After=systemd-udevd.service +Before=systemd-remount-fs.service systemd-random-seed.service systemd-journald.service local-fs-pre.target sysinit.target + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=/etc/init.d/resize2fs_once start + +[Install] +WantedBy=systemd-remount-fs.service +Alias=resize2fs_once.service + |