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.

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