Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=fw-initramfs.git;a=commitdiff;h=eba1bb15c3bd4ab924b56124b0dc72425eddba28
commit eba1bb15c3bd4ab924b56124b0dc72425eddba28 Author: bouleetbil <bouleet...@frogdev.info> Date: Wed Nov 25 14:54:34 2009 +0000 init *create device into ramfs *don't load all modules by default *for usb boot load usb module *added new messages *fixed switch_root diff --git a/init b/init index 4f7462e..e3fa97c 100755 --- a/init +++ b/init @@ -9,8 +9,6 @@ mount -o remount,rw / >/dev/null 2>&1 echo "/sbin/modprobe" > /proc/sys/kernel/modprobe -#Disable kernel messages from popping onto the screen -echo 0 > /proc/sys/kernel/printk #Clear the screen clear @@ -18,8 +16,34 @@ clear #Create all the symlinks to /bin/busybox busybox --install -s + +# if QUIET is set make the kernel less chatty +[ -n "$QUIET" ] && echo '0' > /proc/sys/kernel/printk + #Create device nodes -mknod /dev/tty c 5 0 +good_msg "Creating dev" +# /dev will be the only writable place for this initrd if it's cramfs, so +# we will also use /dev to store some info temporarily. Laster we will clean +# those temp files. +mkdir -p /dev +mount -t tmpfs -n -o nr_inodes=24576,mode=0755 none /dev +good_msg "Creating root device" +mknod -m 700 /dev/root b 1 0 +mknod /dev/console c 5 1 +mknod /dev/null c 1 3 +mknod /dev/zero c 1 5 +mknod /dev/ram b 1 1 +mknod /dev/systty c 4 0 +for i in 1 2 3 4; do mknod -m 666 /dev/tty$i c 4 $i; done +good_msg "Creating random device" +mknod -m 444 /dev/random c 1 8 +mknod -m 644 /dev/urandom c 1 9 +mkdir /dev/pts +mkdir /dev/shm +mkdir /dev/usb +for i in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15; do + mknod /dev/usb/hiddev${i} c 180 $((96+i)) +done #lvm if [ -e /bin/lvm ] @@ -57,6 +81,7 @@ do ;; bootusb) BOOTUSB=1 + SDELAY=10 ;; enc_root\=*) enc_root=$(get_opt $i) @@ -71,6 +96,10 @@ do dolvm) USE_LVM_NORMAL=1 ;; + # Load all modules + loadmodules) + LOADMULES=1 + ;; esac done @@ -78,39 +107,70 @@ done #Mount things needed by this script mount_sysfs +#splash + # Setup hotplugging for firmware loading setup_hotplug -#load modules -load_modules +if [ "${LOADMULES}" -eq '1' ]; +then + load_modules +fi + +#load usb modules +if [ "${BOOTUSB}" -eq '1' ]; +then + for module in $MODULES_USB + do + echo -ne "${BOLD} ::${NORMAL} Scanning for ${module}..." + modprobe ${module} 2>/dev/null 1> /dev/null + if [ $? == 0 ]; then + echo "${module} module loaded" + fi + backup + echo -ne "${NORMAL}" + done +fi #resume #swsusp_resume -# Delay if needed for USB hardware -sdelay - +mkdir -p /sys cd /sys good_msg 'Activating mdev' runmdev +sdelay cd / startVolumes if [ "${BOOTUSB}" -eq '1' ]; then + good_msg "Search USB key" #create mount dir mkdir /key - for a in `find /dev/ -name [sh]???` + for a in `ls /dev/sd* -1` do - mount $a /key + good_msg "Mount $a" + mount $a /key >/dev/null 2>&1 #wait the time to mount usb - sleep 10 + sleep 5 #search the file FrugalMove if [ -e /key/FrugalMove ] then + #good_msg 'Populate dev' + #mount -nvt tmpfs none /key/dev + #mknod -m 622 /key/dev/console c 5 1 + #mknod -m 666 /key/dev/null c 1 3 + #mknod -m 666 /key/dev/zero c 1 5 + #mknod -m 666 /key/dev/ptmx c 5 2 + #mknod -m 666 /key/dev/tty c 5 0 + #mknod -m 444 /key/dev/random c 1 8 + #mknod -m 444 /key/dev/urandom c 1 9 root="${a}" + touch /key/etc/fastboot umount /key 2>/dev/null + good_msg "Using: $a" break fi umount /key 2>/dev/null @@ -129,7 +189,7 @@ fi # Run debug shell if requested rundebugshell -echo -ne "${GOOD}>>${NORMAL}${BOLD} Booting (initramfs)${NORMAL}" +good_msg "Booting (initramfs)" #Mount the root device mount "${root}" /newroot @@ -139,10 +199,26 @@ 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 + + # Reset kernel hotplugging + good_msg "Resetting kernel hotplugging" + echo "" > /proc/sys/kernel/hotplug + + # Umount /sys + good_msg "Unmounting /sys" + umount /sys + + # Umount /dev tree + good_msg "Unmounting /dev" + umount /dev + + # Umount /proc + good_msg "Unmounting /proc" + umount /proc #Switch to the new root and execute init - exec switch_root /newroot "${init}" + cd /newroot + exec switch_root . ${init} fi #This will only be run if the exec above failed _______________________________________________ Frugalware-git mailing list Frugalware-git@frugalware.org http://frugalware.org/mailman/listinfo/frugalware-git