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 rm -rf preos
mkdir -p preos/boot mkdir -p preos/boot
./create_initramfs.sh > preos/boot/initramfs initramfs=preos/boot/initramfs
./create_initramfs.sh > "$initramfs"
./add_kernel_isolinux.sh preos ./add_kernel_isolinux.sh preos
./copy_bin_with_libs.sh preos ./copy_bin_with_libs.sh preos
./create_iso.sh preos preos.iso ./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 done
cd "${initramfs_dir}" cd "${initramfs_dir}"
find . | cpio -H newc -o | gzip
rm -rf "${initramfs_dir}" # Add Arch Linux initramfs with kernel modules included
zcat /boot/initramfs-linux-fallback.img | cpio -i
exit 0
# TODO: # TODO:
# - Kernel modules
# - ssh # - ssh
# - various mkfs # - various mkfs
# - libs # - 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 mknod /dev/tty c 5 0
mdev -s mdev -s
#Function for parsing command line options with "=" in them # udev stuff
# get_opt("init=/sbin/init") will return "/sbin/init" kmod static-nodes --format=tmpfiles --output=/run/tmpfiles.d/kmod.conf
get_opt() { systemd-tmpfiles --prefix=/dev --create --boot
echo "$@" | cut -d "=" -f 2 /usr/lib/systemd/systemd-udevd --daemon --resolve-names=never
} udevadm trigger --action=add --type=subsystems
udevadm trigger --action=add --type=devices
#Defaults udevadm settle
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
exec sh 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