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.

76 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 tmpfs /tmp
  31. mount -n -t proc proc /proc
  32. mount -n -t sysfs sysfs /sys
  33. mount -n -t ramfs ramfs /dev
  34. /sbin/udevstart
  35. cd /dev
  36. rm -rf fd
  37. ln -sf /proc/self/fd
  38. mkdir -p pts shm
  39. cd /
  40. while read dev mntpoint fstype options fsck1 fsck2 ; do
  41. [ "${mntpoint}" == "/" ] && rootfs=${dev}
  42. [ -n "${rootfs}" ] && break
  43. done < /etc/fstab
  44. echo "loading kernel modules"
  45. . /etc/conf/kernel
  46. for x in /etc/conf/* ; do
  47. [ "${x}" == "/etc/conf/kernel" ] && continue
  48. echo "Running ${x} ..."
  49. . ${x}
  50. done
  51. if [ ${rootfsmounted} -eq 0 ] ; then
  52. echo "Mounting rootfs (${rootfs}) on /root"
  53. initrd_mount ${rootfs} /root
  54. rootfsmounted=1
  55. fi
  56. echo "starting init in /root"
  57. echo "parameters passed to init: ${@}"
  58. cd /root
  59. mkdir -p /root/initrd
  60. mount -n --move /tmp /root/tmp
  61. mount -n --move /proc /root/proc
  62. mount -n --move /sys /root/sys
  63. mount -n --move /dev /root/dev
  64. /sbin/pivot_root . initrd
  65. exec chroot . /sbin/init "${@}"