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.

126 lines
3.4 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. echo "" > /sys/kernel/uevent_helper
  35. udevd --daemon
  36. echo "Triggering coldplug ..."
  37. udevtrigger
  38. udevsettle
  39. echo "Loading additional subsystem and filesystem driver ..."
  40. # hack to be removed
  41. #modprobe sbp2
  42. # well some hardcoded help for now ...
  43. #modprobe ide-generic
  44. #modprobe ide-disk
  45. #modprobe ide-cd
  46. #modprobe sd_mod
  47. #modprobe sr_mod
  48. #modprobe sg
  49. # the modular filesystems ...
  50. for x in /lib/modules/*/kernel/fs/{*/,}*.*o ; do
  51. x=${x##*/} ; x=${x%.*o}
  52. modprobe $x
  53. done
  54. echo "Mounting rootfs ..."
  55. # get the root device and init
  56. root="root= `cat /proc/cmdline`" ; root=${root##*root=} ; root=${root%% *}
  57. init="init= `cat /proc/cmdline`" ; init=${init##*init=} ; init=${init%% *}
  58. # try best match / detected rootfs first, all the others thereafter
  59. filesystems=`disktype $root 2>/dev/null |
  60. sed -e '/file system/!d' -e 's/file system.*//' -e 's/ //g' \
  61. -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/' \
  62. -e 's/fat32/vfat/'
  63. sed '1!G ; $p ; h ; d' /proc/filesystems | sed /^nodev/d`
  64. mkdir /rootfs
  65. if [ "$root" ]; then
  66. i=0
  67. while [ $i -le 9 ]; do
  68. for fs in $filesystems ; do
  69. if mount -t $fs $root /rootfs -o ro 2> /dev/null; then
  70. echo "Successfully mounted rootfs as $fs."
  71. # TODO: later on search other places if we want 100% backward compat.
  72. [ "$init" ] || init=/sbin/init
  73. if [ -f /rootfs/$init ]; then
  74. mount -t none /dev -o move /rootfs/dev
  75. mount -t none /proc -o move /rootfs/proc
  76. mount -t none /sys -o move /rootfs/sys
  77. if [ ! -c /rootfs/dev/console ]; then
  78. mknod /rootfs/dev/console c 5 1
  79. fi
  80. if [ ! -c /rootfs/dev/null ]; then
  81. mknod /rootfs/dev/null c 1 3
  82. fi
  83. if [ ! -c /rootfs/dev/zero ]; then
  84. mknod /rootfs/dev/zero c 1 5
  85. fi
  86. if [ ! -c /rootfs/dev/tty ]; then
  87. mknod /rootfs/dev/tty c 5 0
  88. fi
  89. # Before we switch to the real root
  90. # we have to kill udevd
  91. ls -1l /rootfs/proc/*/exe 2> /dev/null | \
  92. sed -n -e "s,.*/proc/\([0-9]*\)/.*udevd.*,kill \1,p" | \
  93. /bin/sh
  94. # enter the systems root
  95. exec switch_root /rootfs $init $*
  96. else
  97. echo "Specified init ($init) does not exist!"
  98. fi
  99. fi
  100. done
  101. [ $(( i++ )) -eq 0 ] && echo "Waiting for root device to become ready ..."
  102. sleep 1
  103. done
  104. fi
  105. echo "Ouhm - some boot problem, but I do not scream. Debug shell:"
  106. exec /bin/sh