rcutorture: Add KVM-based test framework
[platform/adaptation/renesas_rcar/renesas_kernel.git] / tools / testing / selftests / rcutorture / doc / initrd.txt
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
6 That said, here are the commands:
7
8 ------------------------------------------------------------------------
9 zcat /initrd.img > /tmp/initrd.img.zcat
10 mkdir initrd
11 cd initrd
12 cpio -id < /tmp/initrd.img.zcat
13 ------------------------------------------------------------------------
14
15 Interestingly enough, if you are running rcutorture, you don't really
16 need userspace in many cases.  Running without userspace has the
17 advantage of allowing you to test your kernel independently of the
18 distro in place, the root-filesystem layout, and so on.  To make this
19 happen, put the following script in the initrd's tree's "/init" file,
20 with 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
30 mkdir -p /var/lock
31 mount -t sysfs -o nodev,noexec,nosuid sysfs /sys
32 mount -t proc -o nodev,noexec,nosuid proc /proc
33 # Some things don't work properly without /etc/mtab.
34 ln -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
38 if ! 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
44 fi
45
46 mkdir /dev/pts
47 mount -t devpts -o noexec,nosuid,gid=5,mode=0620 devpts /dev/pts || true
48 mount -t tmpfs -o "nosuid,size=20%,mode=0755" tmpfs /run
49 mkdir /run/initramfs
50 # compatibility symlink for the pre-oneiric locations
51 ln -s /run/initramfs /dev/.initramfs
52
53 # Export relevant variables
54 export ROOT=
55 export ROOTDELAY=
56 export ROOTFLAGS=
57 export ROOTFSTYPE=
58 export IP=
59 export BOOT=
60 export BOOTIF=
61 export UBIMTD=
62 export break=
63 export init=/sbin/init
64 export quiet=n
65 export readonly=y
66 export rootmnt=/root
67 export debug=
68 export panic=
69 export blacklist=
70 export resume=
71 export resume_offset=
72 export recovery=
73
74 for i in /sys/devices/system/cpu/cpu*/online
75 do
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
85 done
86
87 while :
88 do
89         sleep 10
90 done