initrd.txt 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. This document describes one way to create the initrd directory hierarchy
  2. in order to allow an initrd to be built into your kernel. The trick
  3. here is to steal the initrd file used on your Linux laptop, Ubuntu in
  4. this case. There are probably much better ways of doing this.
  5. That said, here are the commands:
  6. ------------------------------------------------------------------------
  7. zcat /initrd.img > /tmp/initrd.img.zcat
  8. mkdir initrd
  9. cd initrd
  10. cpio -id < /tmp/initrd.img.zcat
  11. ------------------------------------------------------------------------
  12. Interestingly enough, if you are running rcutorture, you don't really
  13. need userspace in many cases. Running without userspace has the
  14. advantage of allowing you to test your kernel independently of the
  15. distro in place, the root-filesystem layout, and so on. To make this
  16. happen, put the following script in the initrd's tree's "/init" file,
  17. with 0755 mode.
  18. ------------------------------------------------------------------------
  19. #!/bin/sh
  20. [ -d /dev ] || mkdir -m 0755 /dev
  21. [ -d /root ] || mkdir -m 0700 /root
  22. [ -d /sys ] || mkdir /sys
  23. [ -d /proc ] || mkdir /proc
  24. [ -d /tmp ] || mkdir /tmp
  25. mkdir -p /var/lock
  26. mount -t sysfs -o nodev,noexec,nosuid sysfs /sys
  27. mount -t proc -o nodev,noexec,nosuid proc /proc
  28. # Some things don't work properly without /etc/mtab.
  29. ln -sf /proc/mounts /etc/mtab
  30. # Note that this only becomes /dev on the real filesystem if udev's scripts
  31. # are used; which they will be, but it's worth pointing out
  32. if ! mount -t devtmpfs -o mode=0755 udev /dev; then
  33. echo "W: devtmpfs not available, falling back to tmpfs for /dev"
  34. mount -t tmpfs -o mode=0755 udev /dev
  35. [ -e /dev/console ] || mknod --mode=600 /dev/console c 5 1
  36. [ -e /dev/kmsg ] || mknod --mode=644 /dev/kmsg c 1 11
  37. [ -e /dev/null ] || mknod --mode=666 /dev/null c 1 3
  38. fi
  39. mkdir /dev/pts
  40. mount -t devpts -o noexec,nosuid,gid=5,mode=0620 devpts /dev/pts || true
  41. mount -t tmpfs -o "nosuid,size=20%,mode=0755" tmpfs /run
  42. mkdir /run/initramfs
  43. # compatibility symlink for the pre-oneiric locations
  44. ln -s /run/initramfs /dev/.initramfs
  45. # Export relevant variables
  46. export ROOT=
  47. export ROOTDELAY=
  48. export ROOTFLAGS=
  49. export ROOTFSTYPE=
  50. export IP=
  51. export BOOT=
  52. export BOOTIF=
  53. export UBIMTD=
  54. export break=
  55. export init=/sbin/init
  56. export quiet=n
  57. export readonly=y
  58. export rootmnt=/root
  59. export debug=
  60. export panic=
  61. export blacklist=
  62. export resume=
  63. export resume_offset=
  64. export recovery=
  65. for i in /sys/devices/system/cpu/cpu*/online
  66. do
  67. case $i in
  68. '/sys/devices/system/cpu/cpu0/online')
  69. ;;
  70. '/sys/devices/system/cpu/cpu*/online')
  71. ;;
  72. *)
  73. echo 1 > $i
  74. ;;
  75. esac
  76. done
  77. while :
  78. do
  79. sleep 10
  80. done