]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man4/initrd.4
lirc.4: Clarify the description LIRC_SET_REC_TIMEOUT
[thirdparty/man-pages.git] / man4 / initrd.4
CommitLineData
fea681da
MK
1.\" This man-page is Copyright (C) 1997 John S. Kallal
2.\"
93015253 3.\" %%%LICENSE_START(VERBATIM)
fea681da
MK
4.\" Permission is granted to make and distribute verbatim copies of this
5.\" manual provided the copyright notice and this permission notice are
6.\" preserved on all copies.
7.\"
8.\" Permission is granted to copy and distribute modified versions of this
9.\" manual under the conditions for verbatim copying, provided that the
10.\" entire resulting derived work is distributed under the terms of a
11.\" permission notice identical to this one.
c13182ef 12.\"
fea681da
MK
13.\" Since the Linux kernel and libraries are constantly changing, this
14.\" manual page may be incorrect or out-of-date. The author(s) assume no
15.\" responsibility for errors or omissions, or for damages resulting from
16.\" the use of the information contained herein. The author(s) may not
17.\" have taken the same level of care in the production of this manual,
18.\" which is licensed free of charge, as they might when working
19.\" professionally.
c13182ef 20.\"
fea681da
MK
21.\" Formatted or processed versions of this manual, if unaccompanied by
22.\" the source, must acknowledge the copyright and author(s) of this work.
4b72fb64 23.\" %%%LICENSE_END
fea681da
MK
24.\"
25.\" If the you wish to distribute versions of this work under other
c13182ef 26.\" conditions than the above, please contact the author(s) at the following
fea681da 27.\" for permission:
988db661 28.\"
c13182ef 29.\" John S. Kallal -
fea681da
MK
30.\" email: <kallal@voicenet.com>
31.\" mail: 518 Kerfoot Farm RD, Wilmington, DE 19803-2444, USA
32.\" phone: (302)654-5478
c13182ef 33.\"
fea681da 34.\" $Id: initrd.4,v 0.9 1997/11/07 05:05:32 kallal Exp kallal $
4b8c67d9 35.TH INITRD 4 2017-09-15 "Linux" "Linux Programmer's Manual"
fea681da
MK
36.SH NAME
37initrd \- boot loader initialized RAM disk
1351674a 38.SH CONFIGURATION
1351674a
MK
39.I /dev/initrd
40is a read-only block device assigned
41major number 1 and minor number 250.
42Typically
43.I /dev/initrd
44is owned by
45.I root.disk
46with mode 0400 (read access by root only).
47If the Linux system does not have
48.I /dev/initrd
49already created, it can be created with the following commands:
a2b7a144
MK
50.PP
51.in +4n
52.EX
53mknod \-m 400 /dev/initrd b 1 250
54chown root:disk /dev/initrd
55.EE
56.in
1351674a
MK
57.PP
58Also, support for both "RAM disk" and "Initial RAM disk"
15079abb 59(e.g.,
616e3430 60.BR CONFIG_BLK_DEV_RAM=y
c342a49b
MK
61and
62.BR CONFIG_BLK_DEV_INITRD=y )
1351674a 63must be compiled directly into the Linux kernel to use
c342a49b 64.IR /dev/initrd .
1351674a 65When using
c342a49b 66.IR /dev/initrd ,
1351674a
MK
67the RAM disk driver cannot be loaded as a module.
68.\"
69.\"
70.\"
fea681da 71.SH DESCRIPTION
c13182ef
MK
72The special file
73.I /dev/initrd
74is a read-only block device.
b644cdd7
MK
75This device is a RAM disk that is initialized (e.g., loaded)
76by the boot loader before the kernel is started.
77The kernel then can use
c13182ef 78.IR /dev/initrd "'s "
b644cdd7 79contents for a two-phase system boot-up.
fea681da 80.PP
c13182ef 81In the first boot-up phase, the kernel starts up
9ee4a2b6 82and mounts an initial root filesystem from the contents of
c13182ef 83.I /dev/initrd
1930dbe6 84(e.g., RAM disk initialized by the boot loader).
c13182ef
MK
85In the second phase, additional drivers or other modules
86are loaded from the initial root device's contents.
9ee4a2b6
MK
87After loading the additional modules, a new root filesystem
88(i.e., the normal root filesystem) is mounted from a
fea681da
MK
89different device.
90.\"
91.\"
92.\"
73d8cece 93.SS Boot-up operation
c13182ef 94When booting up with
c342a49b
MK
95.BR initrd ,
96the system boots as follows:
c4fd8ad8
MK
97.IP 1. 3
98The boot loader loads the kernel program and
c342a49b
MK
99.IR /dev/initrd 's
100contents into memory.
ea7366cd 101.IP 2.
c4fd8ad8 102On kernel startup,
c13182ef 103the kernel uncompresses and copies the contents of the device
8478ee02 104.I /dev/initrd
c13182ef
MK
105onto device
106.I /dev/ram0
107and then frees the memory used by
c342a49b 108.IR /dev/initrd .
c4fd8ad8 109.IP 3.
b644cdd7 110The kernel then read-write mounts the device
c13182ef 111.I /dev/ram0
9ee4a2b6 112as the initial root filesystem.
c4fd8ad8 113.IP 4.
9ee4a2b6
MK
114If the indicated normal root filesystem is also the initial
115root filesystem (e.g.,
b644cdd7
MK
116.IR /dev/ram0 )
117then the kernel skips to the last step for the usual boot sequence.
c4fd8ad8
MK
118.IP 5.
119If the executable file
c342a49b 120.IR /linuxrc
9ee4a2b6 121is present in the initial root filesystem,
c342a49b 122.I /linuxrc
c13182ef
MK
123is executed with UID 0.
124(The file
8478ee02 125.I /linuxrc
c13182ef
MK
126must have executable permission.
127The file
8478ee02 128.I /linuxrc
c13182ef 129can be any valid executable, including a shell script.)
c4fd8ad8
MK
130.IP 6.
131If
8478ee02 132.I /linuxrc
c13182ef 133is not executed or when
8478ee02 134.I /linuxrc
9ee4a2b6 135terminates, the normal root filesystem is mounted.
fea681da 136(If
0daa9e92 137.I /linuxrc
9ee4a2b6
MK
138exits with any filesystems mounted on the initial root
139filesystem, then the behavior of the kernel is
c342a49b 140.BR UNSPECIFIED .
3d341b33 141See the NOTES section for the current kernel behavior.)
c4fd8ad8 142.IP 7.
9ee4a2b6 143If the normal root filesystem has a directory
c342a49b 144.IR /initrd ,
b644cdd7 145the device
8478ee02 146.I /dev/ram0
c13182ef 147is moved from
c342a49b
MK
148.IR /
149to
150.IR /initrd .
2b9b829d 151Otherwise, if the directory
616e3430 152.IR /initrd
b644cdd7 153does not exist, the device
c342a49b
MK
154.I /dev/ram0
155is unmounted.
c13182ef 156(When moved from
c342a49b 157.IR /
616e3430
MK
158to
159.IR /initrd ,
c342a49b 160.I /dev/ram0
c13182ef 161is not unmounted and therefore processes can remain running from
c342a49b 162.IR /dev/ram0 .
c13182ef 163If directory
0daa9e92 164.I /initrd
9ee4a2b6 165does not exist on the normal root filesystem
c13182ef 166and any processes remain running from
616e3430 167.IR /dev/ram0
c342a49b
MK
168when
169.I /linuxrc
c13182ef 170exits, the behavior of the kernel is
c342a49b 171.BR UNSPECIFIED .
3d341b33 172See the NOTES section for the current kernel behavior.)
c4fd8ad8 173.IP 8.
ade562fb 174The usual boot sequence (e.g., invocation of
8478ee02 175.IR /sbin/init )
9ee4a2b6 176is performed on the normal root filesystem.
c13182ef
MK
177.\"
178.\"
179.\"
c4fd8ad8 180.SS Options
b644cdd7 181The following boot loader options, when used with
c342a49b
MK
182.BR initrd ,
183affect the kernel's boot-up operation:
fea681da
MK
184.TP
185.BI initrd= "filename"
c13182ef 186Specifies the file to load as the contents of
c342a49b 187.IR /dev/initrd .
c10859eb 188For
c13182ef 189.B LOADLIN
76c44d83 190this is a command-line option.
c13182ef
MK
191For
192.B LILO
193you have to use this command in the
194.B LILO
195configuration file
8478ee02 196.IR /etc/lilo.config .
fea681da 197The filename specified with this
9ee4a2b6 198option will typically be a gzipped filesystem image.
fea681da 199.TP
8478ee02 200.I noinitrd
b644cdd7 201This boot option disables the two-phase boot-up operation.
c13182ef
MK
202The kernel performs the usual boot sequence as if
203.I /dev/initrd
204was not initialized.
fea681da 205With this option, any contents of
c13182ef 206.I /dev/initrd
fea681da 207loaded into memory by the boot loader contents are preserved.
c13182ef
MK
208This option permits the contents of
209.I /dev/initrd
9ee4a2b6 210to be any data and need not be limited to a filesystem image.
c13182ef 211However, device
8478ee02 212.I /dev/initrd
fea681da
MK
213is read-only and can be read only one time after system startup.
214.TP
215.BI root= "device-name"
9ee4a2b6 216Specifies the device to be used as the normal root filesystem.
c342a49b
MK
217For
218.B LOADLIN
76c44d83 219this is a command-line option.
c342a49b
MK
220For
221.B LILO
222this is a boot time option or
c13182ef 223can be used as an option line in the
c342a49b 224.B LILO
616e3430 225configuration file
c342a49b 226.IR /etc/lilo.config .
c13182ef 227The device specified by the this option must be a mountable
9ee4a2b6 228device having a suitable root filesystem.
c13182ef
MK
229.\"
230.\"
231.\"
9ee4a2b6 232.SS Changing the normal root filesystem
c13182ef 233By default,
fea681da 234the kernel's settings
ade562fb 235(e.g., set in the kernel file with
8478ee02 236.BR rdev (8)
fea681da
MK
237or compiled into the kernel file),
238or the boot loader option setting
9ee4a2b6
MK
239is used for the normal root filesystems.
240For an NFS-mounted normal root filesystem, one has to use the
616e3430 241.B nfs_root_name
c342a49b
MK
242and
243.B nfs_root_addrs
c13182ef 244boot options to give the NFS settings.
fea681da 245For more information on NFS-mounted root see the kernel documentation file
e7dee047
ES
246.I Documentation/filesystems/nfs/nfsroot.txt
247.\" commit dc7a08166f3a5f23e79e839a8a88849bd3397c32
248(or
249.I Documentation/filesystems/nfsroot.txt
250before Linux 2.6.33).
9ee4a2b6 251For more information on setting the root filesystem see also the
c342a49b
MK
252.BR LILO
253and
2e9cee8a 254.BR LOADLIN
c342a49b 255documentation.
fea681da 256.PP
c13182ef 257It is also possible for the
0daa9e92 258.I /linuxrc
fea681da 259executable to change the normal root device.
c13182ef 260For
0daa9e92 261.I /linuxrc
c13182ef 262to change the normal root device,
616e3430 263.IR /proc
c342a49b 264must be mounted.
c13182ef 265After mounting
c342a49b
MK
266.IR /proc ,
267.I /linuxrc
fea681da 268changes the normal root device by writing into the proc files
616e3430 269.IR /proc/sys/kernel/real-root-dev ,
c342a49b
MK
270.IR /proc/sys/kernel/nfs-root-name ,
271and
272.IR /proc/sys/kernel/nfs-root-addrs .
fea681da 273For a physical root device, the root device is changed by having
0daa9e92 274.I /linuxrc
9ee4a2b6 275write the new root filesystem device number into
c342a49b 276.IR /proc/sys/kernel/real-root-dev .
9ee4a2b6 277For an NFS root filesystem, the root device is changed by having
0daa9e92 278.I /linuxrc
fea681da 279write the NFS setting into files
c342a49b
MK
280.IR /proc/sys/kernel/nfs-root-name
281and
0daa9e92 282.I /proc/sys/kernel/nfs-root-addrs
ade562fb 283and then writing 0xff (e.g., the pseudo-NFS-device number) into file
c342a49b 284.IR /proc/sys/kernel/real-root-dev .
fea681da 285For example, the following shell command line would change
c13182ef 286the normal root device to
8478ee02 287.IR /dev/hdb1 :
a2b7a144
MK
288.PP
289.in +4n
290.EX
291echo 0x365 >/proc/sys/kernel/real-root-dev
292.EE
293.in
294.PP
b644cdd7 295For an NFS example, the following shell command lines would change the
c13182ef 296normal root device to the NFS directory
0daa9e92 297.I /var/nfsroot
c13182ef 298on a local networked NFS server with IP number 193.8.232.7 for a system with
0ab92df8 299IP number 193.8.232.2 and named "idefix":
a2b7a144
MK
300.PP
301.in +4n
302.EX
303echo /var/nfsroot >/proc/sys/kernel/nfs-root-name
304echo 193.8.232.2:193.8.232.7::255.255.255.0:idefix \\
305 >/proc/sys/kernel/nfs-root-addrs
306echo 255 >/proc/sys/kernel/real-root-dev
307.EE
308.in
2dad4c59 309.PP
1a57baf2
MK
310.BR Note :
311The use of
0daa9e92 312.I /proc/sys/kernel/real-root-dev
9ee4a2b6 313to change the root filesystem is obsolete.
66a9882e 314See the Linux kernel source file
96c11b3f
ES
315.I Documentation/admin\-guide/initrd.rst
316.\" commit 9d85025b0418163fae079c9ba8f8445212de8568
317(or
1a57baf2 318.I Documentation/initrd.txt
96c11b3f 319before Linux 4.10)
1a57baf2
MK
320as well as
321.BR pivot_root (2)
322and
323.BR pivot_root (8)
9ee4a2b6 324for information on the modern method of changing the root filesystem.
bea08fec 325.\" FIXME . Should this manual page describe the pivot_root mechanism?
c13182ef
MK
326.\"
327.\"
328.\"
c4fd8ad8 329.SS Usage
c13182ef 330The main motivation for implementing
0daa9e92 331.B initrd
c13182ef 332was to allow for modular kernel configuration at system installation.
fea681da
MK
333.PP
334A possible system installation scenario is as follows:
c4fd8ad8
MK
335.IP 1. 3
336The loader program boots from floppy or other media with a minimal kernel
ade562fb 337(e.g., support for
616e3430 338.IR /dev/ram ,
c342a49b 339.IR /dev/initrd ,
9ee4a2b6 340and the ext2 filesystem) and loads
c342a49b 341.IR /dev/initrd
9ee4a2b6 342with a gzipped version of the initial filesystem.
c4fd8ad8
MK
343.IP 2.
344The executable
0daa9e92 345.I /linuxrc
9ee4a2b6
MK
346determines what is needed to (1) mount the normal root filesystem
347(i.e., device type, device drivers, filesystem) and (2) the
ade562fb 348distribution media (e.g., CD-ROM, network, tape, ...).
b644cdd7
MK
349This can be done by asking the user, by auto-probing,
350or by using a hybrid approach.
c4fd8ad8
MK
351.IP 3.
352The executable
0daa9e92 353.I /linuxrc
9ee4a2b6 354loads the necessary modules from the initial root filesystem.
c4fd8ad8
MK
355.IP 4.
356The executable
0daa9e92 357.I /linuxrc
9ee4a2b6
MK
358creates and populates the root filesystem.
359(At this stage the normal root filesystem does not have to be a
fea681da 360completed system yet.)
c4fd8ad8
MK
361.IP 5.
362The executable
c342a49b
MK
363.IR /linuxrc
364sets
365.IR /proc/sys/kernel/real-root-dev ,
c13182ef 366unmount
c342a49b 367.IR /proc ,
28955f15
SP
368the normal root filesystem and any other filesystems
369it has mounted, and then terminates.
c342a49b 370.IP 6.
9ee4a2b6 371The kernel then mounts the normal root filesystem.
c4fd8ad8 372.IP 7.
9ee4a2b6 373Now that the filesystem is accessible and intact,
fea681da 374the boot loader can be installed.
c4fd8ad8
MK
375.IP 8.
376The boot loader is configured to load into
0daa9e92 377.I /dev/initrd
9ee4a2b6 378a filesystem with the set of modules that was used to bring up the system.
ade562fb 379(e.g., Device
0daa9e92 380.I /dev/ram0
fea681da 381can be modified, then unmounted, and finally, the image is written from
0daa9e92 382.I /dev/ram0
fea681da 383to a file.)
c4fd8ad8
MK
384.IP 9.
385The system is now bootable and additional installation tasks can be
fea681da 386performed.
fea681da 387.PP
c13182ef 388The key role of
0daa9e92 389.I /dev/initrd
3b777aff 390in the above is to reuse the configuration data during normal system operation
fea681da
MK
391without requiring initial kernel selection, a large generic kernel or,
392recompiling the kernel.
393.PP
394A second scenario is for installations where Linux runs on systems with
c13182ef 395different hardware configurations in a single administrative network.
fea681da
MK
396In such cases, it may be desirable to use only a small set of kernels
397(ideally only one) and to keep the system-specific part of configuration
c13182ef
MK
398information as small as possible.
399In this case, create a common file
400with all needed modules.
401Then, only the
8478ee02 402.I /linuxrc
fea681da 403file or a file executed by
8478ee02 404.I /linuxrc
fea681da
MK
405would be different.
406.PP
c13182ef 407A third scenario is more convenient recovery disks.
9ee4a2b6 408Because information like the location of the root filesystem
c13182ef
MK
409partition is not needed at boot time, the system loaded from
410.I /dev/initrd
411can use a dialog and/or auto-detection followed by a
fea681da
MK
412possible sanity check.
413.PP
c13182ef 414Last but not least, Linux distributions on CD-ROM may use
0daa9e92 415.B initrd
c13182ef
MK
416for easy installation from the CD-ROM.
417The distribution can use
0daa9e92 418.B LOADLIN
c13182ef 419to directly load
0daa9e92 420.I /dev/initrd
fea681da 421from CD-ROM without the need of any floppies.
c13182ef 422The distribution could also use a
0daa9e92 423.B LILO
b083bb64 424boot floppy and then bootstrap a bigger RAM disk via
c342a49b
MK
425.IR /dev/initrd
426from the CD-ROM.
c13182ef
MK
427.\"
428.\"
429.\"
25768803
MK
430.SH FILES
431.I /dev/initrd
432.br
433.I /dev/ram0
434.br
435.I /linuxrc
436.br
437.I /initrd
438.\"
439.\"
440.\"
fea681da 441.SH NOTES
c4fd8ad8 442.IP 1. 3
9ee4a2b6 443With the current kernel, any filesystems that remain mounted when
c342a49b
MK
444.I /dev/ram0
445is moved from
446.I /
447to
448.I /initrd
c13182ef
MK
449continue to be accessible.
450However, the
0daa9e92 451.I /proc/mounts
c13182ef 452entries are not updated.
c4fd8ad8
MK
453.IP 2.
454With the current kernel, if directory
c342a49b
MK
455.I /initrd
456does not exist, then
c13182ef 457.I /dev/ram0
118d6caa 458will
4bd8c614
MK
459.B not
460be fully unmounted if
0daa9e92 461.I /dev/ram0
9ee4a2b6 462is used by any process or has any filesystem mounted on it.
c13182ef 463If
c342a49b
MK
464.IR /dev/ram0
465is
4bd8c614 466.B not
c342a49b 467fully unmounted, then
0daa9e92 468.I /dev/ram0
fea681da 469will remain in memory.
c4fd8ad8
MK
470.IP 3.
471Users of
0daa9e92 472.I /dev/initrd
c13182ef 473should not depend on the behavior give in the above notes.
fea681da 474The behavior may change in future versions of the Linux kernel.
c13182ef
MK
475.\"
476.\"
477.\"
d2dc6294
MK
478.\" .SH AUTHORS
479.\" The kernel code for device
480.\" .BR initrd
481.\" was written by Werner Almesberger <almesber@lrc.epfl.ch> and
482.\" Hans Lermen <lermen@elserv.ffm.fgan.de>.
483.\" The code for
484.\" .BR initrd
485.\" was added to the baseline Linux kernel in development version 1.3.73.
47297adb 486.SH SEE ALSO
e37e3282
MK
487.BR chown (1),
488.BR mknod (1),
489.BR ram (4),
490.BR freeramdisk (8),
491.BR rdev (8)
2dad4c59 492.PP
96c11b3f
ES
493.I Documentation/admin\-guide/initrd.rst
494.\" commit 9d85025b0418163fae079c9ba8f8445212de8568
495(or
173fe7e7 496.I Documentation/initrd.txt
96c11b3f 497before Linux 4.10)
173fe7e7
DP
498in the Linux kernel source tree, the LILO documentation,
499the LOADLIN documentation, the SYSLINUX documentation