mirror of the now-defunct rocklinux.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
1.6 KiB

  1. #!/bin/bash
  2. initrd_mount() { # {{{
  3. dev=${1}
  4. mntpoint=${2}
  5. /sbin/fsck -C -a ${dev}
  6. fsckrc=${?}
  7. if [ ${fsckrc} -eq 8 ] ; then
  8. return 1
  9. fi
  10. if [ $(( ${fsckrc} & ~3 )) != 0 ] ; then
  11. echo " **"
  12. echo " ** Filesystem ${dev} || error=${?} failed (returncode=${fsckrc})."
  13. echo " ** Please repair the broken disk(s) manually."
  14. echo " **"
  15. exec /bin/bash
  16. elif [ $(( ${fsckrc} & 2 )) != 0 ] ; then
  17. echo " **"
  18. echo " ** fsck has requested the system to be rebooted."
  19. echo " ** Running a shell."
  20. echo " **"
  21. echo
  22. exec /bin/bash
  23. fi
  24. mount -n ${dev} ${mntpoint}
  25. return ${?}
  26. } # }}}
  27. PATH="/sbin:/usr/sbin:/bin/:/usr/bin"
  28. rootfs=""
  29. rootfsmounted=0
  30. mount -n -t tmpfs none /tmp
  31. mount -n -t proc none /proc
  32. mount -n -t sysfs none /sys
  33. mount -n -t ramfs none /dev
  34. /sbin/udevstart
  35. /sbin/udevd --daemon
  36. cd /dev
  37. rm -rf fd
  38. ln -sf /proc/self/fd
  39. mkdir -p pts shm
  40. cd /
  41. while read dev mntpoint fstype options fsck1 fsck2 ; do
  42. [ "${mntpoint}" == "/" ] && rootfs=${dev}
  43. [ -n "${rootfs}" ] && break
  44. done < /etc/fstab
  45. echo "loading kernel modules"
  46. . /etc/conf/kernel
  47. for x in /etc/conf/* ; do
  48. [ "${x}" == "/etc/conf/kernel" ] && continue
  49. echo "Running ${x} ..."
  50. . ${x}
  51. done
  52. if [ ${rootfsmounted} -eq 0 ] ; then
  53. echo "Mounting rootfs (${rootfs}) on /root"
  54. initrd_mount ${rootfs} /root
  55. rootfsmounted=1
  56. fi
  57. echo "starting init in /root"
  58. echo "parameters passed to init: ${@}"
  59. cd /root
  60. mkdir -p /root/initrd
  61. mount -n --move /tmp /root/tmp
  62. mount -n --move /proc /root/proc
  63. mount -n --move /sys /root/sys
  64. mount -n --move /dev /root/dev
  65. /sbin/pivot_root . initrd
  66. exec chroot . /sbin/init "${@}"