OpenSDE Packages Database (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
3.3 KiB

  1. #!/bin/sh
  2. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. #
  5. # Filename: package/.../mkinitrd/initrdinit.sh
  6. # Copyright (C) 2006 The OpenSDE Project
  7. # Copyright (C) 2005 - 2006 The T2 SDE Project
  8. #
  9. # More information can be found in the files COPYING and README.
  10. #
  11. # This program is free software; you can redistribute it and/or modify
  12. # it under the terms of the GNU General Public License as published by
  13. # the Free Software Foundation; version 2 of the License. A copy of the
  14. # GNU General Public License can be found in the file COPYING.
  15. # --- SDE-COPYRIGHT-NOTE-END ---
  16. echo "Entering early userspace ..."
  17. PATH=/sbin:/bin
  18. echo "Mounting /dev, /proc and /sys ..."
  19. mount -t tmpfs none /dev
  20. mount -t proc none /proc
  21. mount -t usbfs none /proc/bus/usb
  22. mount -t sysfs none /sys
  23. ln -s /proc/self/fd /dev/fd
  24. if [ ! -c /dev/console ]; then
  25. mknod /dev/console c 5 1
  26. fi
  27. if [ ! -c /dev/null ]; then
  28. mknod /dev/null c 1 3
  29. fi
  30. if [ ! -c /dev/zero ]; then
  31. mknod /dev/zero c 1 5
  32. fi
  33. echo "Populating /dev (u/dev) ..."
  34. udevd --daemon
  35. udevtrigger
  36. echo "Running hotplug++ ..."
  37. /sbin/hotplug++ -synth
  38. echo "Loading additional subsystem and filesystem driver ..."
  39. # hack to be removed
  40. modprobe sbp2
  41. # well some hardcoded help for now ...
  42. modprobe ide-generic
  43. modprobe ide-disk
  44. modprobe ide-cd
  45. modprobe sd_mod
  46. modprobe sr_mod
  47. modprobe sg
  48. # the modular filesystems ...
  49. for x in /lib/modules/*/kernel/fs/{*/,}*.*o ; do
  50. x=${x##*/} ; x=${x%.*o}
  51. modprobe $x
  52. done
  53. echo "Mounting rootfs ..."
  54. # get the root device and init
  55. root="root= `cat /proc/cmdline`" ; root=${root##*root=} ; root=${root%% *}
  56. init="init= `cat /proc/cmdline`" ; init=${init##*init=} ; init=${init%% *}
  57. # try best match / detected rootfs first, all the others thereafter
  58. filesystems=`disktype $root 2>/dev/null |
  59. sed -e '/file system/!d' -e 's/file system.*//' -e 's/ //g' \
  60. -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/' \
  61. -e 's/fat32/vfat/'
  62. sed '1!G ; $p ; h ; d' /proc/filesystems | sed /^nodev/d`
  63. mkdir /rootfs
  64. if [ "$root" ]; then
  65. i=0
  66. while [ $i -le 9 ]; do
  67. for fs in $filesystems ; do
  68. if mount -t $fs $root /rootfs -o ro 2> /dev/null; then
  69. echo "Successfully mounted rootfs as $fs."
  70. # TODO: later on search other places if we want 100% backward compat.
  71. [ "$init" ] || init=/sbin/init
  72. if [ -f /rootfs/$init ]; then
  73. mount -t none /dev -o move /rootfs/dev
  74. mount -t none /proc -o move /rootfs/proc
  75. mount -t none /sys -o move /rootfs/sys
  76. if [ ! -c /rootfs/dev/console ]; then
  77. mknod /rootfs/dev/console c 5 1
  78. fi
  79. if [ ! -c /rootfs/dev/null ]; then
  80. mknod /rootfs/dev/null c 1 3
  81. fi
  82. if [ ! -c /rootfs/dev/zero ]; then
  83. mknod /rootfs/dev/zero c 1 5
  84. fi
  85. if [ ! -c /rootfs/dev/tty ]; then
  86. mknod /rootfs/dev/tty c 5 0
  87. fi
  88. # Before we switch to the real root
  89. # we have to kill udevd
  90. ls -1l /rootfs/proc/*/exe 2> /dev/null | \
  91. sed -n -e "s,.*/proc/\([0-9]*\)/.*udevd.*,kill \1,p" | \
  92. /bin/sh
  93. # enter the systems root
  94. exec switch_root /rootfs $init $*
  95. else
  96. echo "Specified init ($init) does not exist!"
  97. fi
  98. fi
  99. done
  100. [ $(( i++ )) -eq 0 ] && echo "Waiting for root device to become ready ..."
  101. sleep 1
  102. done
  103. fi
  104. echo "Ouhm - some boot problem, but I do not scream. Debug shell:"
  105. exec /bin/sh