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

NAME

6       initrd - boot loader initialized RAM disk
7

DESCRIPTION

9       The  special  file  /dev/initrd  is  a  read-only block device.  Device
10       /dev/initrd is a RAM disk that is initialized (e.g. loaded) by the boot
11       loader before the kernel is started.  The kernel then can use the block
12       device /dev/initrd's contents for a two phased system boot-up.
13
14       In the first boot-up phase, the kernel starts up and mounts an  initial
15       root  file-system  from the contents of /dev/initrd (e.g. RAM disk ini‐
16       tialized by the boot loader).  In the second phase, additional  drivers
17       or  other  modules  are loaded from the initial root device's contents.
18       After loading the additional modules, a new root file system (i.e.  the
19       normal root file system) is mounted from a different device.
20

BOOT-UP OPERATION

22       When booting up with initrd, the system boots as follows:
23
24         1.  The  boot  loader loads the kernel program and /dev/initrd's con‐
25         tents into memory.
26
27         2. On kernel startup, the kernel uncompresses and copies the contents
28         of  the  device  /dev/initrd onto device /dev/ram0 and then frees the
29         memory used by /dev/initrd.
30
31         3. The kernel then read-write mounts device /dev/ram0 as the  initial
32         root file system.
33
34         4.  If the indicated normal root file system is also the initial root
35         file-system (e.g.  /dev/ram0 ) then the kernel skips to the last step
36         for the usual boot sequence.
37
38         5.  If  the  executable  file /linuxrc is present in the initial root
39         file-system, /linuxrc is executed with UID  0.   (The  file  /linuxrc
40         must  have executable permission.  The file /linuxrc can be any valid
41         executable, including a shell script.)
42
43         6. If /linuxrc is not executed or when /linuxrc terminates, the  nor‐
44         mal  root  file system is mounted.  (If /linuxrc exits with any file-
45         systems mounted on the initial root file-system, then the behavior of
46         the  kernel  is  UNSPECIFIED.   See the NOTES section for the current
47         kernel behavior.)
48
49         7. If the normal root file has directory /initrd, device /dev/ram0 is
50         moved  from  /  to  /initrd.  Otherwise if directory /initrd does not
51         exist device /dev/ram0 is unmounted.  (When moved from / to  /initrd,
52         /dev/ram0 is not unmounted and therefore processes can remain running
53         from /dev/ram0.  If directory /initrd does not exist  on  the  normal
54         root file-system and any processes remain running from /dev/ram0 when
55         /linuxrc exits, the behavior of the kernel is UNSPECIFIED.   See  the
56         NOTES section for the current kernel behavior.)
57
58         8.  The  usual  boot sequence (e.g. invocation of /sbin/init) is per‐
59         formed on the normal root file system.
60

OPTIONS

62       The following boot loader options when used  with  initrd,  affect  the
63       kernel's boot-up operation:
64
65       initrd=filename
66              Specifies  the file to load as the contents of /dev/initrd.  For
67              LOADLIN this is a command line option.  For LILO you have to use
68              this  command  in  the LILO configuration file /etc/lilo.config.
69              The filename specified with this  option  will  typically  be  a
70              gzipped file-system image.
71
72       noinitrd
73              This  boot time option disables the two phase boot-up operation.
74              The kernel performs the usual boot sequence  as  if  /dev/initrd
75              was   not  initialized.   With  this  option,  any  contents  of
76              /dev/initrd loaded into memory by the boot loader  contents  are
77              preserved.   This  option permits the contents of /dev/initrd to
78              be any data and need not be limited  to  a  file  system  image.
79              However,  device  /dev/initrd  is read-only and can be read only
80              one time after system startup.
81
82       root=device-name
83              Specifies the device to be used as the normal root file  system.
84              For  LOADLIN  this is a command line option.  For LILO this is a
85              boot time option or can be used as an option line  in  the  LILO
86              configuration  file  /etc/lilo.config.   The device specified by
87              the this option must be a mountable  device  having  a  suitable
88              root file-system.
89

CHANGING THE NORMAL ROOT FILE SYSTEM

91       By  default,  the  kernel's  settings (e.g. set in the kernel file with
92       rdev(8) or compiled into the kernel file), or the  boot  loader  option
93       setting  is  used  for the normal root file systems.  For a NFS-mounted
94       normal  root  file  system,  one  has  to  use  the  nfs_root_name  and
95       nfs_root_addrs  boot options to give the NFS settings.  For more infor‐
96       mation on NFS-mounted root  see  the  kernel  documentation  file  nfs‐
97       root.txt.   For  more  information on setting the root file system also
98       see the LILO and LOADLIN documentation.
99
100       It is also possible for the /linuxrc executable to  change  the  normal
101       root device.  For /linuxrc to change the normal root device, /proc must
102       be mounted.  After mounting /proc, /linuxrc  changes  the  normal  root
103       device  by  writing into the proc files /proc/sys/kernel/real-root-dev,
104       /proc/sys/kernel/nfs-root-name,  and   /proc/sys/kernel/nfs-root-addrs.
105       For  a physical root device, the root device is changed by having /lin‐
106       uxrc write the new root file system device number  into  /proc/sys/ker‐
107       nel/real-root-dev.   For  a  NFS  root  file system, the root device is
108       changed  by  having  /linuxrc  write  the  NFS   setting   into   files
109       /proc/sys/kernel/nfs-root-name  and /proc/sys/kernel/nfs-root-addrs and
110       then  writing  0xff  (e.g.  the  pseudo-NFS-device  number)  into  file
111       /proc/sys/kernel/real-root-dev.   For example, the following shell com‐
112       mand line would change the normal root device to /dev/hdb1:
113               echo 0x365 >/proc/sys/kernel/real-root-dev
114       For a NFS example, the following shell command lines would  change  the
115       normal  root  device  to the NFS directory /var/nfsroot on a local net‐
116       worked NFS server with IP number 193.8.232.7 for a system with IP  num‐
117       ber 193.8.232.7 and named 'idefix':
118            echo /var/nfsroot >/proc/sys/kernel/nfs-root-name
119            echo 193.8.232.2:193.8.232.7::255.255.255.0:idefix \
120              >/proc/sys/kernel/nfs-root-addrs
121            echo 255 >/proc/sys/kernel/real-root-dev
122
123       Note: The use of /proc/sys/kernel/real-root-dev to change the root file
124       system is obsolete.  See  the  kernel  source  file  Documentation/ini‐
125       trd.txt  as  well as pivot_root(2) and pivot_root(8) for information on
126       the modern method of changing the root file system.
127

