File: initrd.html

package info (click to toggle)
chos 0.82-2
  • links: PTS
  • area: non-free
  • in suites: slink
  • size: 1,024 kB
  • ctags: 968
  • sloc: ansic: 4,180; asm: 2,103; tcl: 1,976; makefile: 152; sh: 79
file content (567 lines) | stat: -rw-r--r-- 12,816 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
<HTML><HEAD><TITLE>Linux Programmer's Manual: INITRD (4)</TITLE>
</HEAD><body  bgcolor=#ffffff text=#000000 link=#4f4fff vlink=#0000ff alink=#00ff00>

This is the initrd manual page converted to HTML.
<p>
<hr>

<A NAME="lbAB"><H2>NAME</H2></A>

initrd - boot loader initialized RAM disk

<A NAME="lbAC">&nbsp;</A>
<H2>DESCRIPTION</H2>

The special file 
<B>/dev/initrd </B>

is a read-only block device.  
Device 
<B>/dev/initrd</B>

is a RAM disk that is initialized (e.g. loaded) by the boot loader before
the kernel is started.
The kernel then can use the the block device
<B>/dev/initrd</B>'s 

contents for a two phased system boot-up.
<P>

In the first boot-up phase, the kernel starts up 
and mounts an initial root file-system from the contents 
of 
<B>/dev/initrd </B>

