--- trunk/mkinitrd-magellan/mkinitrd.in 2011/09/07 17:46:29 1515 +++ trunk/mkinitrd-magellan/mkinitrd.in 2012/04/02 11:40:49 1793 @@ -754,7 +754,16 @@ add_initrd 'mount -t proc proc /proc' add_initrd 'mount -t sysfs sysfs /sys' -add_initrd 'mount -t tmpfs tmpfs /dev -o rw,mode=0644,size=1024' +add_initrd "if [[ -z \$(grep '[[:space:]]/dev[[:space:]]' /proc/mounts | cut -d ' ' -f2) ]]" +add_initrd 'then' +add_initrd ' # many video drivers needed exec access' +add_initrd ' fstype=ramfs' +add_initrd ' # tmpfs was suggested by Greg Kroah-Hartman' +add_initrd " [[ \$(grep '[[:space:]]tmpfs' /proc/filesystems | cut -d \$'\\t' -f2) = tmpfs ]] && fstype=tmpfs" +add_initrd ' # mount devtmpfs if supported' +add_initrd " [[ \$(grep '[[:space:]]devtmpfs' /proc/filesystems | cut -d \$'\\t' -f2) = devtmpfs ]] && fstype=devtmpfs" +add_initrd ' mount -t ${fstype} dev /dev -o exec,nosuid,mode=0755,size=10M' +add_initrd 'fi' [[ ${IMAGE_TYPE} = loopback ]] && add_initrd 'mount -t ramfs -o remount,rw /dev/ram /' @@ -854,13 +863,16 @@ # get the right initexec add_initrd "INITEXEC=\"${INITEXEC}\"" # support init=* from cmdline -add_initrd 'for i in $(cat /proc/cmdline); do if [[ ${i} = init=* ]]; then INITEXEC=${i/init=}; fi; done' +add_initrd 'for i in $(cat /proc/cmdline); do case ${i} in init=*) INITEXEC="${i#*=}";; esac; done' add_initrd 'echo "-- Mounting sysroot ..."' add_initrd '. /etc/rootdev' add_initrd 'echo "${device} /sysroot ${rootfs} defaults,ro 0 0" > /etc/fstab' add_initrd 'mount /sysroot || ash' +# use devtmpfs if supported +add_initrd "if [ \"\$(grep devtmpfs /proc/filesystems | cut -d$'\t' -f2)\" = \"devtmpfs\" ]; then mount -t devtmpfs dev /sysroot/dev;fi" + # unset hotplug event-manager add_initrd 'echo > /proc/sys/kernel/hotplug' @@ -868,13 +880,13 @@ add_initrd 'echo 3 > /proc/sys/kernel/printk' add_initrd 'BREAK_ENABLED=no' -add_initrd 'for i in $(cat /proc/cmdline); do if [[ ${i} = break ]]; then BREAK_ENABLED=yes; fi; done' -add_initrd 'if [[ ${BREAK_ENABLED} = yes ]]; then echo "-- Break requested, type 'exit' to resume operation ..."; ash; fi' +add_initrd 'for i in $(cat /proc/cmdline); do case ${i} in break) BREAK_ENABLED=yes;; esac; done' +add_initrd 'if [ "${BREAK_ENABLED}" = "yes" ]; then echo "-- Break requested, type 'exit' to resume operation ..."; ash; fi' add_initrd 'echo "-- Switching to real sysroot ..."' -add_initrd 'umount /dev' -add_initrd 'umount /sys' -add_initrd 'umount /proc' +add_initrd 'mount --move /dev /sysroot/dev' +add_initrd 'mount --move /sys /sysroot/sys' +add_initrd 'mount --move /proc /sysroot/proc' [[ ${IMAGE_TYPE} = initramfs ]] && add_initrd 'exec run-init /sysroot ${INITEXEC} $@ /sysroot/dev/console' if [[ ${IMAGE_TYPE} = loopback ]]