687 lines
14 KiB
HTML
687 lines
14 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of INITRD</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>INITRD</H1>
|
|
Section: Linux Programmer's Manual (4)<BR>Updated: 2019-03-06<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
initrd - boot loader initialized RAM disk
|
|
<A NAME="lbAC"> </A>
|
|
<H2>CONFIGURATION</H2>
|
|
|
|
<I>/dev/initrd</I>
|
|
|
|
is a read-only block device assigned
|
|
major number 1 and minor number 250.
|
|
Typically
|
|
<I>/dev/initrd</I>
|
|
|
|
is owned by
|
|
root:disk
|
|
with mode 0400 (read access by root only).
|
|
If the Linux system does not have
|
|
<I>/dev/initrd</I>
|
|
|
|
already created, it can be created with the following commands:
|
|
<P>
|
|
|
|
|
|
|
|
mknod -m 400 /dev/initrd b 1 250
|
|
chown root:disk /dev/initrd
|
|
|
|
|
|
<P>
|
|
|
|
Also, support for both "RAM disk" and "Initial RAM disk"
|
|
(e.g.,
|
|
<B>CONFIG_BLK_DEV_RAM=y</B>
|
|
|
|
and
|
|
<B>CONFIG_BLK_DEV_INITRD=y</B>)
|
|
|
|
must be compiled directly into the Linux kernel to use
|
|
<I>/dev/initrd</I>.
|
|
|
|
When using
|
|
<I>/dev/initrd</I>,
|
|
|
|
the RAM disk driver cannot be loaded as a module.
|
|
|
|
|
|
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
The special file
|
|
<I>/dev/initrd</I>
|
|
|
|
is a read-only block device.
|
|
This device is a RAM disk that is initialized (e.g., loaded)
|
|
by the boot loader before the kernel is started.
|
|
The kernel then can use
|
|
<I>/dev/initrd</I>'s
|
|
|
|
contents for a two-phase system boot-up.
|
|
<P>
|
|
|
|
In the first boot-up phase, the kernel starts up
|
|
and mounts an initial root filesystem from the contents of
|
|
<I>/dev/initrd</I>
|
|
|
|
(e.g., RAM disk initialized by the boot loader).
|
|
In the second phase, additional drivers or other modules
|
|
are loaded from the initial root device's contents.
|
|
After loading the additional modules, a new root filesystem
|
|
(i.e., the normal root filesystem) is mounted from a
|
|
different device.
|
|
|
|
|
|
|
|
<A NAME="lbAE"> </A>
|
|
<H3>Boot-up operation</H3>
|
|
|
|
When booting up with
|
|
<B>initrd</B>,
|
|
|
|
the system boots as follows:
|
|
<DL COMPACT>
|
|
<DT id="1">1.<DD>
|
|
The boot loader loads the kernel program and
|
|
<I>/dev/initrd</I>'s
|
|
|
|
contents into memory.
|
|
<DT id="2">2.<DD>
|
|
On kernel startup,
|
|
the kernel uncompresses and copies the contents of the device
|
|
<I>/dev/initrd</I>
|
|
|
|
onto device
|
|
<I>/dev/ram0</I>
|
|
|
|
and then frees the memory used by
|
|
<I>/dev/initrd</I>.
|
|
|
|
<DT id="3">3.<DD>
|
|
The kernel then read-write mounts the device
|
|
<I>/dev/ram0</I>
|
|
|
|
as the initial root filesystem.
|
|
<DT id="4">4.<DD>
|
|
If the indicated normal root filesystem is also the initial
|
|
root filesystem (e.g.,
|
|
<I>/dev/ram0</I>)
|
|
|
|
then the kernel skips to the last step for the usual boot sequence.
|
|
<DT id="5">5.<DD>
|
|
If the executable file
|
|
<I>/linuxrc</I>
|
|
|
|
is present in the initial root filesystem,
|
|
<I>/linuxrc</I>
|
|
|
|
is executed with UID 0.
|
|
(The file
|
|
<I>/linuxrc</I>
|
|
|
|
must have executable permission.
|
|
The file
|
|
<I>/linuxrc</I>
|
|
|
|
can be any valid executable, including a shell script.)
|
|
<DT id="6">6.<DD>
|
|
If
|
|
<I>/linuxrc</I>
|
|
|
|
is not executed or when
|
|
<I>/linuxrc</I>
|
|
|
|
terminates, the normal root filesystem is mounted.
|
|
(If
|
|
<I>/linuxrc</I>
|
|
|
|
exits with any filesystems mounted on the initial root
|
|
filesystem, then the behavior of the kernel is
|
|
<B>UNSPECIFIED</B>.
|
|
|
|
See the NOTES section for the current kernel behavior.)
|
|
<DT id="7">7.<DD>
|
|
If the normal root filesystem has a directory
|
|
<I>/initrd</I>,
|
|
|
|
the device
|
|
<I>/dev/ram0</I>
|
|
|
|
is moved from
|
|
<I>/</I>
|
|
|
|
to
|
|
<I>/initrd</I>.
|
|
|
|
Otherwise, if the directory
|
|
<I>/initrd</I>
|
|
|
|
does not exist, the device
|
|
<I>/dev/ram0</I>
|
|
|
|
is unmounted.
|
|
(When moved from
|
|
<I>/</I>
|
|
|
|
to
|
|
<I>/initrd</I>,
|
|
|
|
<I>/dev/ram0</I>
|
|
|
|
is not unmounted and therefore processes can remain running from
|
|
<I>/dev/ram0</I>.
|
|
|
|
If directory
|
|
<I>/initrd</I>
|
|
|
|
does not exist on the normal root filesystem
|
|
and any processes remain running from
|
|
<I>/dev/ram0</I>
|
|
|
|
when
|
|
<I>/linuxrc</I>
|
|
|
|
exits, the behavior of the kernel is
|
|
<B>UNSPECIFIED</B>.
|
|
|
|
See the NOTES section for the current kernel behavior.)
|
|
<DT id="8">8.<DD>
|
|
The usual boot sequence (e.g., invocation of
|
|
<I>/sbin/init</I>)
|
|
|
|
is performed on the normal root filesystem.
|
|
|
|
|
|
|
|
</DL>
|
|
<A NAME="lbAF"> </A>
|
|
<H3>Options</H3>
|
|
|
|
The following boot loader options, when used with
|
|
<B>initrd</B>,
|
|
|
|
affect the kernel's boot-up operation:
|
|
<DL COMPACT>
|
|
<DT id="9"><B>initrd=</B><I>filename</I>
|
|
|
|
<DD>
|
|
Specifies the file to load as the contents of
|
|
<I>/dev/initrd</I>.
|
|
|
|
For
|
|
<B>LOADLIN</B>
|
|
|
|
this is a command-line option.
|
|
For
|
|
<B>LILO</B>
|
|
|
|
you have to use this command in the
|
|
<B>LILO</B>
|
|
|
|
configuration file
|
|
<I>/etc/lilo.config</I>.
|
|
|
|
The filename specified with this
|
|
option will typically be a gzipped filesystem image.
|
|
<DT id="10"><I>noinitrd</I>
|
|
|
|
<DD>
|
|
This boot option disables the two-phase boot-up operation.
|
|
The kernel performs the usual boot sequence as if
|
|
<I>/dev/initrd</I>
|
|
|
|
was not initialized.
|
|
With this option, any contents of
|
|
<I>/dev/initrd</I>
|
|
|
|
loaded into memory by the boot loader contents are preserved.
|
|
This option permits the contents of
|
|
<I>/dev/initrd</I>
|
|
|
|
to be any data and need not be limited to a filesystem image.
|
|
However, device
|
|
<I>/dev/initrd</I>
|
|
|
|
is read-only and can be read only one time after system startup.
|
|
<DT id="11"><B>root=</B><I>device-name</I>
|
|
|
|
<DD>
|
|
Specifies the device to be used as the normal root filesystem.
|
|
For
|
|
<B>LOADLIN</B>
|
|
|
|
this is a command-line option.
|
|
For
|
|
<B>LILO</B>
|
|
|
|
this is a boot time option or
|
|
can be used as an option line in the
|
|
<B>LILO</B>
|
|
|
|
configuration file
|
|
<I>/etc/lilo.config</I>.
|
|
|
|
The device specified by the this option must be a mountable
|
|
device having a suitable root filesystem.
|
|
|
|
|
|
|
|
</DL>
|
|
<A NAME="lbAG"> </A>
|
|
<H3>Changing the normal root filesystem</H3>
|
|
|
|
By default,
|
|
the kernel's settings
|
|
(e.g., set in the kernel file with
|
|
<B><A HREF="/cgi-bin/man/man2html?8+rdev">rdev</A></B>(8)
|
|
|
|
or compiled into the kernel file),
|
|
or the boot loader option setting
|
|
is used for the normal root filesystems.
|
|
For an NFS-mounted normal root filesystem, one has to use the
|
|
<B>nfs_root_name</B>
|
|
|
|
and
|
|
<B>nfs_root_addrs</B>
|
|
|
|
boot options to give the NFS settings.
|
|
For more information on NFS-mounted root see the kernel documentation file
|
|
<I>Documentation/filesystems/nfs/nfsroot.txt</I>
|
|
|
|
|
|
(or
|
|
<I>Documentation/filesystems/nfsroot.txt</I>
|
|
|
|
before Linux 2.6.33).
|
|
For more information on setting the root filesystem see also the
|
|
<B>LILO</B>
|
|
|
|
and
|
|
<B>LOADLIN</B>
|
|
|
|
documentation.
|
|
<P>
|
|
|
|
It is also possible for the
|
|
<I>/linuxrc</I>
|
|
|
|
executable to change the normal root device.
|
|
For
|
|
<I>/linuxrc</I>
|
|
|
|
to change the normal root device,
|
|
<I>/proc</I>
|
|
|
|
must be mounted.
|
|
After mounting
|
|
<I>/proc</I>,
|
|
|
|
<I>/linuxrc</I>
|
|
|
|
changes the normal root device by writing into the proc files
|
|
<I>/proc/sys/kernel/real-root-dev</I>,
|
|
|
|
<I>/proc/sys/kernel/nfs-root-name</I>,
|
|
|
|
and
|
|
<I>/proc/sys/kernel/nfs-root-addrs</I>.
|
|
|
|
For a physical root device, the root device is changed by having
|
|
<I>/linuxrc</I>
|
|
|
|
write the new root filesystem device number into
|
|
<I>/proc/sys/kernel/real-root-dev</I>.
|
|
|
|
For an NFS root filesystem, the root device is changed by having
|
|
<I>/linuxrc</I>
|
|
|
|
write the NFS setting into files
|
|
<I>/proc/sys/kernel/nfs-root-name</I>
|
|
|
|
and
|
|
<I>/proc/sys/kernel/nfs-root-addrs</I>
|
|
|
|
and then writing 0xff (e.g., the pseudo-NFS-device number) into file
|
|
<I>/proc/sys/kernel/real-root-dev</I>.
|
|
|
|
For example, the following shell command line would change
|
|
the normal root device to
|
|
<I>/dev/hdb1</I>:
|
|
|
|
<P>
|
|
|
|
|
|
|
|
echo 0x365 >/proc/sys/kernel/real-root-dev
|
|
|
|
|
|
<P>
|
|
|
|
For an NFS example, the following shell command lines would change the
|
|
normal root device to the NFS directory
|
|
<I>/var/nfsroot</I>
|
|
|
|
on a local networked NFS server with IP number 193.8.232.7 for a system with
|
|
IP number 193.8.232.2 and named "idefix":
|
|
<P>
|
|
|
|
|
|
|
|
echo /var/nfsroot >/proc/sys/kernel/nfs-root-name
|
|
echo 193.8.232.2:193.8.232.7::255.255.255.0:idefix \
|
|
<BR> >/proc/sys/kernel/nfs-root-addrs
|
|
echo 255 >/proc/sys/kernel/real-root-dev
|
|
|
|
|
|
<P>
|
|
|
|
<B>Note</B>:
|
|
|
|
The use of
|
|
<I>/proc/sys/kernel/real-root-dev</I>
|
|
|
|
to change the root filesystem is obsolete.
|
|
See the Linux kernel source file
|
|
<I>Documentation/admin-guide/initrd.rst</I>
|
|
|
|
|
|
(or
|
|
<I>Documentation/initrd.txt</I>
|
|
|
|
before Linux 4.10)
|
|
as well as
|
|
<B><A HREF="/cgi-bin/man/man2html?2+pivot_root">pivot_root</A></B>(2)
|
|
|
|
and
|
|
<B><A HREF="/cgi-bin/man/man2html?8+pivot_root">pivot_root</A></B>(8)
|
|
|
|
for information on the modern method of changing the root filesystem.
|
|
|
|
|
|
|
|
|
|
<A NAME="lbAH"> </A>
|
|
<H3>Usage</H3>
|
|
|
|
The main motivation for implementing
|
|
<B>initrd</B>
|
|
|
|
was to allow for modular kernel configuration at system installation.
|
|
<P>
|
|
|
|
A possible system installation scenario is as follows:
|
|
<DL COMPACT>
|
|
<DT id="12">1.<DD>
|
|
The loader program boots from floppy or other media with a minimal kernel
|
|
(e.g., support for
|
|
<I>/dev/ram</I>,
|
|
|
|
<I>/dev/initrd</I>,
|
|
|
|
and the ext2 filesystem) and loads
|
|
<I>/dev/initrd</I>
|
|
|
|
with a gzipped version of the initial filesystem.
|
|
<DT id="13">2.<DD>
|
|
The executable
|
|
<I>/linuxrc</I>
|
|
|
|
determines what is needed to (1) mount the normal root filesystem
|
|
(i.e., device type, device drivers, filesystem) and (2) the
|
|
distribution media (e.g., CD-ROM, network, tape, ...).
|
|
This can be done by asking the user, by auto-probing,
|
|
or by using a hybrid approach.
|
|
<DT id="14">3.<DD>
|
|
The executable
|
|
<I>/linuxrc</I>
|
|
|
|
loads the necessary modules from the initial root filesystem.
|
|
<DT id="15">4.<DD>
|
|
The executable
|
|
<I>/linuxrc</I>
|
|
|
|
creates and populates the root filesystem.
|
|
(At this stage the normal root filesystem does not have to be a
|
|
completed system yet.)
|
|
<DT id="16">5.<DD>
|
|
The executable
|
|
<I>/linuxrc</I>
|
|
|
|
sets
|
|
<I>/proc/sys/kernel/real-root-dev</I>,
|
|
|
|
unmount
|
|
<I>/proc</I>,
|
|
|
|
the normal root filesystem and any other filesystems
|
|
it has mounted, and then terminates.
|
|
<DT id="17">6.<DD>
|
|
The kernel then mounts the normal root filesystem.
|
|
<DT id="18">7.<DD>
|
|
Now that the filesystem is accessible and intact,
|
|
the boot loader can be installed.
|
|
<DT id="19">8.<DD>
|
|
The boot loader is configured to load into
|
|
<I>/dev/initrd</I>
|
|
|
|
a filesystem with the set of modules that was used to bring up the system.
|
|
(e.g., Device
|
|
<I>/dev/ram0</I>
|
|
|
|
can be modified, then unmounted, and finally, the image is written from
|
|
<I>/dev/ram0</I>
|
|
|
|
to a file.)
|
|
<DT id="20">9.<DD>
|
|
The system is now bootable and additional installation tasks can be
|
|
performed.
|
|
</DL>
|
|
<P>
|
|
|
|
The key role of
|
|
<I>/dev/initrd</I>
|
|
|
|
in the above is to reuse the configuration data during normal system operation
|
|
without requiring initial kernel selection, a large generic kernel or,
|
|
recompiling the kernel.
|
|
<P>
|
|
|
|
A second scenario is for installations where Linux runs on systems with
|
|
different hardware configurations in a single administrative network.
|
|
In such cases, it may be desirable to use only a small set of kernels
|
|
(ideally only one) and to keep the system-specific part of configuration
|
|
information as small as possible.
|
|
In this case, create a common file
|
|
with all needed modules.
|
|
Then, only the
|
|
<I>/linuxrc</I>
|
|
|
|
file or a file executed by
|
|
<I>/linuxrc</I>
|
|
|
|
would be different.
|
|
<P>
|
|
|
|
A third scenario is more convenient recovery disks.
|
|
Because information like the location of the root filesystem
|
|
partition is not needed at boot time, the system loaded from
|
|
<I>/dev/initrd</I>
|
|
|
|
can use a dialog and/or auto-detection followed by a
|
|
possible sanity check.
|
|
<P>
|
|
|
|
Last but not least, Linux distributions on CD-ROM may use
|
|
<B>initrd</B>
|
|
|
|
for easy installation from the CD-ROM.
|
|
The distribution can use
|
|
<B>LOADLIN</B>
|
|
|
|
to directly load
|
|
<I>/dev/initrd</I>
|
|
|
|
from CD-ROM without the need of any floppies.
|
|
The distribution could also use a
|
|
<B>LILO</B>
|
|
|
|
boot floppy and then bootstrap a bigger RAM disk via
|
|
<I>/dev/initrd</I>
|
|
|
|
from the CD-ROM.
|
|
|
|
|
|
|
|
<A NAME="lbAI"> </A>
|
|
<H2>FILES</H2>
|
|
|
|
<I>/dev/initrd</I>
|
|
|
|
<BR>
|
|
|
|
<I>/dev/ram0</I>
|
|
|
|
<BR>
|
|
|
|
<I>/linuxrc</I>
|
|
|
|
<BR>
|
|
|
|
<I>/initrd</I>
|
|
|
|
|
|
|
|
|
|
<A NAME="lbAJ"> </A>
|
|
<H2>NOTES</H2>
|
|
|
|
<DL COMPACT>
|
|
<DT id="21">1.<DD>
|
|
With the current kernel, any filesystems that remain mounted when
|
|
<I>/dev/ram0</I>
|
|
|
|
is moved from
|
|
<I>/</I>
|
|
|
|
to
|
|
<I>/initrd</I>
|
|
|
|
continue to be accessible.
|
|
However, the
|
|
<I>/proc/mounts</I>
|
|
|
|
entries are not updated.
|
|
<DT id="22">2.<DD>
|
|
With the current kernel, if directory
|
|
<I>/initrd</I>
|
|
|
|
does not exist, then
|
|
<I>/dev/ram0</I>
|
|
|
|
will
|
|
<B>not</B>
|
|
|
|
be fully unmounted if
|
|
<I>/dev/ram0</I>
|
|
|
|
is used by any process or has any filesystem mounted on it.
|
|
If
|
|
<I>/dev/ram0</I>
|
|
|
|
is
|
|
<B>not</B>
|
|
|
|
fully unmounted, then
|
|
<I>/dev/ram0</I>
|
|
|
|
will remain in memory.
|
|
<DT id="23">3.<DD>
|
|
Users of
|
|
<I>/dev/initrd</I>
|
|
|
|
should not depend on the behavior give in the above notes.
|
|
The behavior may change in future versions of the Linux kernel.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</DL>
|
|
<A NAME="lbAK"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?1+chown">chown</A></B>(1),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?1+mknod">mknod</A></B>(1),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?4+ram">ram</A></B>(4),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?8+freeramdisk">freeramdisk</A></B>(8),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?8+rdev">rdev</A></B>(8)
|
|
|
|
<P>
|
|
|
|
<I>Documentation/admin-guide/initrd.rst</I>
|
|
|
|
|
|
(or
|
|
<I>Documentation/initrd.txt</I>
|
|
|
|
before Linux 4.10)
|
|
in the Linux kernel source tree, the LILO documentation,
|
|
the LOADLIN documentation, the SYSLINUX documentation
|
|
<A NAME="lbAL"> </A>
|
|
<H2>COLOPHON</H2>
|
|
|
|
This page is part of release 5.05 of the Linux
|
|
<I>man-pages</I>
|
|
|
|
project.
|
|
A description of the project,
|
|
information about reporting bugs,
|
|
and the latest version of this page,
|
|
can be found at
|
|
<A HREF="https://www.kernel.org/doc/man-pages/.">https://www.kernel.org/doc/man-pages/.</A>
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="24"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="25"><A HREF="#lbAC">CONFIGURATION</A><DD>
|
|
<DT id="26"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DL>
|
|
<DT id="27"><A HREF="#lbAE">Boot-up operation</A><DD>
|
|
<DT id="28"><A HREF="#lbAF">Options</A><DD>
|
|
<DT id="29"><A HREF="#lbAG">Changing the normal root filesystem</A><DD>
|
|
<DT id="30"><A HREF="#lbAH">Usage</A><DD>
|
|
</DL>
|
|
<DT id="31"><A HREF="#lbAI">FILES</A><DD>
|
|
<DT id="32"><A HREF="#lbAJ">NOTES</A><DD>
|
|
<DT id="33"><A HREF="#lbAK">SEE ALSO</A><DD>
|
|
<DT id="34"><A HREF="#lbAL">COLOPHON</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:06:01 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|