(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 file system 
(i.e. the normal root file system) is mounted from a 
different device.



<A NAME="lbAD">&nbsp;</A>
<H2>BOOT-UP OPERATION </H2>

When booting up with 
<B>initrd</B>, the system boots as follows:

<DL COMPACT><DT><DD>
<P>

1. The boot loader loads the kernel program and 
<B>/dev/initrd</B>'s contents into memory.

<P>

2. On kernel startup, the kernel uncompresses and copies the contents of the device 
<B>/dev/initrd</B>

onto device 
<B>/dev/ram0 </B>

and then frees the memory used by 
<B>/dev/initrd</B>.

<P>

3. The kernel then read-write mounts device
<B>/dev/ram0 </B>

as the initial root file system.
<P>

4. If the indicated normal root file system is also the initial root file-system
(e.g. 
<B>/dev/ram0</B>

) then the kernel skips to the last step for the usual boot sequence.
<P>

5. If the executable file 
<B>/linuxrc</B> is present in the initial root file-system, <B>/linuxrc</B>

is executed with uid 0.  
(The file 
<B>/linuxrc</B>

must have executable permission.  
The file 
<B>/linuxrc</B>

can be any valid executable, including a shell script.)  
<P>

6. If  
<B>/linuxrc</B>

is not executed or when 
<B>/linuxrc</B>

terminates, the normal root file system is mounted.  
(If
<B>/linuxrc</B>

exits with any file-systems mounted on the initial root 
file-system, then the behavior of the kernel is 
<B>UNSPECIFIED</B>.

See the 
<B>NOTES</B>

section for the current kernel behavior.)
<P>

7. If the normal root file has directory 
<B>/initrd</B>, device

<B>/dev/ram0</B>

is moved from 
<B>/</B> to <B>/initrd</B>.

Otherwise if directory  
<B>/initrd</B> does not exist device <B>/dev/ram0</B> is unmounted.

(When moved from 
<B>/</B> to <B>/initrd</B>, <B>/dev/ram0</B>

is not unmounted and therefore processes can remain running from 
<B>/dev/ram0</B>.

If directory 
<B>/initrd</B>

does not exist on the normal root file-system 
and any processes remain running from  
<B>/dev/ram0</B> when <B>/linuxrc</B>

exits, the behavior of the kernel is 
<B>UNSPECIFIED</B>.

See the 
<B>NOTES</B>

section for the current kernel behavior.)
<P>

8. The usual boot sequence (e.g. invocation of 
<B>/sbin/init</B>) is performed on the normal root file system.




</DL>
<A NAME="lbAE">&nbsp;</A>
<H2>OPTIONS</H2>

The following boot loader options when used with 
<B>initrd</B>, affect the kernel's boot-up operation:

<DL COMPACT>
<DT><B>initrd=</B><I>filename</I>

<DD>
Specifies the file to load as the contents of 
<B>/dev/initrd</B>.

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 <B>/etc/lilo.config</B>.

The filename specified with this
option will typically be a gzipped file-system image.
<DT><B>noinitrd</B>

<DD>
This boot time option disables the two phase boot-up operation.
The kernel performs the usual boot sequence as if 
<B>/dev/initrd </B>

was not initialized. 
With this option, any contents of
<B>/dev/initrd </B>

loaded into memory by the boot loader contents are preserved.
This option permits the contents of 
<B>/dev/initrd</B>

to be any data and need not be limited to a file system image.  
However, device  
<B>/dev/initrd </B>

is read-only and can be read only one time after system startup.
<DT><B>root=</B><I>device-name</I>

<DD>
Specifies the device to be used as the normal root file system. 
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 <B>/etc/lilo.config</B>.

The device specified by the this option must be a mountable 
device having a suitable root file-system.



</DL>
<A NAME="lbAF">&nbsp;</A>
<H2>CHANGING THE NORMAL ROOT FILE SYSTEM</H2>

By default, 
the kernel's settings 
(i.e. set in the kernel file with 
<B>rdev</B>  or compiled into the kernel file ), 

or the boot loader option setting
is used for the normal root file systems.
For a NFS-mounted normal root file system, 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 NSF-mounted root see the kernel documentation file
<B>nfsroot.txt</B>.

For more information on setting the root file system also see the
<B>LILO</B> and <B>LOADLIN</B> documentation.

<P>

It is also possible for the 
<B>/linuxrc</B>

executable to change the normal root device.
For 
<B>/linuxrc</B>

to change the normal root device, 
<B>/proc</B> must be mounted.

After mounting 
<B>/proc</B>, <B>/linuxrc</B>

changes the normal root device by writing into the proc files
<B>/proc/sys/kernel/real-root-dev</B>, 

<B>/proc/sys/kernel/nfs-root-name</B>, and 

<B>/proc/sys/kernel/nfs-root-addrs</B>.

For a physical root device, the root device is changed by having
<B>/linuxrc</B>

write the new root file system device number into
<B>/proc/sys/kernel/real-root-dev</B>.

For a NSF root file system, the root device is changed by having
<B>/linuxrc</B>

write the NSF setting into files
<B>/proc/sys/kernel/nfs-root-name</B> and 

<B>/proc/sys/kernel/nfs-root-addrs</B>

and then writing 0xff (e.g. the pseudo-NFS-device number) into file
<B>/proc/sys/kernel/real-root-dev</B>.

For example, the following shell command line would change the normal root device to 
<B>/dev/hdb1 :</B>

<PRE>
<B>
        echo 0x365 &gt;/proc/sys/kernel
</B>
</PRE>

For a NSF example, the following shell command lines would change the 
normal root device to the NSF directory 
<B>/var/nfsroot</B>

on a local networked NSF server with IP number 193.8.232.7 for a system with 
IP number 193.8.232.7 and named 'idefix':
<PRE>
<B>
        echo /var/nfsroot &gt;/proc/sys/kernel/nfs-root-name
        echo 193.8.232.2:193.8.232.7::255.255.255.0:idefix \
        &gt;/proc/sys/kernel/nfs-root-addrs
        echo 255 &gt;/proc/sys/kernel/real-root-dev
</B>
</PRE>




<A NAME="lbAG">&nbsp;</A>
<H2>USAGE</H2>

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><DD>
<P>

1. The loader program boots from floppy or other media with a minimal kernel
(e.g. support for 
<B>/dev/ram</B>, <B>/dev/initrd</B>, and the ext2 file-system) and loads 

<B>/dev/initrd</B> with a gzipped version of the initial file-system.

<P>

2. The executable 
<B>/linuxrc</B>

determines what is needed to (1) mount the normal root file-system
(i.e. device type, device drivers, file system) 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.
<P>

3. The executable 
<B>/linuxrc</B>

loads the necessary modules from the initial root file-system.
<P>

4. The executable 
<B>/linuxrc</B>

creates and populates the root file system.  (At this stage the normal
root file system does not have to be a
completed system yet.)
<P>

5. The executable 
<B>/linuxrc</B> sets <B>/proc/sys/kernel/real-root-dev,</B>

unmount 
<B>/proc</B>, 

the normal root file system and any other file
systems it has mounted, and then terminates.
<P>

6. The kernel then mounts the normal root file system.
<P>

7. Now that the file system is accessible and intact,
the boot loader can be installed.
<P>

8. The boot loader is configured to load into
<B>/dev/initrd</B>

a file system with the set of modules that was used to bring up the system. 
(e.g. Device
<B>/dev/ram0</B>

can be modified, then unmounted, and finally, the image is written from
<B>/dev/ram0</B>

to a file.)
<P>

9. The system is now bootable and additional installation tasks can be
performed.
</DL>

<P>

The key role of 
<B>/dev/initrd</B>

in the above is to re-use 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 the 
<B>/linuxrc</B>

file or a file executed by
<B>/linuxrc</B>

would be different.
<P>

A third scenario is more convenient recovery disks. 
Because information like the location of the root file-system 
partition is not needed at boot time, the system loaded from 
<B>/dev/initrd </B>

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 
<B>/dev/initrd</B>

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
<B>/dev/initrd</B> from the CD-ROM.




<A NAME="lbAH">&nbsp;</A>
<H2>CONFIGURATION</H2>

The 
<B>/dev/initrd </B>

is a read-only block device assigned 
major number 1 and minor number 250.  
Typically 
<B>/dev/initrd</B>

is owned by 
<B>root.disk </B>

with mode 0400 (read access by root only).
If the Linux system does not have
<B>/dev/initrd</B>

already created, it can be created with the following commands:
<PRE>
<B>
        mknod -m 400 /dev/initrd b 1 250
        chown root.disk /dev/initrd
</B>
</PRE>

Also, support for both &quot;RAM disk&quot; and &quot;Initial RAM disk&quot; 
(e.g. 
<B>CONFIG_BLK_DEV_RAM=y</B> and <B>CONFIG_BLK_DEV_INITRD=y</B>

) support must be compiled directly into the Linux kernel to use 
<B>/dev/initrd</B>.

When using 
<B>/dev/initrd</B>, 

the RAM disk driver cannot be loaded as a module.



<A NAME="lbAI">&nbsp;</A>
<H2>FILES</H2>

<I>/dev/initrd</I>

<BR>

<I>/dev/ram0</I>

<BR>

<I>/linuxrc</I>

<BR>

<I>/initrd</I>

<A NAME="lbAJ">&nbsp;</A>
<H2>SEE ALSO</H2>

<B><A HREF="http:/cgi-bin/man2html?man1/chown.1">chown</A></B>(1), <B><A HREF="http:/cgi-bin/man2html?man1/mknod.1">mknod</A></B>(1), <B>/dev/<A HREF="http:/cgi-bin/man2html?man4/ram.4">ram</A></B>(4), 

<B><A HREF="http:/cgi-bin/man2html?man8/freeramdisk.8">freeramdisk</A></B>(8), <B><A HREF="http:/cgi-bin/man2html?man8/rdev.8">rdev</A></B>(8),  

<BR>

documentation file <B>initrd.txt</B> in the kernel source package,  

<BR>

<B>LILO</B> documentation,  <B>LOADLIN</B> documentation,  

<B>SYSLINUX</B> documentation.




<A NAME="lbAK">&nbsp;</A>
<H2>NOTES</H2>

1. With the current kernel, any file systems that remain mounted when
<B>/dev/ram0</B> is moved from <B>/</B> to <B>/initrd</B>

continue to be accessible.  However, the
<B>/proc/mounts</B>

entries are not updated. 
<P>

2. With the current kernel, if directory 
<B>/initrd</B> does not exist, then <B>/dev/ram0</B>

will NOT be fully unmounted if 
<B>/dev/ram0</B>

is used by any process or has any file-system mounted on it.
If  
<B>/dev/ram0</B> is NOT fully unmounted, 

then  
<B>/dev/ram0</B>

will remain in memory.
<P>

3. Users of 
<B>/dev/initrd</B>

should not depend on the behavior give in the above notes.  
The behavior may change in future versions of the Linux kernel.



<A NAME="lbAL">&nbsp;</A>
<H2>AUTHOR</H2>

The kernel code for device 
<B>initrd</B>

was written by Werner Almesberger &lt;<A HREF="mailto:almesber@lrc.epfl.ch">almesber@lrc.epfl.ch</A>&gt; and 
Hans Lermen &lt;<A HREF="mailto:lermen@elserv.ffm.fgan.de">lermen@elserv.ffm.fgan.de</A>&gt;.
The code for
<B>initrd</B>

was added to the baseline Linux kernel in development version 1.3.73

<HR>
This manual page was converted to HTML using
<A HREF="http:/cgi-bin/man2html">man2html</A>,
 18:06:48 EET, December 13, 1997
</BODY>
</HTML>