@fredx181
Hi
I have more progress with re-writing initrd.
There is a overview of changes i made.
Use singe binary /bin/busybox
From fresh busybox-static .deb package i build.
gumanzoy wrote: Fri Apr 11, 2025 6:09 pm
Add busybox-static deb package re-build with enabled: blkid
eject
lspci
busybox-static_1.37.0-4phb_amd64.deb busybox-static_1.37.0-4phb_i386.deb
Not need /cr-initrd/initramfs/lib/ anymore.
But cryptsetup support disabled. Maybe this is disadvantage.
Actual versions of scripts:
/usr/local/sbin/mkinitrd /opt/initramfs/finit /opt/initramfs/linuxrc
And /opt/initramfs/modlist trimmed (remove unused modules)
Major changes for initrd and folder structure: viewtopic.php?p=147260#p147260
grub.cfg and extgrub.cfg.example updated.
GitHub Commit bf642db Unload unused kernel/drivers/mmc (cardreader) modules
Now try to unload unused ata_ and mmc kernel modules before unmount devices. To keep modules for existing drives loaded.
Re-write code to mount -o move
or umount
devices.
Depending on changes= used or not, and copy2ram / noauto cheatcodes.
Code: Select all
# Create /mnt/home symlink
if [ "$BOOTDEV" ] && [ -d "$BOOTDEV" ]; then
ln -snf $BOOTDEV /union/mnt/home
elif [ -d "$DATADEV" ]; then
ln -snf $DATADEV /union/mnt/home
fi
# Create /mnt/saved symlink
if [ -d /memory/images/changes-exit ]; then
ln -snf /mnt/live/memory/images/changes-exit /union/mnt/saved
else
ln -snf /mnt/live/memory/changes /union/mnt/saved
fi
MNTPOINTS=`grep /mnt/ /etc/fstab | cut -d" " -f2`
[ -d /mnt/nfs ] && MNTPOINTS="/mnt/nfs $MNTPOINTS"
[ -d /mnt/isoloop ] && MNTPOINTS="/mnt/isoloop $MNTPOINTS"
if [ $CHNDEV ] && [ -d $CHNDEV ]; then
MNTPOINTS="$CHNDEV $MNTPOINTS"
fi
# Move mountpoints /mnt/XX to /union/mnt/XX
for MNTDEV in $MNTPOINTS
do mkdir -p /union"$MNTDEV"
if [ "$MNTDEV" = "$CHNDEV" ]; then
if [ "$CHNEXIT" ] && param copy2ram ; then
mount -o move "$MNTDEV" /union"$MNTDEV" # && umount /union"$MNTDEV" 2>/dev/null
continue
else
mount -o move "$MNTDEV" /union"$MNTDEV"
continue # keep CHNDEV mounted
fi
elif [ "$MNTDEV" = "$DATADEV" -o "$MNTDEV" = "$BOOTDEV" ]; then
if param noauto && param copy2ram ; then
umount "$MNTDEV" 2>/dev/null || mount -o move "$MNTDEV" /union"$MNTDEV"
else
mount -o move "$MNTDEV" /union"$MNTDEV"
fi
continue
fi
param noauto && umount "$MNTDEV" 2>/dev/null || mount -o move "$MNTDEV" /union"$MNTDEV"
done
# Remove unused /mnt/XX dir's
rmdir /mnt/* 2>/dev/null
And also symlinks /mnt/home
and /mnt/saved
creation moved to linuxrc, /usr/local/bin/mountlink
removed.
This in GitHub Commit 157cf4b Update opt/initramfs scripts
And as you can see i update messages with color variables instead of directly writing codes.
Code: Select all
echo "${YELLOW}from= cheatcode is incorrect, press enter to search through all devices${RST}"
Next GitHub Commit aa5542e Update initramfs/linuxrc (re-write chroot part)
Re-write last part of linuxrc - pivot_root, exec chroot
Make it more compact. Support only merged-usr but possible to change it slightly to support non-merged-usr too.
Code: Select all
echo "${i}changing root directory"
if [ -x /union/usr/sbin/init ]; then
cp -f /union/usr/sbin/init /bin
INIT=init
elif [ -x /union/usr/lib/systemd/systemd ]; then
cp -f /union/usr/lib/systemd/systemd /bin
INIT=systemd
fi
if [ -x /bin/$INIT ]; then
mkdir -p /union/mnt/live
echo "${BOLD}live system is ready now - starting Debian${RST}"
pivot_root /union /union/mnt/live
exec /mnt/live/bin/chroot . /mnt/live/bin/$INIT "$@" <dev/console >dev/console 2>&1
else
echo "${RED}ERROR Something went wrong. Press Ctrl+Alt+Del to reboot.${RST}"
sh
fi
Last, huge part GitHub Commit 5507eda Upd opt/initramfs scripts (re-write changes= code)
Re-write changes= and pfull= code
De-duplicate it. Make it more easy to understand (for me
).
This will be enabled in next v0006 phb_test .iso
I will do 2 versions: first 64bit only. and second 64+32 combined in one .iso
I will build and upload it soon to make new initrd available for testing.
Later i will modify fstab() function in finit to mount all partitions read-only, and then re-mount rw if changes= used, or noauto cheatcode not used.
Changes for ntfs ro driver in my To Do list for next test .iso:
gumanzoy wrote: Fri Apr 18, 2025 10:07 pm
Changes (with ntfs) currently not tested. Maybe this option can work after do some more modifications to linuxrc.
PocketHandyBox 64bit Kernel 5.10 Copy2RAM changes=EXIT:/phb/changes.dat