summaryrefslogtreecommitdiffstats
path: root/upstream/opensuse-leap-15-6/man4/initrd.4
blob: 770517cb8e88967434f1e911bbaa75c0d859b2fd (plain)
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
.\" This man-page is Copyright (C) 1997 John S. Kallal
.\"
.\" SPDX-License-Identifier: Linux-man-pages-copyleft
.\"
.\" If the you wish to distribute versions of this work under other
.\" conditions than the above, please contact the author(s) at the following
.\" for permission:
.\"
.\"  John S. Kallal -
.\"	email: <kallal@voicenet.com>
.\"	mail: 518 Kerfoot Farm RD, Wilmington, DE 19803-2444, USA
.\"	phone: (302)654-5478
.\"
.\" $Id: initrd.4,v 0.9 1997/11/07 05:05:32 kallal Exp kallal $
.TH initrd 4 2023-02-05 "Linux man-pages 6.04"
.SH NAME
initrd \- boot loader initialized RAM disk
.SH CONFIGURATION
.I /dev/initrd
is a read-only block device assigned
major number 1 and minor number 250.
Typically
.I /dev/initrd
is owned by
root:disk
with mode 0400 (read access by root only).
If the Linux system does not have
.I /dev/initrd
already created, it can be created with the following commands:
.PP
.in +4n
.EX
mknod \-m 400 /dev/initrd b 1 250
chown root:disk /dev/initrd
.EE
.in
.PP
Also, support for both "RAM disk" and "Initial RAM disk"
(e.g.,
.B CONFIG_BLK_DEV_RAM=y
and
.BR CONFIG_BLK_DEV_INITRD=y )
must be compiled directly into the Linux kernel to use
.IR /dev/initrd .
When using
.IR /dev/initrd ,
the RAM disk driver cannot be loaded as a module.
.\"
.\"
.\"
.SH DESCRIPTION
The special file
.I /dev/initrd
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
.IR /dev/initrd "'s"
contents for a two-phase system boot-up.
.PP
In the first boot-up phase, the kernel starts up
and mounts an initial root filesystem from the contents of
.I /dev/initrd
(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.
.\"
.\"
.\"
.SS Boot-up operation
When booting up with
.BR initrd ,
the system boots as follows:
.IP (1) 5
The boot loader loads the kernel program and
.IR /dev/initrd 's
contents into memory.
.IP (2)
On kernel startup,
the kernel uncompresses and copies the contents of the device
.I /dev/initrd
onto device
.I /dev/ram0
and then frees the memory used by
.IR /dev/initrd .
.IP (3)
The kernel then read-write mounts the device
.I /dev/ram0
as the initial root filesystem.
.IP (4)
If the indicated normal root filesystem is also the initial
root filesystem (e.g.,
.IR /dev/ram0 )
then the kernel skips to the last step for the usual boot sequence.
.IP (5)
If the executable file
.I /linuxrc
is present in the initial root filesystem,
.I /linuxrc
is executed with UID 0.
(The file
.I /linuxrc
must have executable permission.
The file
.I /linuxrc
can be any valid executable, including a shell script.)
.IP (6)
If
.I /linuxrc
is not executed or when
.I /linuxrc
terminates, the normal root filesystem is mounted.
(If
.I /linuxrc
exits with any filesystems mounted on the initial root
filesystem, then the behavior of the kernel is
.BR UNSPECIFIED .
See the NOTES section for the current kernel behavior.)
.IP (7)
If the normal root filesystem has a directory
.IR /initrd ,
the device
.I /dev/ram0
is moved from
.I /
to
.IR /initrd .
Otherwise, if the directory
.I /initrd
does not exist, the device
.I /dev/ram0
is unmounted.
(When moved from
.I /
to
.IR /initrd ,
.I /dev/ram0
is not unmounted and therefore processes can remain running from
.IR /dev/ram0 .
If directory
.I /initrd
does not exist on the normal root filesystem
and any processes remain running from
.I /dev/ram0
when
.I /linuxrc
exits, the behavior of the kernel is
.BR UNSPECIFIED .
See the NOTES section for the current kernel behavior.)
.IP (8)
The usual boot sequence (e.g., invocation of
.IR /sbin/init )
is performed on the normal root filesystem.
.\"
.\"
.\"
.SS Options
The following boot loader options, when used with
.BR initrd ,
affect the kernel's boot-up operation:
.TP
.BI initrd= "filename"
Specifies the file to load as the contents of
.IR /dev/initrd .
For
.B LOADLIN
this is a command-line option.
For
.B LILO
you have to use this command in the
.B LILO
configuration file
.IR /etc/lilo.config .
The filename specified with this
option will typically be a gzipped filesystem image.
.TP
.B noinitrd
This boot option disables the two-phase boot-up operation.
The kernel performs the usual boot sequence as if
.I /dev/initrd
was not initialized.
With this option, any contents of
.I /dev/initrd
loaded into memory by the boot loader contents are preserved.
This option permits the contents of
.I /dev/initrd
to be any data and need not be limited to a filesystem image.
However, device
.I /dev/initrd
is read-only and can be read only one time after system startup.
.TP
.BI root= "device-name"
Specifies the device to be used as the normal root filesystem.
For
.B LOADLIN
this is a command-line option.
For
.B LILO
this is a boot time option or
can be used as an option line in the
.B LILO
configuration file
.IR /etc/lilo.config .
The device specified by this option must be a mountable
device having a suitable root filesystem.
.\"
.\"
.\"
.SS Changing the normal root filesystem
By default,
the kernel's settings
(e.g., set in the kernel file with
.BR rdev (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
and
.B nfs_root_addrs
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
.\" commit dc7a08166f3a5f23e79e839a8a88849bd3397c32
(or
.I Documentation/filesystems/nfsroot.txt
before Linux 2.6.33).
For more information on setting the root filesystem see also the
.B LILO
and
.B LOADLIN
documentation.
.PP
It is also possible for the
.I /linuxrc
executable to change the normal root device.
For
.I /linuxrc
to change the normal root device,
.I /proc
must be mounted.
After mounting
.IR /proc ,
.I /linuxrc
changes the normal root device by writing into the proc files
.IR /proc/sys/kernel/real\-root\-dev ,
.IR /proc/sys/kernel/nfs\-root\-name ,
and
.IR /proc/sys/kernel/nfs\-root\-addrs .
For a physical root device, the root device is changed by having
.I /linuxrc
write the new root filesystem device number into
.IR /proc/sys/kernel/real\-root\-dev .
For an NFS root filesystem, the root device is changed by having
.I /linuxrc
write the NFS setting into files
.I /proc/sys/kernel/nfs\-root\-name
and
.I /proc/sys/kernel/nfs\-root\-addrs
and then writing 0xff (e.g., the pseudo-NFS-device number) into file
.IR /proc/sys/kernel/real\-root\-dev .
For example, the following shell command line would change
the normal root device to
.IR /dev/hdb1 :
.PP
.in +4n
.EX
echo 0x365 >/proc/sys/kernel/real\-root\-dev
.EE
.in
.PP
For an NFS example, the following shell command lines would change the
normal root device to the NFS directory
.I /var/nfsroot
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":
.PP
.in +4n
.EX
echo /var/nfsroot >/proc/sys/kernel/nfs\-root\-name
echo 193.8.232.2:193.8.232.7::255.255.255.0:idefix \e
    >/proc/sys/kernel/nfs\-root\-addrs
echo 255 >/proc/sys/kernel/real\-root\-dev
.EE
.in
.PP
.BR Note :
The use of
.I /proc/sys/kernel/real\-root\-dev
to change the root filesystem is obsolete.
See the Linux kernel source file
.I Documentation/admin\-guide/initrd.rst
.\" commit 9d85025b0418163fae079c9ba8f8445212de8568
(or
.I Documentation/initrd.txt
before Linux 4.10)
as well as
.BR pivot_root (2)
and
.BR pivot_root (8)
for information on the modern method of changing the root filesystem.
.\" FIXME . Should this manual page  describe the pivot_root mechanism?
.\"
.\"
.\"
.SS Usage
The main motivation for implementing
.B initrd
was to allow for modular kernel configuration at system installation.
.PP
A possible system installation scenario is as follows:
.IP (1) 5
The loader program boots from floppy or other media with a minimal kernel
(e.g., support for
.IR /dev/ram ,
.IR /dev/initrd ,
and the ext2 filesystem) and loads
.I /dev/initrd
with a gzipped version of the initial filesystem.
.IP (2)
The executable
.I /linuxrc
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.
.IP (3)
The executable
.I /linuxrc
loads the necessary modules from the initial root filesystem.
.IP (4)
The executable
.I /linuxrc
creates and populates the root filesystem.
(At this stage the normal root filesystem does not have to be a
completed system yet.)
.IP (5)
The executable
.I /linuxrc
sets
.IR /proc/sys/kernel/real\-root\-dev ,
unmounts
.IR /proc ,
the normal root filesystem and any other filesystems
it has mounted, and then terminates.
.IP (6)
The kernel then mounts the normal root filesystem.
.IP (7)
Now that the filesystem is accessible and intact,
the boot loader can be installed.
.IP (8)
The boot loader is configured to load into
.I /dev/initrd
a filesystem with the set of modules that was used to bring up the system.
(e.g., device
.I /dev/ram0
can be modified, then unmounted, and finally, the image is written from
.I /dev/ram0
to a file.)
.IP (9)
The system is now bootable and additional installation tasks can be
performed.
.PP
The key role of
.I /dev/initrd
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.
.PP
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
file or a file executed by
.I /linuxrc
would be different.
.PP
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
can use a dialog and/or auto-detection followed by a
possible sanity check.
.PP
Last but not least, Linux distributions on CD-ROM may use
.B initrd
for easy installation from the CD-ROM.
The distribution can use
.B LOADLIN
to directly load
.I /dev/initrd
from CD-ROM without the need of any floppies.
The distribution could also use a
.B LILO
boot floppy and then bootstrap a bigger RAM disk via
.I /dev/initrd
from the CD-ROM.
.\"
.\"
.\"
.SH FILES
.I /dev/initrd
.br
.I /dev/ram0
.br
.I /linuxrc
.br
.I /initrd
.\"
.\"
.\"
.SH NOTES
.IP \[bu] 3
With the current kernel, any filesystems that remain mounted when
.I /dev/ram0
is moved from
.I /
to
.I /initrd
continue to be accessible.
However, the
.I /proc/mounts
entries are not updated.
.IP \[bu]
With the current kernel, if directory
.I /initrd
does not exist, then
.I /dev/ram0
will
.B not
be fully unmounted if
.I /dev/ram0
is used by any process or has any filesystem mounted on it.
If
.I /dev/ram0
is
.B not
fully unmounted, then
.I /dev/ram0
will remain in memory.
.IP \[bu]
Users of
.I /dev/initrd
should not depend on the behavior given in the above notes.
The behavior may change in future versions of the Linux kernel.
.\"
.\"
.\"
.\" .SH AUTHORS
.\" The kernel code for device
.\" .BR initrd
.\" was written by Werner Almesberger <almesber@lrc.epfl.ch> and
.\" Hans Lermen <lermen@elserv.ffm.fgan.de>.
.\" The code for
.\" .BR initrd
.\" was added to the baseline Linux kernel in development version 1.3.73.
.SH SEE ALSO
.BR chown (1),
.BR mknod (1),
.BR ram (4),
.BR freeramdisk (8),
.BR rdev (8)
.PP
.I Documentation/admin\-guide/initrd.rst
.\" commit 9d85025b0418163fae079c9ba8f8445212de8568
(or
.I Documentation/initrd.txt
before Linux 4.10)
in the Linux kernel source tree, the LILO documentation,
the LOADLIN documentation, the SYSLINUX documentation