aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/initrd.txt
diff options
context:
space:
mode:
Diffstat (limited to 'Documentation/initrd.txt')
-rw-r--r--Documentation/initrd.txt74
1 files changed, 46 insertions, 28 deletions
diff --git a/Documentation/initrd.txt b/Documentation/initrd.txt
index 15f1b35deb34..d3dc505104da 100644
--- a/Documentation/initrd.txt
+++ b/Documentation/initrd.txt
@@ -27,16 +27,20 @@ When using initrd, the system typically boots as follows:
27 1) the boot loader loads the kernel and the initial RAM disk 27 1) the boot loader loads the kernel and the initial RAM disk
28 2) the kernel converts initrd into a "normal" RAM disk and 28 2) the kernel converts initrd into a "normal" RAM disk and
29 frees the memory used by initrd 29 frees the memory used by initrd
30 3) initrd is mounted read-write as root 30 3) if the root device is not /dev/ram0, the old (deprecated)
31 4) /linuxrc is executed (this can be any valid executable, including 31 change_root procedure is followed. see the "Obsolete root change
32 mechanism" section below.
33 4) root device is mounted. if it is /dev/ram0, the initrd image is
34 then mounted as root
35 5) /sbin/init is executed (this can be any valid executable, including
32 shell scripts; it is run with uid 0 and can do basically everything 36 shell scripts; it is run with uid 0 and can do basically everything
33 init can do) 37 init can do).
34 5) linuxrc mounts the "real" root file system 38 6) init mounts the "real" root file system
35 6) linuxrc places the root file system at the root directory using the 39 7) init places the root file system at the root directory using the
36 pivot_root system call 40 pivot_root system call
37 7) the usual boot sequence (e.g. invocation of /sbin/init) is performed 41 8) init execs the /sbin/init on the new root filesystem, performing
38 on the root file system 42 the usual boot sequence
39 8) the initrd file system is removed 43 9) the initrd file system is removed
40 44
41Note that changing the root directory does not involve unmounting it. 45Note that changing the root directory does not involve unmounting it.
42It is therefore possible to leave processes running on initrd during that 46It is therefore possible to leave processes running on initrd during that
@@ -70,7 +74,7 @@ initrd adds the following new options:
70 root=/dev/ram0 74 root=/dev/ram0
71 75
72 initrd is mounted as root, and the normal boot procedure is followed, 76 initrd is mounted as root, and the normal boot procedure is followed,
73 with the RAM disk still mounted as root. 77 with the RAM disk mounted as root.
74 78
75Compressed cpio images 79Compressed cpio images
76---------------------- 80----------------------
@@ -137,11 +141,11 @@ We'll describe the loopback device method:
137 # mkdir /mnt/dev 141 # mkdir /mnt/dev
138 # mknod /mnt/dev/console c 5 1 142 # mknod /mnt/dev/console c 5 1
139 5) copy all the files that are needed to properly use the initrd 143 5) copy all the files that are needed to properly use the initrd
140 environment. Don't forget the most important file, /linuxrc 144 environment. Don't forget the most important file, /sbin/init
141 Note that /linuxrc's permissions must include "x" (execute). 145 Note that /sbin/init's permissions must include "x" (execute).
142 6) correct operation the initrd environment can frequently be tested 146 6) correct operation the initrd environment can frequently be tested
143 even without rebooting with the command 147 even without rebooting with the command
144 # chroot /mnt /linuxrc 148 # chroot /mnt /sbin/init
145 This is of course limited to initrds that do not interfere with the 149 This is of course limited to initrds that do not interfere with the
146 general system state (e.g. by reconfiguring network interfaces, 150 general system state (e.g. by reconfiguring network interfaces,
147 overwriting mounted devices, trying to start already running demons, 151 overwriting mounted devices, trying to start already running demons,
@@ -154,7 +158,7 @@ We'll describe the loopback device method:
154 # gzip -9 initrd 158 # gzip -9 initrd
155 159
156For experimenting with initrd, you may want to take a rescue floppy and 160For experimenting with initrd, you may want to take a rescue floppy and
157only add a symbolic link from /linuxrc to /bin/sh. Alternatively, you 161only add a symbolic link from /sbin/init to /bin/sh. Alternatively, you
158can try the experimental newlib environment [2] to create a small 162can try the experimental newlib environment [2] to create a small
159initrd. 163initrd.
160 164
@@ -163,15 +167,14 @@ boot loaders support initrd. Since the boot process is still compatible
163with an older mechanism, the following boot command line parameters 167with an older mechanism, the following boot command line parameters
164have to be given: 168have to be given:
165 169
166 root=/dev/ram0 init=/linuxrc rw 170 root=/dev/ram0 rw
167 171
168(rw is only necessary if writing to the initrd file system.) 172(rw is only necessary if writing to the initrd file system.)
169 173
170With LOADLIN, you simply execute 174With LOADLIN, you simply execute
171 175
172 LOADLIN <kernel> initrd=<disk_image> 176 LOADLIN <kernel> initrd=<disk_image>
173e.g. LOADLIN C:\LINUX\BZIMAGE initrd=C:\LINUX\INITRD.GZ root=/dev/ram0 177e.g. LOADLIN C:\LINUX\BZIMAGE initrd=C:\LINUX\INITRD.GZ root=/dev/ram0 rw
174 init=/linuxrc rw
175 178
176With LILO, you add the option INITRD=<path> to either the global section 179With LILO, you add the option INITRD=<path> to either the global section
177or to the section of the respective kernel in /etc/lilo.conf, and pass 180or to the section of the respective kernel in /etc/lilo.conf, and pass
@@ -179,7 +182,7 @@ the options using APPEND, e.g.
179 182
180 image = /bzImage 183 image = /bzImage
181 initrd = /boot/initrd.gz 184 initrd = /boot/initrd.gz
182 append = "root=/dev/ram0 init=/linuxrc rw" 185 append = "root=/dev/ram0 rw"
183 186
184and run /sbin/lilo 187and run /sbin/lilo
185 188
@@ -191,7 +194,7 @@ Now you can boot and enjoy using initrd.
191Changing the root device 194Changing the root device
192------------------------ 195------------------------
193 196
194When finished with its duties, linuxrc typically changes the root device 197When finished with its duties, init typically changes the root device
195and proceeds with starting the Linux system on the "real" root device. 198and proceeds with starting the Linux system on the "real" root device.
196 199
197The procedure involves the following steps: 200The procedure involves the following steps:
@@ -217,7 +220,7 @@ must exist before calling pivot_root. Example:
217# mkdir initrd 220# mkdir initrd
218# pivot_root . initrd 221# pivot_root . initrd
219 222
220Now, the linuxrc process may still access the old root via its 223Now, the init process may still access the old root via its
221executable, shared libraries, standard input/output/error, and its 224executable, shared libraries, standard input/output/error, and its
222current root directory. All these references are dropped by the 225current root directory. All these references are dropped by the
223following command: 226following command:
@@ -249,10 +252,6 @@ disk can be freed:
249It is also possible to use initrd with an NFS-mounted root, see the 252It is also possible to use initrd with an NFS-mounted root, see the
250pivot_root(8) man page for details. 253pivot_root(8) man page for details.
251 254
252Note: if linuxrc or any program exec'ed from it terminates for some
253reason, the old change_root mechanism is invoked (see section "Obsolete
254root change mechanism").
255
256 255
257Usage scenarios 256Usage scenarios
258--------------- 257---------------
@@ -264,15 +263,15 @@ as follows:
264 1) system boots from floppy or other media with a minimal kernel 263 1) system boots from floppy or other media with a minimal kernel
265 (e.g. support for RAM disks, initrd, a.out, and the Ext2 FS) and 264 (e.g. support for RAM disks, initrd, a.out, and the Ext2 FS) and
266 loads initrd 265 loads initrd
267 2) /linuxrc determines what is needed to (1) mount the "real" root FS 266 2) /sbin/init determines what is needed to (1) mount the "real" root FS
268 (i.e. device type, device drivers, file system) and (2) the 267 (i.e. device type, device drivers, file system) and (2) the
269 distribution media (e.g. CD-ROM, network, tape, ...). This can be 268 distribution media (e.g. CD-ROM, network, tape, ...). This can be
270 done by asking the user, by auto-probing, or by using a hybrid 269 done by asking the user, by auto-probing, or by using a hybrid
271 approach. 270 approach.
272 3) /linuxrc loads the necessary kernel modules 271 3) /sbin/init loads the necessary kernel modules
273 4) /linuxrc creates and populates the root file system (this doesn't 272 4) /sbin/init creates and populates the root file system (this doesn't
274 have to be a very usable system yet) 273 have to be a very usable system yet)
275 5) /linuxrc invokes pivot_root to change the root file system and 274 5) /sbin/init invokes pivot_root to change the root file system and
276 execs - via chroot - a program that continues the installation 275 execs - via chroot - a program that continues the installation
277 6) the boot loader is installed 276 6) the boot loader is installed
278 7) the boot loader is configured to load an initrd with the set of 277 7) the boot loader is configured to load an initrd with the set of
@@ -291,7 +290,7 @@ different hardware configurations in a single administrative domain. In
291such cases, it is desirable to generate only a small set of kernels 290such cases, it is desirable to generate only a small set of kernels
292(ideally only one) and to keep the system-specific part of configuration 291(ideally only one) and to keep the system-specific part of configuration
293information as small as possible. In this case, a common initrd could be 292information as small as possible. In this case, a common initrd could be
294generated with all the necessary modules. Then, only /linuxrc or a file 293generated with all the necessary modules. Then, only /sbin/init or a file
295read by it would have to be different. 294read by it would have to be different.
296 295
297A third scenario are more convenient recovery disks, because information 296A third scenario are more convenient recovery disks, because information
@@ -337,6 +336,25 @@ This old, deprecated mechanism is commonly called "change_root", while
337the new, supported mechanism is called "pivot_root". 336the new, supported mechanism is called "pivot_root".
338 337
339 338
339Mixed change_root and pivot_root mechanism
340------------------------------------------
341
342In case you did not want to use root=/dev/ram0 to trig the pivot_root mechanism,
343you may create both /linuxrc and /sbin/init in your initrd image.
344
345/linuxrc would contain only the following:
346
347#! /bin/sh
348mount -n -t proc proc /proc
349echo 0x0100 >/proc/sys/kernel/real-root-dev
350umount -n /proc
351
352Once linuxrc exited, the kernel would mount again your initrd as root,
353this time executing /sbin/init. Again, it would be duty of this init
354to build the right environment (maybe using the root= device passed on
355the cmdline) before the final execution of the real /sbin/init.
356
357
340Resources 358Resources
341--------- 359---------
342 360