forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/tools/testing/selftests/rcutorture/doc/initrd.txt
....@@ -1,9 +1,11 @@
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.
1
+The rcutorture scripting tools automatically create an initrd containing
2
+a single statically linked binary named "init" that loops over a
3
+very long sleep() call. In both cases, this creation is done by
4
+tools/testing/selftests/rcutorture/bin/mkinitrd.sh.
55
6
-That said, here are the commands:
6
+However, if you don't like the notion of statically linked bare-bones
7
+userspace environments, you might wish to press an existing initrd
8
+into service:
79
810 ------------------------------------------------------------------------
911 cd tools/testing/selftests/rcutorture
....@@ -11,103 +13,4 @@
1113 mkdir initrd
1214 cd initrd
1315 cpio -id < /tmp/initrd.img.zcat
14
-------------------------------------------------------------------------
15
-
16
-Another way to create an initramfs image is using "dracut"[1], which is
17
-available on many distros, however the initramfs dracut generates is a cpio
18
-archive with another cpio archive in it, so an extra step is needed to create
19
-the initrd directory hierarchy.
20
-
21
-Here are the commands to create a initrd directory for rcutorture using
22
-dracut:
23
-
24
-------------------------------------------------------------------------
25
-dracut --no-hostonly --no-hostonly-cmdline --module "base bash shutdown" /tmp/initramfs.img
26
-cd tools/testing/selftests/rcutorture
27
-mkdir initrd
28
-cd initrd
29
-/usr/lib/dracut/skipcpio /tmp/initramfs.img | zcat | cpio -id < /tmp/initramfs.img
30
-------------------------------------------------------------------------
31
-
32
-Interestingly enough, if you are running rcutorture, you don't really
33
-need userspace in many cases. Running without userspace has the
34
-advantage of allowing you to test your kernel independently of the
35
-distro in place, the root-filesystem layout, and so on. To make this
36
-happen, put the following script in the initrd's tree's "/init" file,
37
-with 0755 mode.
38
-
39
-------------------------------------------------------------------------
40
-#!/bin/sh
41
-
42
-[ -d /dev ] || mkdir -m 0755 /dev
43
-[ -d /root ] || mkdir -m 0700 /root
44
-[ -d /sys ] || mkdir /sys
45
-[ -d /proc ] || mkdir /proc
46
-[ -d /tmp ] || mkdir /tmp
47
-mkdir -p /var/lock
48
-mount -t sysfs -o nodev,noexec,nosuid sysfs /sys
49
-mount -t proc -o nodev,noexec,nosuid proc /proc
50
-# Some things don't work properly without /etc/mtab.
51
-ln -sf /proc/mounts /etc/mtab
52
-
53
-# Note that this only becomes /dev on the real filesystem if udev's scripts
54
-# are used; which they will be, but it's worth pointing out
55
-if ! mount -t devtmpfs -o mode=0755 udev /dev; then
56
- echo "W: devtmpfs not available, falling back to tmpfs for /dev"
57
- mount -t tmpfs -o mode=0755 udev /dev
58
- [ -e /dev/console ] || mknod --mode=600 /dev/console c 5 1
59
- [ -e /dev/kmsg ] || mknod --mode=644 /dev/kmsg c 1 11
60
- [ -e /dev/null ] || mknod --mode=666 /dev/null c 1 3
61
-fi
62
-
63
-mkdir /dev/pts
64
-mount -t devpts -o noexec,nosuid,gid=5,mode=0620 devpts /dev/pts || true
65
-mount -t tmpfs -o "nosuid,size=20%,mode=0755" tmpfs /run
66
-mkdir /run/initramfs
67
-# compatibility symlink for the pre-oneiric locations
68
-ln -s /run/initramfs /dev/.initramfs
69
-
70
-# Export relevant variables
71
-export ROOT=
72
-export ROOTDELAY=
73
-export ROOTFLAGS=
74
-export ROOTFSTYPE=
75
-export IP=
76
-export BOOT=
77
-export BOOTIF=
78
-export UBIMTD=
79
-export break=
80
-export init=/sbin/init
81
-export quiet=n
82
-export readonly=y
83
-export rootmnt=/root
84
-export debug=
85
-export panic=
86
-export blacklist=
87
-export resume=
88
-export resume_offset=
89
-export recovery=
90
-
91
-for i in /sys/devices/system/cpu/cpu*/online
92
-do
93
- case $i in
94
- '/sys/devices/system/cpu/cpu0/online')
95
- ;;
96
- '/sys/devices/system/cpu/cpu*/online')
97
- ;;
98
- *)
99
- echo 1 > $i
100
- ;;
101
- esac
102
-done
103
-
104
-while :
105
-do
106
- sleep 10
107
-done
108
-------------------------------------------------------------------------
109
-
110
-References:
111
-[1]: https://dracut.wiki.kernel.org/index.php/Main_Page
112
-[2]: http://blog.elastocloud.org/2015/06/rapid-linux-kernel-devtest-with-qemu.html
113
-[3]: https://www.centos.org/forums/viewtopic.php?t=51621
16
+# Manually verify that initrd contains needed binaries and libraries.