X-Git-Url: http://git.tremily.us/?a=blobdiff_plain;f=generic%2Flinuxrc;h=8d5976e5117aaa2fb87cd10353a6cc1e78db61a6;hb=c4e37560598d4dc59ef3619084f3822df71e8aef;hp=6c352e7af2ce2da5bb469debf511fb699f2b95bc;hpb=5f847e97f2992fb388f5cba9444b460ae900cc8a;p=genkernel.git diff --git a/generic/linuxrc b/generic/linuxrc index 6c352e7..8d5976e 100644 --- a/generic/linuxrc +++ b/generic/linuxrc @@ -23,6 +23,21 @@ fi mount -o remount,rw / mount -t proc proc /proc +if [ "$0" = '/init' ] +then + /bin/busybox --install -s + rm /linuxrc + if [ -e /sbin/udev ] + then + ln -s /sbin/udev /sbin/udevstart + fi + + if [ -e /bin/lvm ] + then + ln -s /bin/lvm /bin/vgscan + ln -s /bin/lvm /bin/vgchange + fi +fi [ -n "$QUIET" ] && echo '0' > /proc/sys/kernel/printk CMDLINE=`cat /proc/cmdline` @@ -154,12 +169,12 @@ startVolumes() { if [ "${DO_lvm2}" -a "${USE_LVM2_NORMAL}" -eq '1' ] then - if [ -e '/sbin/vgscan' -a -e '/sbin/vgchange' ] + if [ -e '/bin/vgscan' -a -e '/bin/vgchange' ] then echo -e "${GOOD}>>${NORMAL}${BOLD} Scanning for Volume Groups...${NORMAL}" - /sbin/vgscan + /bin/vgscan --ignorelockingfailure --mknodes echo -e "${GOOD}>>${NORMAL}${BOLD} Activating Volume Groups...${NORMAL}" - /sbin/vgchange -ay + /bin/vgchange -ay --ignorelockingfailure fi fi @@ -176,7 +191,7 @@ startVolumes() { echo -e "${GOOD}>>${NORMAL}${BOLD} Mounting filesystems${NORMAL}" # Check udev is on... -[ "${KMAJOR}" -eq 2 -a "${KMINOR}" -ge '6' -a ! "${USE_UDEV_SUPPORT}" -eq '0' ] && USE_UDEV_SUPPORT=1 +[ "${KMAJOR}" -eq 2 -a "${KMINOR}" -ge '6' -a ! "${USE_UDEV_NORMAL}" -eq '0' ] && USE_UDEV_NORMAL=1 [ "${USE_UDEV_NORMAL}" -eq '1' -a ! -x /sbin/udev ] && USE_UDEV_NORMAL=0 # If using 2.4 and udev; back off... @@ -206,6 +221,7 @@ then runUdev startVolumes mv /dev/* /newroot/dev + cd / else if [ ! -e /newroot/dev/.devfsd ] then @@ -274,6 +290,12 @@ then fi chooseKeymap [ "${DEVBIND}" -eq '1' ] && umount /dev + + if [ -e /etc/sysconfig/keyboard -a "${CDROOT}" -eq '1' ] + then + mkdir -p /newroot/etc/sysconfig/ + cp /etc/sysconfig/keyboard /newroot/etc/sysconfig/keyboard + fi fi # FIX: indent me in one $CDROOT -eq '0' @@ -292,6 +314,7 @@ then cd /sys echo -e "${GOOD}>>${NORMAL}${BOLD} Activating udev...${NORMAL}" runUdev + cd / elif [ "${CDROOT}" -eq '0' -a "${USE_DEVFS_NORMAL}" -eq '1' ] then [ ! -e /dev/.devfsd ] && mount -t devfs devfs /dev @@ -463,52 +486,96 @@ else mkdir -p /newroot/tmp/.initrd fi -[ ! -e /newroot/dev/console ] && mknod /newroot/dev/console c 5 1 -echo -ne "${GOOD}>>${NORMAL}${BOLD} Booting" +if [ "$0" = '/linuxrc' ] +then + [ ! -e /newroot/dev/console ] && mknod /newroot/dev/console c 5 1 + echo -ne "${GOOD}>>${NORMAL}${BOLD} Booting" -cd /newroot -mkdir /newroot/proc /newroot/sys 2>/dev/null -pivot_root . tmp/.initrd -echo -n '.' + cd /newroot + mkdir /newroot/proc /newroot/sys 2>/dev/null + pivot_root . tmp/.initrd + echo -n '.' -if /tmp/.initrd/bin/[ "${USE_DEVFS_NORMAL}" -eq '1' -a "${CDROOT}" -eq '0' ] -then - umount /tmp/.initrd/proc || echo '*: Failed to unmount the initrd /proc!' - mount -n --move /tmp/.initrd/dev dev || echo '*: Failed to move over the /dev tree!' - rm -rf /tmp/.initrd/dev || echo '*: Failed to remove the initrd /dev!' -elif /tmp/.initrd/bin/[ "${USE_UDEV_NORMAL}" -eq '1' ] -then - /tmp/.initrd/bin/[ -e /tmp/.initrd/dev/fd ] && rm /tmp/.initrd/dev/fd - /tmp/.initrd/bin/[ -e /tmp/.initrd/dev/stdin ] && rm /tmp/.initrd/dev/stdin - /tmp/.initrd/bin/[ -e /tmp/.initrd/dev/stdout ] && rm /tmp/.initrd/dev/stdout - /tmp/.initrd/bin/[ -e /tmp/.initrd/dev/stderr ] && rm /tmp/.initrd/dev/stderr - /tmp/.initrd/bin/[ -e /tmp/.initrd/dev/core ] && rm /tmp/.initrd/dev/core - umount /tmp/.initrd/dev || echo '*: Failed to unmount the initrd /dev!' - umount /tmp/.initrd/proc || echo '*: Failed to unmount the initrd /proc!' - umount /tmp/.initrd/sys || echo '*: Failed to unmount the initrd /sys!' -elif /tmp/.initrd/bin/[ "${CDROOT}" -eq '1' ] + if /tmp/.initrd/bin/[ "${USE_DEVFS_NORMAL}" -eq '1' -a "${CDROOT}" -eq '0' ] + then + umount /tmp/.initrd/proc || echo '*: Failed to unmount the initrd /proc!' + mount -n --move /tmp/.initrd/dev dev || echo '*: Failed to move over the /dev tree!' + rm -rf /tmp/.initrd/dev || echo '*: Failed to remove the initrd /dev!' + elif /tmp/.initrd/bin/[ "${USE_UDEV_NORMAL}" -eq '1' ] + then + /tmp/.initrd/bin/[ -e /tmp/.initrd/dev/fd ] && rm /tmp/.initrd/dev/fd + /tmp/.initrd/bin/[ -e /tmp/.initrd/dev/stdin ] && rm /tmp/.initrd/dev/stdin + /tmp/.initrd/bin/[ -e /tmp/.initrd/dev/stdout ] && rm /tmp/.initrd/dev/stdout + /tmp/.initrd/bin/[ -e /tmp/.initrd/dev/stderr ] && rm /tmp/.initrd/dev/stderr + /tmp/.initrd/bin/[ -e /tmp/.initrd/dev/core ] && rm /tmp/.initrd/dev/core + umount /tmp/.initrd/dev || echo '*: Failed to unmount the initrd /dev!' + umount /tmp/.initrd/proc || echo '*: Failed to unmount the initrd /proc!' + umount /tmp/.initrd/sys || echo '*: Failed to unmount the initrd /sys!' + elif /tmp/.initrd/bin/[ "${CDROOT}" -eq '1' ] + then + umount /tmp/.initrd/proc || echo "*: Failed to unmount the initrd /proc!" + umount /dev 2>/dev/null + mount -n --move /tmp/.initrd/dev dev 2>/dev/null + rm -rf /tmp/.initrd/dev || echo '*: Failed to remove the initrd /dev!' + + umount /sys 2>/dev/null + umount /tmp/.initrd/sys 2>/dev/null + fi + echo -n '.' + + # /usr/src/linux/Documentation/initrd.txt + # here's the line it says we should do: + # exec chroot . /sbin/init /dev/console 2>&1 + + exec dev/console 2>&1 + echo '.' + exec chroot . /bin/sh <<- EOF + umount /tmp/.initrd || echo "*: Failed to unmount the initrd!" + /sbin/blockdev --flushbufs /dev/ram0 >/dev/null 2>&1 + exec /sbin/init ${REAL_INIT} +EOF +elif [ "$0" = '/init' ] then - umount /tmp/.initrd/proc || echo "*: Failed to unmount the initrd /proc!" - umount /dev 2>/dev/null - mount -n --move /tmp/.initrd/dev dev 2>/dev/null - rm -rf /tmp/.initrd/dev || echo '*: Failed to remove the initrd /dev!' + [ ! -e /newroot/dev/console ] && mknod /newroot/dev/console c 5 1 + echo -ne "${GOOD}>>${NORMAL}${BOLD} Booting (initramfs method)" + + cd /newroot + mkdir /newroot/proc /newroot/sys 2>/dev/null + echo -n '.' + + if [ "${USE_DEVFS_NORMAL}" -eq '1' -a "${CDROOT}" -eq '0' ] + then + umount /dev || echo '*: Failed to unmount the initrd /dev!' + umount /sys || echo '*: Failed to unmount the initrd /sys!' + umount /proc || echo '*: Failed to unmount the initrd /proc!' + elif [ "${USE_UDEV_NORMAL}" -eq '1' ] + then + umount /dev || echo '*: Failed to unmount the initrd /dev!' + umount /sys || echo '*: Failed to unmount the initrd /sys!' + umount /proc || echo '*: Failed to unmount the initrd /proc!' + elif [ "${CDROOT}" -eq '1' ] + then + umount /dev 2>/dev/null + umount /sys 2>/dev/null + umount /proc || echo "*: Failed to unmount the initrd /proc!" + fi + echo -n '.' + + exec dev/console 2>&1 + echo '.' + + # Cleanup initramfs in the background + # to reclaim initramfs tmpfs memoryspace + INITRAMFS_FILES=`ls /|grep -v newroot` + (sleep 10; cd /; rm -rf ${INITRAMFS_FILES}) & + # End initramfs cleanup + + # Start the real root init + exec chroot . /bin/sh <<- EOF + exec /sbin/init ${REAL_INIT} +EOF - umount /sys 2>/dev/null - umount /tmp/.initrd/sys 2>/dev/null fi -echo -n '.' - -# /usr/src/linux/Documentation/initrd.txt -# here's the line it says we should do: -# exec chroot . /sbin/init /dev/console 2>&1 - -exec dev/console 2>&1 -echo '.' -exec chroot . /bin/sh <<- EOF - umount /tmp/.initrd || echo "*: Failed to unmount the initrd!" - /sbin/blockdev --flushbufs /dev/ram0 >/dev/null 2>&1 - exec /sbin/init ${REAL_INIT} -EOF echo 'A fatal error has probably occured since /sbin/init did not' echo 'boot correctly. Trying to open a shell...'