1INITRD(4)                  Linux Programmer's Manual                 INITRD(4)
2
3
4

NAME

6       initrd - boot loader initialized RAM disk
7

CONFIGURATION

9       The /dev/initrd is a read-only block device assigned major number 1 and
10       minor number 250.  Typically /dev/initrd is  owned  by  root.disk  with
11       mode  0400  (read  access  by root only).  If the Linux system does not
12       have /dev/initrd already created, it can be created with the  following
13       commands:
14               mknod -m 400 /dev/initrd b 1 250
15               chown root:disk /dev/initrd
16
17       Also,  support  for  both "RAM disk" and "Initial RAM disk" (e.g., CON‐
18       FIG_BLK_DEV_RAM=y  and  CONFIG_BLK_DEV_INITRD=y)   must   be   compiled
19       directly  into  the  Linux  kernel  to  use  /dev/initrd.   When  using
20       /dev/initrd, the RAM disk driver cannot be loaded as a module.
21

DESCRIPTION

23       The special file /dev/initrd is a read-only block device.  This  device
24       is  a  RAM  disk  that is initialized (e.g., loaded) by the boot loader
25       before the kernel is started.  The kernel then  can  use  /dev/initrd's
26       contents for a two-phase system boot-up.
27
28       In  the first boot-up phase, the kernel starts up and mounts an initial
29       root file-system from the contents of /dev/initrd (e.g., RAM disk  ini‐
30       tialized  by the boot loader).  In the second phase, additional drivers
31       or other modules are loaded from the initial  root  device's  contents.
32       After loading the additional modules, a new root file system (i.e., the
33       normal root file system) is mounted from a different device.
34
35   Boot-up operation
36       When booting up with initrd, the system boots as follows:
37
38       1. The boot loader loads the kernel program and /dev/initrd's  contents
39          into memory.
40
41       2. On  kernel  startup, the kernel uncompresses and copies the contents
42          of the device /dev/initrd onto device /dev/ram0 and then  frees  the
43          memory used by /dev/initrd.
44
45       3. The  kernel  then read-write mounts the device /dev/ram0 as the ini‐
46          tial root file system.
47
48       4. If the indicated normal root file system is also  the  initial  root
49          file-system (e.g., /dev/ram0) then the kernel skips to the last step
50          for the usual boot sequence.
51
52       5. If the executable file /linuxrc is present in the initial root file-
53          system,  /linuxrc  is  executed with UID 0.  (The file /linuxrc must
54          have executable permission.  The file /linuxrc can be any valid exe‐
55          cutable, including a shell script.)
56
57       6. If  /linuxrc is not executed or when /linuxrc terminates, the normal
58          root file system is mounted.  (If /linuxrc exits with any  file-sys‐
59          tems  mounted  on the initial root file-system, then the behavior of
60          the kernel is UNSPECIFIED.  See the NOTES section  for  the  current
61          kernel behavior.)
62
63       7. If  the  normal root file system has a directory /initrd, the device
64          /dev/ram0 is moved from / to /initrd.  Otherwise  if  the  directory
65          /initrd  does  not  exist, the device /dev/ram0 is unmounted.  (When
66          moved from / to /initrd, /dev/ram0 is not  unmounted  and  therefore
67          processes  can  remain running from /dev/ram0.  If directory /initrd
68          does not exist on the normal root  file  system  and  any  processes
69          remain  running  from /dev/ram0 when /linuxrc exits, the behavior of
70          the kernel is UNSPECIFIED.  See the NOTES section  for  the  current
71          kernel behavior.)
72
73       8. The  usual  boot  sequence  (e.g., invocation of /sbin/init) is per‐
74          formed on the normal root file system.
75
76   Options
77       The following boot loader options, when used with  initrd,  affect  the
78       kernel's boot-up operation:
79
80       initrd=filename
81              Specifies  the file to load as the contents of /dev/initrd.  For
82              LOADLIN this is a command-line option.  For LILO you have to use
83              this  command  in  the LILO configuration file /etc/lilo.config.
84              The filename specified with this  option  will  typically  be  a
85              gzipped file-system image.
86
87       noinitrd
88              This  boot option disables the two-phase boot-up operation.  The
89              kernel performs the usual boot sequence as  if  /dev/initrd  was
90              not  initialized.  With this option, any contents of /dev/initrd
91              loaded into memory by the boot loader  contents  are  preserved.
92              This  option  permits the contents of /dev/initrd to be any data
93              and need not be limited to a file system image.  However, device
94              /dev/initrd  is  read-only  and  can be read only one time after
95              system startup.
96
97       root=device-name
98              Specifies the device to be used as the normal root file  system.
99              For  LOADLIN  this is a command-line option.  For LILO this is a
100              boot time option or can be used as an option line  in  the  LILO
101              configuration  file  /etc/lilo.config.   The device specified by
102              the this option must be a mountable  device  having  a  suitable
103              root file-system.
104
105   Changing the normal root file system
106       By  default,  the  kernel's settings (e.g., set in the kernel file with
107       rdev(8) or compiled into the kernel file), or the  boot  loader  option
108       setting  is  used for the normal root file systems.  For an NFS-mounted
109       normal  root  file  system,  one  has  to  use  the  nfs_root_name  and
110       nfs_root_addrs  boot options to give the NFS settings.  For more infor‐
111       mation on NFS-mounted root see the kernel documentation file Documenta‐
112       tion/filesystems/nfsroot.txt.  For more information on setting the root
113       file system see also the LILO and LOADLIN documentation.
114
115       It is also possible for the /linuxrc executable to  change  the  normal
116       root device.  For /linuxrc to change the normal root device, /proc must
117       be mounted.  After mounting /proc, /linuxrc  changes  the  normal  root
118       device  by  writing into the proc files /proc/sys/kernel/real-root-dev,
119       /proc/sys/kernel/nfs-root-name,  and   /proc/sys/kernel/nfs-root-addrs.
120       For  a physical root device, the root device is changed by having /lin‐
121       uxrc write the new root file system device number  into  /proc/sys/ker‐
122       nel/real-root-dev.   For  an  NFS  root file system, the root device is
123       changed  by  having  /linuxrc  write  the  NFS   setting   into   files
124       /proc/sys/kernel/nfs-root-name  and /proc/sys/kernel/nfs-root-addrs and
125       then writing  0xff  (e.g.,  the  pseudo-NFS-device  number)  into  file
126       /proc/sys/kernel/real-root-dev.   For example, the following shell com‐
127       mand line would change the normal root device to /dev/hdb1:
128
129           echo 0x365 >/proc/sys/kernel/real-root-dev
130
131       For an NFS example, the following shell command lines would change  the
132       normal  root  device  to the NFS directory /var/nfsroot on a local net‐
133       worked NFS server with IP number 193.8.232.7 for a system with IP  num‐
134       ber 193.8.232.2 and named "idefix":
135
136           echo /var/nfsroot >/proc/sys/kernel/nfs-root-name
137           echo 193.8.232.2:193.8.232.7::255.255.255.0:idefix \
138               >/proc/sys/kernel/nfs-root-addrs
139           echo 255 >/proc/sys/kernel/real-root-dev
140
141       Note: The use of /proc/sys/kernel/real-root-dev to change the root file
142       system is obsolete.   See  the  Linux  kernel  source  file  Documenta‐
143       tion/initrd.txt as well as pivot_root(2) and pivot_root(8) for informa‐
144       tion on the modern method of changing the root file system.
145
146   Usage
147       The main motivation for implementing initrd was to  allow  for  modular
148       kernel configuration at system installation.
149
150       A possible system installation scenario is as follows:
151
152       1. The  loader  program boots from floppy or other media with a minimal
153          kernel (e.g., support for /dev/ram, /dev/initrd, and the ext2  file-
154          system)  and loads /dev/initrd with a gzipped version of the initial
155          file-system.
156
157       2. The executable /linuxrc determines what is needed to (1)  mount  the
158          normal  root  file-system  (i.e.,  device type, device drivers, file
159          system) and (2) the distribution media (e.g., CD-ROM, network, tape,
160          ...).   This  can be done by asking the user, by auto-probing, or by
161          using a hybrid approach.
162
163       3. The executable /linuxrc loads the necessary modules from the initial
164          root file-system.
165
166       4. The  executable /linuxrc creates and populates the root file system.
167          (At this stage the normal root file system does not  have  to  be  a
168          completed system yet.)
169
170       5. The executable /linuxrc sets /proc/sys/kernel/real-root-dev, unmount
171          /proc, the normal root file system and any other file systems it has
172          mounted, and then terminates.
173
174       6. The kernel then mounts the normal root file system.
175
176       7. Now  that  the file system is accessible and intact, the boot loader
177          can be installed.
178
179       8. The boot loader is configured to load into /dev/initrd a file system
180          with  the  set  of  modules  that  was  used to bring up the system.
181          (e.g.,  Device  /dev/ram0  can  be  modified,  then  unmounted,  and
182          finally, the image is written from /dev/ram0 to a file.)
183
184       9. The  system is now bootable and additional installation tasks can be
185          performed.
186
187       The key role of /dev/initrd in the above is to reuse the  configuration
188       data  during  normal  system operation without requiring initial kernel
189       selection, a large generic kernel or, recompiling the kernel.
190
191       A second scenario is for installations where Linux runs on systems with
192       different  hardware  configurations in a single administrative network.
193       In such cases, it may be desirable to use only a small set  of  kernels
194       (ideally  only  one) and to keep the system-specific part of configura‐
195       tion information as small as possible.  In this case, create  a  common
196       file  with  all needed modules.  Then, only the /linuxrc file or a file
197       executed by /linuxrc would be different.
198
199       A third scenario is more convenient recovery disks.   Because  informa‐
200       tion  like the location of the root file-system partition is not needed
201       at boot time, the system loaded  from  /dev/initrd  can  use  a  dialog
202       and/or auto-detection followed by a possible sanity check.
203
204       Last  but  not  least, Linux distributions on CD-ROM may use initrd for
205       easy installation from the CD-ROM.  The distribution can use LOADLIN to
206       directly load /dev/initrd from CD-ROM without the need of any floppies.
207       The distribution could also use a LILO boot floppy and then bootstrap a
208       bigger RAM disk via /dev/initrd from the CD-ROM.
209

