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
|
.\" SPDX-License-Identifier: AGPL-3.0-or-later
.\" Copyright (c) 2022 Red Hat GmbH
.\" Author: Stefano Brivio <sbrivio@redhat.com>
.TH mbuto 1
.SH NAME
.B mbuto
\- Host-agnostic initramfs image builder for lightweight virtual machines
.SH SYNOPSIS
.B mbuto [\fIOPTIONS\fR\fB] [\fIADD_ON\fR\fB]...
.SH DESCRIPTION
.B mbuto \fR(\fIM\fRinimal \fIB\fRuilder \fIU\fRsing \fIT\fRerse \fIO\fRptions)
builds Linux initramfs images suitable for lightweight virtual machine
environments, without relying on distribution-specific tools (such as
\fBdracut\fR(8), \fBdebootstrap\fR(8), \fBmkinitramfs\fR(8), etc.) or
containerised environments.
Programs are sourced from the host, together with required dynamic libraries.
Kernel modules, links, and initial device nodes are configured manually. A
convenience support for distribution packages is supplied, with the sole
function of extracting packages, ignoring dependencies, without an actual
installation process.
For pre-defined profiles covering common tasks and use cases, see
\fBPROFILES\fR.
\fIADD_ON\fR can be a list of additional programs, kernel module names, device
nodes, or generic files. The type is auto-detected.
.SH OPTIONS
.TP
.BR \-c " " \fIgzip\fR|\fIlz4\fR|\fIlzma\fR|\fIauto\fR|\fInone\fR
Compression method for CPIO file: \fIauto\fR picks the method resulting in the
shortest decompression time, measured on the output image (average of five
runs). Default is \fInone\fR.
.TP
.BR \-d
Do not strip binary objects. By default, debugging information is stripped from
copied binary objects.
.TP
.BR \-f " " \fIpath
Path for initramfs output. By default, a temporary file is created.
If the initramfs image already exists, add the given \fIADD_ON\fR to it.
.TP
.BR \-k " " \fIversion
Installed kernel version to source associated modules from. By default, the
currently running kernel version (as reported by uname(1)) is used.
.TP
.BR \-m " " \fIpath
Relative root directory for \fI/lib/modules\fR. Default: /
.TP
.BR \-p " " \fIprofile\fR|\fIfile\fR
Profile for add-ons, specific init script and format of printed command result.
Can be one of built-in \fIprofile\fRs \fIbase\fR, \fIbash\fR, \fIkata\fR,
\fIkata_debug\fR, \fIpasst\fR, \fIkselftests\fR, or a shell script \fIfile\fR
including bare assignments (not in a function) for the desired image parameters.
To avoid collisions with built-in profiles, \fIfile\fR needs to be specified as
a command, e.g. \fI./passt\fR and not \fIpasst\fR.
See \fBPROFILES\fR below for further details.
.TP
.BR \-s " " \fIscript\fR|\fI-\fR
Path to fix-up script to run before init, which can be used to replace the one
defined by the profile. \fI-\fR disables the pre-init fix-up script.
.TP
.BR \-v
Enable verbose operation.
.TP
.BR \-h
Display help message with usage and options.
.SH ENVIRONMENTAL VARIABLES
Environmental variables can be used to replace:
.TP
.BR \fBPROGS\fI
Base programs, to be included in the image, defined by the profile.
.BR \fBLIBS_DLOPEN\fI
Additional libraries, not directly linked from programs, typically loaded via
dlopen(3) by matching libraries, in the form:
\fBMATCHING_LIBRARY\fR \fBADDITIONAL_LIBRARY\fI
.TP
.BR \fBKMODS\fI
Base kernel modules, defined by the profile.
.TP
.BR \fBNODES\fI
Device nodes, copied from host if just the name is given, and created otherwise
if in the form:
\fBNAME\fR,\fBTYPE\fR,\fBMAJOR\fR,\fBMINOR
.TP
.BR \fBLINKS\fI
Link to programs by name, as space-separated pairs of:
\fBPROGRAM\fR \fBPATH\fR
.TP
.BR \fBDIRS\fI
List of initial set of empty directories
.TP
.BR \fBCOPIES\fI
Lists of paths to be copied, recursively, preserving attributes and parents.
.SH PROFILES
Profiles define sets of base programs, links, kernel modules, and pre-init
scripts to cover common use cases. These built-in profiles are currently
available:
.TP
.BR \fBbase\fI
The bare minimum to start an interactive shell.
.TP
.BR \fBbash\fI
Start bash with a few kernel modules and tools to enable basic filesystem usage
and networking configuration.
.TP
.BR \fBkata\fI
Creates a guest image suitable for usage with Kata Containers
(https://katacontainers.io): source \fIkata-agent\fR and perform cgroup setup
in pre-init.
.TP
.BR \fBkata_debug\fI
Creates a guest image intented to debug issues with Kata Containers
(https://katacontainers.io): include some more utilities on top of the ones
sourced by the \fIkata\fR profile, and starts an interactive shell before
starting \fIkata-agent\fR.
.TP
.BR \fBpasst\fI
Creates a guest image used to run the test suite of \fBpasst\fR(1)
(https://passt.top), including a number of networking utilities among others.
.TP
.BR \fBkselftests\fI
Creates a guest image including a set of Linux kernel selftests
(https://kselftest.wiki.kernel.org/) together with the tools needed to run them.
Modules and test programs are selected depending on the given test collections,
and, for convenience, this profile also triggers installation of modules and
test programs to temporary directories.
The following sub-options are provided:
.RS
.TP
.BR \-L
List available collections.
.TP
.BR \-C " " \fIcollection\fR
Select a collection of tests to run. Collections are defined by the set of
targets in \fBtools/testing/selftests/Makefile\fR of the Linux kernel tree.
.TP
.BR \-T " " \fIcollection\fR:\fItest\fR
Select a specific test to run, within a collection. Available tests are listed
by \fITEST_PROGS\fR variables in the Makefile of a test subdirectory.
.RE
.SH EXAMPLES
.TP
.BR "Build a base image as temporary file"
.RS
.nf
$ mbuto
Applying profile base
Creating image: /tmp/tmp.hbRUmHpR3a
Size: bin 353k lib 4.0M kmod 213k total 4.6M compressed 4.5M
/tmp/tmp.hbRUmHpR3a
.fi
.RE
.TP
.BR "Build a base image including grep and needed libraries"
.RS
.nf
$ mbuto grep
Applying profile base
Creating image: /tmp/tmp.RXC8K7altF
Size: bin 562k lib 4.0M kmod 213k total 4.8M compressed 4.7M
/tmp/tmp.RXC8K7altF
.fi
.RE
.TP
.BR "Run an interactive shell with \fBqemu\fR(1)"
.RS
.nf
$ kvm -kernel /boot/vmlinuz-$(uname -r) -initrd $(mbuto) \\
-nodefaults -nographic -append console=ttyS0 -serial stdio
.fi
.RE
.TP
.BR "Run the " \fItimens\fR " kselftests collection"
.RS
.nf
$ cd linux
$ kvm -kernel arch/x86/boot/bzImage \\
-initrd $(mbuto -p kselftests -C timens) \\
-nodefaults -nographic -append console=ttyS0 -serial stdio
.fi
.RE
.TP
.BR "Run the " \fIrtcpie\fR " kselftest from the " \fItimers\fR " collection"
.RS
.nf
$ cd linux
$ mbuto -p kselftests -T timers.rtcpie -f test.img
$ kvm -kernel arch/x86/boot/bzImage -initrd test.img \\
-nodefaults -nographic -append console=ttyS0 -serial stdio
.fi
.RE
.SH AUTHORS
Stefano Brivio <sbrivio@redhat.com>, Sevinj Aghayeva <sevinj.aghayeva@gmail.com>
.SH REPORTING BUGS
Please send reports or patches via e-mail to the authors.
.SH COPYRIGHT
Copyright (c) 2020-2022 Red Hat GmbH.
\fBmbuto\fR is free software: you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
.SH SEE ALSO
\fBqemu\fR(1), \fBsupermin\fR(1), \fBdracut\fR(8), \fBmkinitramfs\fR(8),
\fBdebootstrap\fR(8).
See example terminal captures at https://mbuto.sh.
|