initrd.txt 2.6 KB

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