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