From 9ad28406002855cde33b7abdd0a816b8af3ed0ac Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 15 Jun 2015 21:57:48 +0200 Subject: [PATCH] Working PreOS without SSH Signed-off-by: Nico Schottelius --- hacking/v3-busybox/all.sh | 25 +++++++++++++- hacking/v3-busybox/create_initramfs.sh | 14 +++++--- hacking/v3-busybox/init | 47 ++++---------------------- 3 files changed, 40 insertions(+), 46 deletions(-) diff --git a/hacking/v3-busybox/all.sh b/hacking/v3-busybox/all.sh index 65a3706b..563d093a 100755 --- a/hacking/v3-busybox/all.sh +++ b/hacking/v3-busybox/all.sh @@ -3,7 +3,30 @@ rm -rf preos mkdir -p preos/boot -./create_initramfs.sh > preos/boot/initramfs +initramfs=preos/boot/initramfs + +./create_initramfs.sh > "$initramfs" ./add_kernel_isolinux.sh preos ./copy_bin_with_libs.sh preos ./create_iso.sh preos preos.iso + +exit 0 + +run_earlyhook() { + kmod static-nodes --format=tmpfiles --output=/run/tmpfiles.d/kmod.conf + systemd-tmpfiles --prefix=/dev --create --boot + /usr/lib/systemd/systemd-udevd --daemon --resolve-names=never + udevd_running=1 +} + +run_hook() { + msg ":: Triggering uevents..." + udevadm trigger --action=add --type=subsystems + udevadm trigger --action=add --type=devices + udevadm settle +} + +run_cleanuphook() { + udevadm control --exit + udevadm info --cleanup-db +} diff --git a/hacking/v3-busybox/create_initramfs.sh b/hacking/v3-busybox/create_initramfs.sh index f87a7ef6..77606374 100755 --- a/hacking/v3-busybox/create_initramfs.sh +++ b/hacking/v3-busybox/create_initramfs.sh @@ -18,15 +18,19 @@ for link in sh mount; do done cd "${initramfs_dir}" -find . | cpio -H newc -o | gzip -rm -rf "${initramfs_dir}" - -exit 0 +# Add Arch Linux initramfs with kernel modules included +zcat /boot/initramfs-linux-fallback.img | cpio -i # TODO: -# - Kernel modules # - ssh # - various mkfs # - libs +# Create new initramfs +find . | cpio -H newc -o | gzip + +# echo ${initramfs_dir} +rm -rf "${initramfs_dir}" + +exit 0 diff --git a/hacking/v3-busybox/init b/hacking/v3-busybox/init index a961526f..2c6d747a 100755 --- a/hacking/v3-busybox/init +++ b/hacking/v3-busybox/init @@ -16,46 +16,13 @@ mknod /dev/null c 1 3 mknod /dev/tty c 5 0 mdev -s -#Function for parsing command line options with "=" in them -# get_opt("init=/sbin/init") will return "/sbin/init" -get_opt() { - echo "$@" | cut -d "=" -f 2 -} - -#Defaults -init="/sbin/init" -root="/dev/hda1" - -#Process command line options -for i in $(cat /proc/cmdline); do - case $i in - root\=*) - root=$(get_opt $i) - ;; - init\=*) - init=$(get_opt $i) - ;; - esac -done +# udev stuff +kmod static-nodes --format=tmpfiles --output=/run/tmpfiles.d/kmod.conf +systemd-tmpfiles --prefix=/dev --create --boot +/usr/lib/systemd/systemd-udevd --daemon --resolve-names=never +udevadm trigger --action=add --type=subsystems +udevadm trigger --action=add --type=devices +udevadm settle exec sh - -# Skipping the rest - -#Mount the root device -mount "${root}" /newroot - -#Check if $init exists and is executable -if [[ -x "/newroot/${init}" ]] ; then - #Unmount all other mounts so that the ram used by - #the initramfs can be cleared after switch_root - umount /sys /proc - - #Switch to the new root and execute init - exec switch_root /newroot "${init}" -fi - -#This will only be run if the exec above failed -echo "Failed to switch_root, dropping to a shell" -exec sh