#!/bin/sh [ -d /dev ] || mkdir -m 0755 /dev [ -d /root ] || mkdir -m 0700 /root [ -d /sys ] || mkdir /sys [ -d /proc ] || mkdir /proc [ -d /tmp ] || mkdir /tmp mkdir -p /var/lock mount -t sysfs -o nodev,noexec,nosuid none /sys mount -t proc -o nodev,noexec,nosuid none /proc grep -q '\' /proc/cmdline || echo "Loading, please wait..." # Note that this only becomes /dev on the real filesystem if udev's scripts # are used; which they will be, but it's worth pointing out if ! mount -t devtmpfs -o mode=0755 none /dev; then mount -t tmpfs -o mode=0755 none /dev mknod -m 0600 /dev/console c 5 1 mknod /dev/null c 1 3 fi mkdir /dev/pts mount -t devpts -o noexec,nosuid,gid=5,mode=0620 none /dev/pts || true > /dev/.initramfs-tools mkdir /dev/.initramfs # Export the dpkg architecture export DPKG_ARCH= . /conf/arch.conf # Set modprobe env export MODPROBE_OPTIONS="-qb" # Export relevant variables export ROOT= export ROOTDELAY= export ROOTFLAGS= export ROOTFSTYPE= export IPOPTS= export HWADDR= export break= export init=/sbin/init export quiet=n export readonly=y export rootmnt=/root export debug= export panic= export blacklist= export resume_offset= # Bring in the main config . /conf/initramfs.conf . /scripts/functions if [ -z "${noresume}" ]; then export resume=${RESUME} else export noresume fi [ -n "${netconsole}" ] && modprobe netconsole netconsole=${netconsole} # export BOOT variable value for compcache, # so we know if we run from casper export BOOT # Don't do log messages here to avoid confusing usplash run_scripts /scripts/init-top log_begin_msg "Loading essential drivers..." load_modules log_end_msg [ "$quiet" != "y" ] && log_begin_msg "Running /scripts/init-premount" run_scripts /scripts/init-premount [ "$quiet" != "y" ] && log_end_msg [ -d /mnt ] || mkdir -m 0755 /mnt echo ========================== echo "Please wait until all the device you want to boot is recognized and then push ENTER key." echo ========================== read a deviceslist=$(blkid|cut -d: -f1) okdeviceslist="" for a in $deviceslist do umount -l /mnt 2>/dev/null mount -t auto $a /mnt 2>/dev/null || continue if [ -e /mnt/vmlinuz -a -e /mnt/initrd.img ] then okdeviceslist="${okdeviceslist} $a" elif [ -n "$(ls /mnt/boot/ -1 2>/dev/null|grep vmlinuz)" ] then if [ -e /mnt/boot/initrd*$(ls /mnt/boot -1 2>/dev/null|grep vmlinuz|tail -n1|cut -c9- 2>/dev/null)* ] then okdeviceslist="${okdeviceslist} $a" fi fi umount -l /mnt 2>/dev/null done i=0 echo ========================== echo "The device file names and information of partitions will be recognized and are shown below." echo for a in ${okdeviceslist} do echo $i":"$(blkid|grep "${a}:") i=$(expr $i + 1) done echo echo "Please type the number of the device file name of the root partition of Ubuntu you want to boot." readloop() { while [ a = a ] do read a if [ $a -ge 0 ] then if [ $? = 1 ] then echo "Please type number" continue elif [ $a -lt "$(echo $*|tr ' ' '\n'|wc -l)" ] then break else echo "Please type number smaller than $(echo $*|tr ' ' '\n'|wc -l)" continue fi echo "Please type number larger than 0 or 0" fi done } readloop "${okdeviceslist}" device=$(echo ${okdeviceslist}|cut -d" " -f $(expr $a + 1)) echo "You selected $a:$device" mount -t auto $device /mnt echo "If you want to search Grub settings, please type y" echo "If you want to get into busybox, please type zzz" read a fakemore () { step=$1 num=1 ln=$(wc -l $2 |sed "s/^[^0-9]*//"|sed "s/[^0-9]*$//") while [ $num -lt $ln ] do sed -n "$num,$(expr $num + $step) p" $2 read -p "## Please enter q to quit displaying: " b if [ a"$b" = "aq" ] then break fi num=$(expr $num + $step + 1) done return } if [ -n "$(echo $a|grep y)" ] then if [ -e /mnt/boot/grub/grub.cfg ] then echo "/boot/grub/grub.cfg (GRUB2 settings file) is found. Please push any key to show its contents." read b fakemore 10 /mnt/boot/grub/grub.cfg fi if [ -e /mnt/boot/grub/menu.lst ] then echo "GRUB legacy settings file /boot/grub/menu.lst is found." echo "Please enter q to skip showing its content. Please input any other to show its contents." read b if [ "a$b" != "aq" ] then fakemore 10 /mnt/boot/grub/menu.lst fi fi if [ -e /mnt/menu.lst ] then echo "GRUB legacy settings file /menu.lst is found." echo "Please enter q to skip showing its content. Please input any other to show its contents." read b if [ "a$b" != "aq" ] then fakemore 10 /mnt/menu.lst fi fi fi if [ -n "$(echo $a|grep zzz)" ] then PS1='(kiyoChelp) ' /bin/sh -i /dev/console 2>&1 fi echo "======================================" echo "The following kernels seems to be available." kernels1=$(ls /mnt/boot/ -1|grep vmlinuz) kernels="" i=0 for a in $kernels1 do if [ -n "$(ls -1 /mnt/boot/initrd*$(echo $a|cut -c9-))*" ] then echo $i":"$(echo $kernels1|cut -d" " -f $(expr $i + 1)) i=$(expr $i + 1) kernels="$kernels $a" fi done echo "Please type the number of the kernel you want to boot." readloop "${kernels}" kernel=$(echo ${kernels}|cut -d" " -f $(expr $a + 1)) echo "You selected $a:$kernel" echo "The following option is suggested to pass to the kernel:" echo "root=UUID=$(blkid|grep "$device:"|sed -e "s/^.*UUID=\"//"|sed -e "s/\".*//") ro" echo "" echo "Please enter commandline parameter to pass to kernel." echo "If you accept the suggested option, please type nothing." read a if [ -n "$a" ] then kexec -l /mnt/boot/$kernel --append="$a" --initrd=$(ls /mnt/boot/initrd*$(echo $kernel|cut -c9-)*|tail -n1) kexec -e else kexec -l /mnt/boot/$kernel --append="root=UUID=$(blkid|grep "$device:"|sed -e "s/^.*UUID=\"//"|sed -e "s/\".*//") ro" --initrd=$(ls /mnt/boot/initrd*$(echo $kernel|cut -c9-)*|tail -n1) kexec -e fi umount -l /mnt echo "DAMESSU! I will try to make you use terminal" PS1='(kiyoChelp) ' /bin/sh -i /dev/console 2>&1 echo "Please reboot by pressing CTRL+ALT+DEL or ATL+SysRq+R,S,E,I,U,B" exec run-init ${rootmnt} ${init} "$@" <${rootmnt}/dev/console >${rootmnt}/dev/console 2>&1 panic "Could not execute run-init."