USAGE

129       The main motivation for implementing initrd was to  allow  for  modular
130       kernel configuration at system installation.
131
132       A possible system installation scenario is as follows:
133
134         1. The loader program boots from floppy or other media with a minimal
135         kernel (e.g. support for /dev/ram, /dev/initrd, and  the  ext2  file-
136         system)  and  loads /dev/initrd with a gzipped version of the initial
137         file-system.
138
139         2. The executable /linuxrc determines what is needed to (1) mount the
140         normal  root file-system (i.e. device type, device drivers, file sys‐
141         tem) and (2) the distribution  media  (e.g.  CD-ROM,  network,  tape,
142         ...).  This  can  be  done by asking the user, by auto-probing, or by
143         using a hybrid approach.
144
145         3. The executable /linuxrc loads the necessary modules from the  ini‐
146         tial root file-system.
147
148         4.  The  executable /linuxrc creates and populates the root file sys‐
149         tem.  (At this stage the normal root file system does not have to  be
150         a completed system yet.)
151
152         5.   The  executable  /linuxrc  sets  /proc/sys/kernel/real-root-dev,
153         unmount /proc, the normal root file system and any other file systems
154         it has mounted, and then terminates.
155
156         6. The kernel then mounts the normal root file system.
157
158         7. Now that the file system is accessible and intact, the boot loader
159         can be installed.
160
161         8. The boot loader is configured to load into /dev/initrd a file sys‐
162         tem  with  the  set  of modules that was used to bring up the system.
163         (e.g. Device /dev/ram0 can be modified, then unmounted, and  finally,
164         the image is written from /dev/ram0 to a file.)
165
166         9.  The  system is now bootable and additional installation tasks can
167         be performed.
168
169       The key role of /dev/initrd in the above is to re-use the configuration
170       data  during  normal  system operation without requiring initial kernel
171       selection, a large generic kernel or, recompiling the kernel.
172
173       A second scenario is for installations where Linux runs on systems with
174       different  hardware  configurations in a single administrative network.
175       In such cases, it may be desirable to use only a small set  of  kernels
176       (ideally  only  one) and to keep the system-specific part of configura‐
177       tion information as small as possible.  In this case, create  a  common
178       file  with  all needed modules.  Then, only the /linuxrc file or a file
179       executed by /linuxrc would be different.
180
181       A third scenario is more convenient recovery disks.   Because  informa‐
182       tion  like the location of the root file-system partition is not needed
183       at boot time, the system loaded  from  /dev/initrd  can  use  a  dialog
184       and/or auto-detection followed by a possible sanity check.
185
186       Last  but  not  least, Linux distributions on CD-ROM may use initrd for
187       easy installation from the CD-ROM.  The distribution can use LOADLIN to
188       directly load /dev/initrd from CD-ROM without the need of any floppies.
189       The distribution could also use a LILO boot floppy and then bootstrap a
190       bigger ram disk via /dev/initrd from the CD-ROM.
191

CONFIGURATION

193       The /dev/initrd is a read-only block device assigned major number 1 and
194       minor number 250.  Typically /dev/initrd is  owned  by  root.disk  with
195       mode  0400  (read  access  by root only).  If the Linux system does not
196       have /dev/initrd already created, it can be created with the  following
197       commands:
198               mknod -m 400 /dev/initrd b 1 250
199               chown root:disk /dev/initrd
200       Also,  support  for  both "RAM disk" and "Initial RAM disk" (e.g.  CON‐
201       FIG_BLK_DEV_RAM=y and CONFIG_BLK_DEV_INITRD=y ) support  must  be  com‐
202       piled  directly  into  the Linux kernel to use /dev/initrd.  When using
203       /dev/initrd, the RAM disk driver cannot be loaded as a module.
204

FILES

206       /dev/initrd
207       /dev/ram0
208       /linuxrc
209       /initrd
210

SEE ALSO

212       chown(1), mknod(1), ram(4), freeramdisk(8), rdev(8)
213
214       The documentation file initrd.txt in the  kernel  source  package,  the
215       LILO  documentation, the LOADLIN documentation, the SYSLINUX documenta‐
216       tion.
217

NOTES

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

AUTHOR

233       The  kernel  code  for  device initrd was written by Werner Almesberger
234       <almesber@lrc.epfl.ch>  and  Hans  Lermen  <lermen@elserv.ffm.fgan.de>.
235       The  code for initrd was added to the baseline Linux kernel in develop‐
236       ment version 1.3.73.
237
238
239
240Linux 2.0                         1997-11-06                         INITRD(4)
Impressum