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
|
/////
vim:set ts=4 sw=4 syntax=asciidoc noet:
/////
mkinitcpio(8)
=============
Name
----
mkinitcpio - Create an initial ramdisk environment
Synopsis
--------
'mkinitcpio' [options]
Description
-----------
Creates an initial ramdisk environment for booting the linux kernel. The
initial ramdisk is in essence a very small environment (early userspace) which
loads various kernel modules and sets up necessary things before handing over
control to init. This makes it possible to have, for example, encrypted root
filesystems and root filesystems on a software RAID array. mkinitcpio allows
for easy extension with custom hooks, has autodetection at runtime, and many
other features.
Options
-------
*-A, \--addhooks* 'hooks'::
Add the additional 'hooks' to the image. These will be processed in order
after all other hooks from the config file. Multiple hooks should be
comma-separated. This option can be specified multiple times.
*-c, \--config* 'config'::
Use 'config' file to generate the ramdisk. Default: /etc/mkinitcpio.conf
*-d, \--generatedir* 'directory'::
Set 'directory' as the location where the initramfs is built. This might be
useful to generate a shutdown ramfs in '/run/initramfs'.
*-g, \--generate* 'filename'::
Generate a CPIO image as 'filename'. Default: no; this means nothing will be
written to the filesystem unless this option is specified.
*-H, \--hookhelp* 'hookname'::
Output help for hookname 'hookname'.
*-h, \--help*::
Output a short overview of available command-line switches.
*-k, \--kernel* 'kernelversion'::
Use 'kernelversion', instead of the current running kernel. This may be a
path to a kernel image (only supported for x86-based architectures), a specific
kernel version or the special keyword 'none'. In the latter case, no kernel
modules are added to the image.
*-L, \--listhooks*::
List all available hooks.
*-M, \--automods*::
Display modules found via autodetection. mkinitcpio will automatically try to
determine which kernel modules are needed to start your computer. This option
lists which modules were detected.
*-n, \--nocolor*::
Disable color output.
*-P, \--allpresets*::
Process all presets contained in '/etc/mkinitcpio.d'. See the '-p' option for
more detail about presets.
*-p, \--preset* 'preset'::
Build initramfs image(s) according to specified 'preset'. This may be a file in
/etc/mkinitcpio.d (without the .preset extension) or a full, absolute path to a
file. This option may be specified multiple times to process multiple presets.
*-r, \--moduleroot* 'root'::
Specifies the root directory to find modules in, defaulting to '/'.
*-S, \--skiphooks* 'hooks'::
Skip 'hooks' when generating the image. Multiple hooks should be comma-separated.
This option can be specified multiple times.
*-s, \--save*::
Saves the build directory for the initial ramdisk. Default: no; This means
the directory will not be retained if this option isn't specified. Useful for
debugging purposes.
*-t, \--builddir* 'tmpdir'::
Use 'tmpdir' as the temporary build directory instead of /tmp. 'tmpdir'
must exist. The 'TMPDIR' environment variable is also honored to set this
location, but the command line option will take precedence.
*-V, \--version*::
Display version information.
*-v, \--verbose*::
Verbose output. Outputs more information about what's happening during
creation of the ramdisk.
*-z, \--compress* 'compress'::
Override the compression method with the 'compress' program.
About Presets
-------------
A preset is a pre-defined definition on how to create an initial ramdisk.
Instead of specifying the configuration file and which output file, every time
you generate a new initial ramdisk, you define a preset and use the -p switch
to generate an initial ramdisk according to your preset. Presets are located in
/etc/mkinitcpio.d
About Install Hooks
-------------------
Install hooks are bash scripts which are sourced during mkinitcpio runtime in
order to add modules, binaries, and other files to the image. A variety of
functions exist to facilitate this.
*add_module* 'modname'::
Adds the module specified by 'modname' to the image. Dependencies are derived
and added automatically.
*add_binary* 'binary' [ 'destination' ] [ 'mode' ]::
Adds a binary to the image. The argument 'binary' need not be an absolute
path and, if needed, a lookup will be performed. If the binary is a dynamically
linked ELF binary, dependencies will be automatically added. Optionally, a
destination within the initramfs image as well as a file mode can be specified.
By default, the destintation and mode be taken from the source derived from
'binary'.
*add_file* 'path' [ 'destination' ] [ 'mode' ]::
Adds a file and any needed parent directories to the image. Optionally, a
destination within the initramfs image as well as a file mode can be specified.
By default, the destination and mode will be taken from the source and mode of
the file specified by the 'path'.
*add_dir* 'path'::
Adds a directory and its parents to the image.
*add_full_dir* 'directory' [ 'glob' ]::
Recursively adds a directory to the image by walking the given path and
calling *add_file*, *add_dir*, and *add_symlink* accordingly. This function
will not follow symlinks, nor will it add the targets of symlinks.
If the 'glob' argument is passed, only files and symlinks matching this glob
will be added.
*add_symlink* 'path' [ 'link-target' ]::
Adds a symlink to the image at the specified `path`, optionally pointing to
the specified `link-target`. If the `link-target` is not provided, it is assumed
that this symlink exists in the real filesystem, and the target will be read
using readlink. There is no checking done to ensure that the target of the
symlink exists, and symlinks will not be followed recursively.
*add_all_modules* [ '-f filter' ] *pattern*::
Adds modules to the image, without regard for the autodetect whitelist. *pattern*
should be a subdirectory within the kernel tree describing a subset of modules to
be included. Further refinement can be provided via the -f flag with an extended
regular expression.
*add_checked_modules* [ '-f filter' ] *pattern*::
Similar to *add_all_modules* with the constraint that only modules matching the
whitelist generated by the autodetect hook will be added to the image. If the
autodetect hook is not present in the image, this function is identical to
*add_all_modules*.
*add_runscript*::
Adds a runtime hook to the image, which is a busybox ash compatible shell
script. The name of the script is guaranteed to match the name of the hook the
script is called from.
About Runtime Hooks
-------------------
Runtime hooks added to the image via the *add_runscript* function from an
install hook are able to provide extra functionality during early userspace.
Specific functions in these files will run at different times. A hook can
define one or more of these. At each hook point, hooks are run in the order
that they are defined in the HOOKS variable, except for cleanup hooks which are
run in reverse.
*run_earlyhook*::
Functions of this name will be run once the API mounts have been setup and the
kernel command line has been parsed. Daemons needed for early userspace should
be started from this hook point.
*run_hook*::
Functions of this name will be run after any early hooks, and after user
defined modules have been installed. This is the most common hook point, and
functionality such as scanning for LVM volumes and mapping encrypted volumes
should be performed here.
*run_latehook*::
Functions of this name will be run after root has been mounted. This is generally
used for further necessary setup in the real root, such as mounting other system
partitions.
*run_cleanuphook*::
Functions of this name are run as late as possible. Any daemons started
from a run_earlyhook function should be shut down here in preparation for
switching to the real root.
Early Init Environment
----------------------
mkinitcpio gives special treatment to certain environment variables passed on
the kernel command line:
*break*['=<premount|postmount>']::
If specified, mkinitcpio will start a shell during early init. The optional
parameter controls when this occurs: when 'premount' or no parameter are
specified, the shell will be launched prior to mounting root. If 'postmount'
is specified, the shell will be launched after mounting root.
*disablehooks=*'hooklist'::
This is a comma separated list of hooks which will be skipped during early
init.
*earlymodules=*'modulelist'::
This is a comma separated list of modules which will be loaded prior to any
others. This is generally not needed, and usually points to a configuration
or kernel problem.
*quiet*::
Causes mkinitcpio to output fewer messages during boot. Errors will not be
suppressed.
*ro*::
Specifies that root should be mounted with readonly permissions. This is the
default behavior.
*rw*::
Specifies that root should be mounted with readwrite permissions. This is
generally only useful if your initramfs uses the 'fsck' hook.
*root=*'rootdevice'::
This variable describes the root partition which early init will mount
before passing control to the real init. mkinitcpio understands a variety of
formats, the most basic of which is the path to the block device, either
directly such as '/dev/sda2', or using a udev symlink such as
'/dev/disk/by-label/CorsairF80-root'. Support for identification by LABEL or
UUID tags are also supported, such as, 'LABEL=CorsairF80-root'. As of
util-linux 2.22, PARTUUID and PARTLABEL are also supported. Identification
via hex encoded major/minor device ID is supported for legacy reasons, but
should be avoided as it tends to be fragile.
*rootdelay=*'seconds'::
Sets the delay, in seconds, that mkinitcpio is willing to wait for the root
device to show up, if it is not available immediately. This defaults to 10
seconds. If an invalid integer is passed, this variable will have no effect.
*rootflags=*'flaglist'::
A comma-separated list of flags which will be passed onto the *mount*(8)
command when mounting the root filesystem. Acceptable values are filesystem
specific.
*rootfstype=*'fstype'::
Overrides the type of filesystem being mounted as root. This should almost never
be needed as *mount*(8) usually detects this on its own.
*rd.debug*::
Enables shell debug (xtrace). If 'rd.log' is not also a parameter on the kernel
command line, this parameter implies 'rd.log=console'.
*rd.log*['=<console|file|kmsg|all>']::
Enables logging of early userspace messages. If specified, the optional
parameter describes where this information is logged. Multiple options can be
OR'd together using the pipe (|) character. Messages are always logged to
the console unless the 'quiet' parameter is passed. If the optional parameter
is not specified, 'kmsg|console' is assumed. If 'rd.log' is not present on the
kernel command line, no logging will take place.
*console*;;
Writes output to '/dev/console'.
*file*;;
Writes output to '/run/initramfs/init.log'.
*kmsg*;;
Writes output to the '/dev/kmsg' device (introduced in Linux 3.5). This
option is a no-op if your kernel lacks support for '/dev/kmsg'.
*all*;;
Writes output to all known log targets.
These are only the variables that the core of mkinitcpio honor. Additional
hooks may look for other environment variables and should be documented by the
help output for the hook.
Files
-----
'/etc/mkinitcpio.conf'::
Default configuration file for mkinitcpio.
'/etc/mkinitcpio.d'::
Directory containing mkinitcpio presets.
'/etc/initcpio/install'::
'/usr/lib/initcpio/install'::
Search path for build time hooks.
'/etc/initcpio/hooks'::
'/usr/lib/initcpio/hooks'::
Search path for early userspace runtime hooks.
Examples
--------
*mkinitcpio*::
Perform a 'dry-run'. This will generate an initial ramdisk but will not
write anything. Use -g to create the real image.
*mkinitcpio -p linux*::
Create an initial ramdisk based on the 'linux' preset.
*mkinitcpio -g /boot/initramfs-linux.img -k /boot/vmlinuz-linux*::
Create an initial ramdisk for the kernel at /boot/vmlinuz-linux. The
resulting image will be written to /boot/initramfs-linux.img.
See also
--------
A more thorough article on configuring mkinitcpio:
<http://wiki.archlinux.org/index.php/Mkinitcpio>
*initrd*(4), *lsinitcpio*(1), *mkinitcpio.conf*(5), *bootparam*(7)
Bugs
----
Upon writing this manpage, there were no noticeable bugs present. Please visit
<http://bugs.archlinux.org/> for an up to date list.
Authors
-------
mkinitcpio is created and maintained by the Arch Linux Developer community.
Copyright
---------
Copyright (c) Arch Linux 2006-2012
|