Working PreOS without SSH

Signed-off-by: Nico Schottelius <nico@wurzel.schottelius.org>
This commit is contained in:
Nico Schottelius 2015-06-15 21:57:48 +02:00
parent 85c825438e
commit 9ad2840600
3 changed files with 40 additions and 46 deletions

View file

@ -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
}

View file

@ -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

View file

@ -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