OpenSDE Framework (without history before r20070)
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.

125 lines
2.8 KiB

  1. #!/bin/sh
  2. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. #
  5. # Filename: target/early/initramfs/init.sh
  6. # Copyright (C) 2007 - 2008 The OpenSDE Project
  7. #
  8. # More information can be found in the files COPYING and README.
  9. #
  10. # This program is free software; you can redistribute it and/or modify
  11. # it under the terms of the GNU General Public License as published by
  12. # the Free Software Foundation; version 2 of the License. A copy of the
  13. # GNU General Public License can be found in the file COPYING.
  14. # --- SDE-COPYRIGHT-NOTE-END ---
  15. export PATH=/usr/bin:/usr/sbin:/bin:/sbin
  16. modules=
  17. root=
  18. mode=
  19. initrd=/sbin/init
  20. NOCOLOR=
  21. initargs="$*"
  22. # read kernel arguments
  23. [ -e /proc/cmdline ] || mount -n -t proc none /proc
  24. set -- $( cat /proc/cmdline )
  25. for x; do
  26. v="${x#*=}"
  27. case "$x" in
  28. root=*) root="$v" ;;
  29. init=*) init="$v" ;;
  30. rw|ro) mode="$x" ;;
  31. modules=*) modules=$( echo "$v" | tr ',' ' ' ) ;;
  32. nocolor) export NOCOLOR=yes ;;
  33. esac
  34. done
  35. . /etc/rc.d/functions.in
  36. banner "Starting Early User Space environment"
  37. title "Mounting /proc and /sys"
  38. check mount -n -t usbfs none /proc/bus/usb
  39. check mount -n -t sysfs none /sys
  40. status
  41. [ -x /bin/dmesg ] && /bin/dmesg -n 3
  42. title "Preparing /dev"
  43. check mount -n -t tmpfs none /dev
  44. check cp -a /lib/udev/devices/* /dev
  45. status
  46. title "Starting udev daemon"
  47. echo "" > /sys/kernel/uevent_helper
  48. check udevd --daemon
  49. status
  50. if [ -x /sbin/modprobe -a -n "$modules" ]; then
  51. title "Preloading requested kernel modules"
  52. for x in $modules; do
  53. echo -n " $x"
  54. check modprobe -q $x
  55. done
  56. status
  57. fi
  58. title "Triggering coldplug"
  59. check udevtrigger
  60. check udevsettle
  61. status
  62. sleep 2
  63. [ -n "$root" ] || echo "No root device defined."
  64. if [ ! -e "$root" -a -s /etc/mdadm.conf ]; then
  65. # try activating software raids
  66. title "Activating RAID devices"
  67. check modprobe md-mod
  68. check udevsettle
  69. check mdadm -As --auto=yes
  70. status
  71. fi
  72. if [ ! -e "$root" -a -d /etc/lvm/archive ]; then
  73. title "Activating LVM devices"
  74. check modprobe dm_mod
  75. check udevsettle
  76. check lvm vgchange -ay
  77. status
  78. fi
  79. if [ -n "$root" ]; then
  80. udevsettle
  81. if [ -e "$root" ]; then
  82. /lib/udev/vol_id "$root" > /tmp/$$.vol_id
  83. . /tmp/$$.vol_id
  84. rm /tmp/$$.vol_id
  85. title "Mounting $root (${ID_FS_TYPE:-unknown}) "
  86. check mount ${ID_FS_TYPE:+-t $ID_FS_TYPE} ${mode:+-o $mode} "$root" /rootfs
  87. status
  88. else
  89. echo "root device ($root) not found on time."
  90. fi
  91. fi
  92. # wait for /sbin/init
  93. while [ ! -x "/rootfs$initrd" ]; do
  94. echo "Please mount root device on /rootfs and exit to continue"
  95. setsid /bin/sh < /dev/console > /dev/console 2> /dev/console
  96. done
  97. title "Cleaning up"
  98. check killall udevd
  99. check mount -t none -o move /dev /rootfs/dev
  100. check mount -t none -o move /sys /rootfs/sys
  101. check mount -t none -o move /proc /rootfs/proc
  102. status
  103. exec switch_root /rootfs "$initrd" "$initargs"