FILES

211       /dev/initrd
212       /dev/ram0
213       /linuxrc
214       /initrd
215

NOTES

217       1. With  the  current kernel, any file systems that remain mounted when
218          /dev/ram0 is moved from / to  /initrd  continue  to  be  accessible.
219          However, the /proc/mounts entries are not updated.
220
221       2. With  the  current kernel, if directory /initrd does not exist, then
222          /dev/ram0 will not be fully unmounted if /dev/ram0 is  used  by  any
223          process  or  has any file-system mounted on it.  If /dev/ram0 is not
224          fully unmounted, then /dev/ram0 will remain in memory.
225
226       3. Users of /dev/initrd should not depend on the behavior give  in  the
227          above  notes.   The  behavior  may  change in future versions of the
228          Linux kernel.
229

SEE ALSO

231       chown(1), mknod(1), ram(4), freeramdisk(8), rdev(8)
232
233       Documentation/initrd.txt in the Linux kernel source tree, the LILO doc‐
234       umentation, the LOADLIN documentation, the SYSLINUX documentation
235

COLOPHON

237       This  page  is  part of release 3.53 of the Linux man-pages project.  A
238       description of the project, and information about reporting  bugs,  can
239       be found at http://www.kernel.org/doc/man-pages/.
240
241
242
243Linux                             2010-09-04                         INITRD(4)
Impressum