1virt-builder(1)             Virtualization Support             virt-builder(1)
2
3
4

NAME

6       virt-builder - Build virtual machine images quickly
7

SYNOPSIS

9        virt-builder os-version
10           [-o|--output DISKIMAGE] [--size SIZE] [--format raw|qcow2]
11           [--arch ARCHITECTURE] [--attach ISOFILE]
12           [--append-line FILE:LINE] [--chmod PERMISSIONS:FILE]
13           [--commands-from-file FILENAME] [--copy SOURCE:DEST]
14           [--copy-in LOCALPATH:REMOTEDIR] [--delete PATH] [--edit FILE:EXPR]
15           [--firstboot SCRIPT] [--firstboot-command 'CMD+ARGS']
16           [--firstboot-install PKG,PKG..] [--hostname HOSTNAME]
17           [--install PKG,PKG..] [--link TARGET:LINK[:LINK..]] [--mkdir DIR]
18           [--move SOURCE:DEST] [--password USER:SELECTOR]
19           [--root-password SELECTOR] [--run SCRIPT]
20           [--run-command 'CMD+ARGS'] [--scrub FILE] [--sm-attach SELECTOR]
21           [--sm-register] [--sm-remove] [--sm-unregister]
22           [--ssh-inject USER[:SELECTOR]] [--truncate FILE]
23           [--truncate-recursive PATH] [--timezone TIMEZONE] [--touch FILE]
24           [--uninstall PKG,PKG..] [--update] [--upload FILE:DEST]
25           [--write FILE:CONTENT] [--no-logfile]
26           [--password-crypto md5|sha256|sha512] [--selinux-relabel]
27           [--sm-credentials SELECTOR]
28
29
30        virt-builder -l|--list [--long] [--list-format short|long|json] [os-version]
31
32        virt-builder --notes os-version
33
34        virt-builder --print-cache
35
36        virt-builder --cache-all-templates
37
38        virt-builder --delete-cache
39
40        virt-builder --get-kernel DISKIMAGE
41           [--format raw|qcow2] [--output OUTPUTDIR]
42

DESCRIPTION

44       Virt-builder is a tool for quickly building new virtual machines.  You
45       can build a variety of VMs for local or cloud use, usually within a few
46       minutes or less.  Virt-builder also has many ways to customize these
47       VMs.  Everything is run from the command line and nothing requires root
48       privileges, so automation and scripting is simple.
49
50       Note that virt-builder does not install guests from scratch.  It takes
51       cleanly prepared, digitally signed OS templates and customizes them.
52       This approach is used because it is much faster, but if you need to do
53       fresh installs you may want to look at virt-install(1) and
54       oz-install(1).
55
56       The easiest way to get started is by looking at the examples in the
57       next section.
58

EXAMPLES

60   List the virtual machines available
61        virt-builder --list
62
63       will list out the operating systems available to install.  A selection
64       of freely redistributable OSes is available as standard.  You can add
65       your own too (see below).
66
67       After choosing a guest from the list, you may want to see if there are
68       any installation notes:
69
70        virt-builder --notes fedora-27
71
72   Build a virtual machine
73        virt-builder fedora-27
74
75       will build a Fedora 25 image for the same architecture as virt-builder
76       (so running it from an i686 installation will try to build an i686
77       image, if available).  This will have all default configuration
78       (minimal size, no user accounts, random root password, only the bare
79       minimum installed software, etc.).
80
81       You do not need to run this command as root.
82
83       The first time this runs it has to download the template over the
84       network, but this gets cached (see "CACHING").
85
86       The name of the output file is derived from the template name, so above
87       it will be fedora-27.img.  You can change the output filename using the
88       -o option:
89
90        virt-builder fedora-27 -o mydisk.img
91
92       You can also use the -o option to write to existing devices or logical
93       volumes.
94
95        virt-builder fedora-27 --format qcow2
96
97       As above, but write the output in qcow2 format to fedora-27.qcow2.
98
99        virt-builder fedora-27 --size 20G
100
101       As above, but the output size will be 20 GB.  The guest OS is resized
102       as it is copied to the output (automatically, using virt-resize(1)).
103
104        virt-builder fedora-27 --arch i686
105
106       As above, but using an i686 template, if available.
107
108   Setting the root password
109        virt-builder fedora-27 --root-password file:/tmp/rootpw
110
111       Create a Fedora 25 image.  The root password is taken from the file
112       /tmp/rootpw.
113
114       Note if you don’t set --root-password then the guest is given a random
115       root password which is printed on stdout.
116
117       You can also create user accounts.  See "USERS AND PASSWORDS" below.
118
119   Set the hostname
120        virt-builder fedora-27 --hostname virt.example.com
121
122       Set the hostname to "virt.example.com".
123
124   Installing software
125       To install packages from the ordinary (guest) software repository (eg.
126       dnf or apt):
127
128        virt-builder fedora-27 --install "inkscape,@Xfce Desktop"
129
130       (In Fedora, "@" is used to install groups of packages.  On Debian you
131       would install a meta-package instead.)
132
133       To update the installed packages to the latest version:
134
135        virt-builder debian-7 --update
136
137       For guests which use SELinux, like Fedora and Red Hat Enterprise Linux,
138       you may need to do SELinux relabelling after installing or updating
139       packages (see "SELINUX" below):
140
141        virt-builder fedora-27 --update --selinux-relabel
142
143   Customizing the installation
144       There are many options that let you customize the installation.  These
145       include: --run/--run-command, which run a shell script or command while
146       the disk image is being generated and lets you add or edit files that
147       go into the disk image.  --firstboot/--firstboot-command, which let you
148       add scripts/commands that are run the first time the guest boots.
149       --edit to edit files.  --upload to upload files.
150
151       For example:
152
153        cat <<'EOF' > /tmp/dnf-update.sh
154        dnf -y --best update
155        EOF
156
157        virt-builder fedora-27 --firstboot /tmp/dnf-update.sh
158
159       or simply:
160
161        virt-builder fedora-27 --firstboot-command 'dnf -y --best update'
162
163       which makes the dnf(8) "update" command run once the first time the
164       guest boots.
165
166       Or:
167
168        virt-builder fedora-27 \
169          --edit '/etc/dnf/dnf.conf:
170                    s/gpgcheck=1/gpgcheck=0/'
171
172       which edits /etc/dnf/dnf.conf inside the disk image (during disk image
173       creation, long before boot).
174
175       You can combine these options, and have multiple options of all types.
176

OPTIONS

178       --help
179           Display help.
180
181       --arch ARCHITECTURE
182           Use the specified architecture for the output image.  This means
183           there must be sources providing the requested template for the
184           requested architecture.
185
186           See also "ARCHITECTURE".
187
188       --attach ISOFILE
189           During the customization phase, the given disk is attached to the
190           libguestfs appliance.  This is used to provide extra software
191           repositories or other data for customization.
192
193           You probably want to ensure the volume(s) or filesystems in the
194           attached disks are labelled (or use an ISO volume name) so that you
195           can mount them by label in your run-scripts:
196
197            mkdir /tmp/mount
198            mount LABEL=EXTRA /tmp/mount
199
200           You can have multiple --attach options, and the format can be any
201           disk format (not just an ISO).
202
203           See also: --run, "Installing packages at build time from a side
204           repository", genisoimage(1), virt-make-fs(1).
205
206       --attach-format FORMAT
207           Specify the disk format for the next --attach option.  The "FORMAT"
208           is usually "raw" or "qcow2".  Use "raw" for ISOs.
209
210       --cache DIR
211       --no-cache
212           --cache DIR sets the directory to use/check for cached template
213           files.  If not set, defaults to either
214           $XDG_CACHE_HOME/virt-builder/ or $HOME/.cache/virt-builder/.
215
216           --no-cache disables template caching.
217
218       --cache-all-templates
219           Download all templates to the cache and then exit.  See "CACHING".
220
221           Note this doesn't cache everything.  More templates might be
222           uploaded.  Also this doesn't cache packages (the --install,
223           --update options).
224
225       --check-signature
226       --no-check-signature
227           Check/don’t check the digital signature of the OS template.  The
228           default is to check the signature and exit if it is not correct.
229           Using --no-check-signature bypasses this check.
230
231           See also --fingerprint.
232
233       --colors
234       --colours
235           Use ANSI colour sequences to colourize messages.  This is the
236           default when the output is a tty.  If the output of the program is
237           redirected to a file, ANSI colour sequences are disabled unless you
238           use this option.
239
240       --curl CURL
241           Specify an alternate curl(1) binary.  You can also use this to add
242           curl parameters, for example to disable https certificate checks:
243
244            virt-builder --curl "curl --insecure" [...]
245
246       --delete-cache
247           Delete the template cache.  See "CACHING".
248
249       --no-delete-on-failure
250           Don’t delete the output file on failure to build.  You can use this
251           to debug failures to run scripts.  See "DEBUGGING BUILDS" for ways
252           to debug images.
253
254           The default is to delete the output file if virt-builder fails (or,
255           for example, some script that it runs fails).
256
257       --fingerprint 'AAAA BBBB ...'
258           Check that the index and templates are signed by the key with the
259           given fingerprint.  (The fingerprint is a long string, usually
260           written as 10 groups of 4 hexadecimal digits).
261
262           You can give this option multiple times.  If you have multiple
263           source URLs, then you can have either no fingerprint, one
264           fingerprint or multiple fingerprints.  If you have multiple, then
265           each must correspond 1-1 with a source URL.
266
267       --format qcow2
268       --format raw
269           For ordinary builds, this selects the output format.  The default
270           is raw.
271
272           With --get-kernel this specifies the input format.
273
274           To create an old-style qcow2 file (for compatibility with RHEL 6 or
275           very old qemu < 1.1), after running virt-builder, use this command:
276
277            qemu-img amend -f qcow2 -o compat=0.10 output.qcow2
278
279       --get-kernel IMAGE
280           This option extracts the kernel and initramfs from a previously
281           built disk image called "IMAGE" (in fact it works for any VM disk
282           image, not just ones built using virt-builder).
283
284           Note this method is deprecated: there is a separate tool for this,
285           virt-get-kernel(1), which has more options for the file extraction.
286
287           The kernel and initramfs are written to the current directory,
288           unless you also specify the --output "outputdir" directory name.
289
290           The format of the disk image is automatically detected unless you
291           specify it by using the --format option.
292
293           In the case where the guest contains multiple kernels, the one with
294           the highest version number is chosen.  To extract arbitrary kernels
295           from the disk image, see guestfish(1).  To extract the entire /boot
296           directory of a guest, see virt-copy-out(1).
297
298       --gpg GPG
299           Specify an alternate gpg(1) (GNU Privacy Guard) binary.  By default
300           virt-builder looks for either "gpg2" or "gpg" in the $PATH.
301
302           You can also use this to add gpg parameters, for example to specify
303           an alternate home directory:
304
305            virt-builder --gpg "gpg --homedir /tmp" [...]
306
307       -l [os-version]
308       --list [os-version]
309       --list --list-format format [os-version]
310       --list --long [os-version]
311           List all the available templates if no guest is specified, or only
312           for the specified one.
313
314           It is possible to choose with --list-format the output format for
315           the list templates:
316
317           short
318               The default format, prints only the template identifier and,
319               next to it, its short description.
320
321           long
322               Prints a textual list with the details of the available
323               sources, followed by the details of the available templates.
324
325           json
326               Prints a JSON object with the details of the available sources
327               and the details of the available templates.
328
329               The "version" key in the main object represents the
330               "compatibility version", and it is bumped every time the
331               resulting JSON output is incompatible with the previous
332               versions (for example the structure has changed, or non-
333               optional keys are no more present).
334
335           --long is a shorthand for the "long" format.
336
337           See also: --source, --notes, "SOURCES OF TEMPLATES".
338
339       --machine-readable
340       --machine-readable=format
341           This option is used to make the output more machine friendly when
342           being parsed by other programs.  See "MACHINE READABLE OUTPUT"
343           below.
344
345       -m MB
346       --memsize MB
347           Change the amount of memory allocated to --run scripts.  Increase
348           this if you find that --run scripts or the --install option are
349           running out of memory.
350
351           The default can be found with this command:
352
353            guestfish get-memsize
354
355       --network
356       --no-network
357           Enable or disable network access from the guest during the
358           installation.
359
360           Enabled is the default.  Use --no-network to disable access.
361
362           The network only allows outgoing connections and has other minor
363           limitations.  See "NETWORK" in virt-rescue(1).
364
365           If you use --no-network then certain other options such as
366           --install will not work.
367
368           This does not affect whether the guest can access the network once
369           it has been booted, because that is controlled by your hypervisor
370           or cloud environment and has nothing to do with virt-builder.
371
372           Generally speaking you should not use --no-network.  But here are
373           some reasons why you might want to:
374
375           1.  Because the libguestfs backend that you are using doesn't
376               support the network.  (See: "BACKEND" in guestfs(3)).
377
378           2.  Any software you need to install comes from an attached ISO, so
379               you don't need the network.
380
381           3.  You don’t want untrusted guest code trying to access your host
382               network when running virt-builder.  This is particularly an
383               issue when you don't trust the source of the operating system
384               templates.  (See "SECURITY" below).
385
386           4.  You don’t have a host network (eg. in secure/restricted
387               environments).
388
389       --no-sync
390           Do not sync the output file on exit.
391
392           Virt-builder "fsync"s the output file or disk image when it exits.
393
394           The reason is that qemu/KVM’s default caching mode is "none" or
395           "directsync", both of which bypass the host page cache.  Therefore
396           these would not work correctly if you immediately started the guest
397           after running virt-builder - they would not see the complete output
398           file.  (Note that you should not use these caching modes - they are
399           fundamentally broken for this and other reasons.)
400
401           If you are not using these broken caching modes, you can use
402           --no-sync to avoid this unnecessary sync and gain considerable
403           extra performance.
404
405       --notes os-version
406           List any notes associated with this guest, then exit (this does not
407           do the install).
408
409       -o filename
410       --output filename
411           Write the output to filename.  If you don’t specify this option,
412           then the output filename is generated by taking the "os-version"
413           string and adding ".img" (for raw format) or ".qcow2" (for qcow2
414           format).
415
416           Note that the output filename could be a device, partition or
417           logical volume.
418
419           When used with --get-kernel, this option specifies the output
420           directory.
421
422       --print-cache
423           Print information about the template cache.  See "CACHING".
424
425       -q
426       --quiet
427           Don’t print ordinary progress messages.
428
429       --size SIZE
430           Select the size of the output disk, where the size can be specified
431           using common names such as "32G" (32 gigabytes) etc.
432
433           Virt-builder will resize filesystems inside the disk image
434           automatically.
435
436           If the size is not specified, then one of two things happens.  If
437           the output is a file, then the size is the same as the template.
438           If the output is a device, partition, etc then the size of that
439           device is used.
440
441           To specify size in bytes, the number must be followed by the
442           lowercase letter b, eg: "--size 10737418240b".
443
444       --smp N
445           Enable N ≥ 2 virtual CPUs for --run scripts to use.
446
447       --source URL
448           Set the source URL to look for indexes.
449
450           You can give this option multiple times to specify multiple
451           sources.
452
453           See also "SOURCES OF TEMPLATES" below.
454
455           Note that you should not point --source to sources that you don’t
456           trust (unless the source is signed by someone you do trust).  See
457           also the --no-network option.
458
459       --no-warn-if-partition
460           Do not emit a warning if the output device is a partition.  This
461           warning avoids a common user error when writing to a USB key or
462           external drive, when you should normally write to the whole device
463           (--output /dev/sdX), not to a partition on the device
464           (--output /dev/sdX1).  Use this option to suppress this warning.
465
466       -v
467       --verbose
468           Enable debug messages and/or produce verbose output.
469
470           When reporting bugs, use this option and attach the complete output
471           to your bug report.
472
473       -V
474       --version
475           Display version number and exit.
476
477       --wrap
478           Wrap error, warning, and informative messages.  This is the default
479           when the output is a tty.  If the output of the program is
480           redirected to a file, wrapping is disabled unless you use this
481           option.
482
483       -x  Enable tracing of libguestfs API calls.
484
485   Customization options
486       --append-line FILE:LINE
487           Append a single line of text to the "FILE".  If the file does not
488           already end with a newline, then one is added before the appended
489           line.  Also a newline is added to the end of the "LINE" string
490           automatically.
491
492           For example (assuming ordinary shell quoting) this command:
493
494            --append-line '/etc/hosts:10.0.0.1 foo'
495
496           will add either "10.0.0.1 foo⏎" or "⏎10.0.0.1 foo⏎" to the file,
497           the latter only if the existing file does not already end with a
498           newline.
499
500           "⏎" represents a newline character, which is guessed by looking at
501           the existing content of the file, so this command does the right
502           thing for files using Unix or Windows line endings.  It also works
503           for empty or non-existent files.
504
505           To insert several lines, use the same option several times:
506
507            --append-line '/etc/hosts:10.0.0.1 foo'
508            --append-line '/etc/hosts:10.0.0.2 bar'
509
510           To insert a blank line before the appended line, do:
511
512            --append-line '/etc/hosts:'
513            --append-line '/etc/hosts:10.0.0.1 foo'
514
515       --chmod PERMISSIONS:FILE
516           Change the permissions of "FILE" to "PERMISSIONS".
517
518           Note: "PERMISSIONS" by default would be decimal, unless you prefix
519           it with 0 to get octal, ie. use 0700 not 700.
520
521       --commands-from-file FILENAME
522           Read the customize commands from a file, one (and its arguments)
523           each line.
524
525           Each line contains a single customization command and its
526           arguments, for example:
527
528            delete /some/file
529            install some-package
530            password some-user:password:its-new-password
531
532           Empty lines are ignored, and lines starting with "#" are comments
533           and are ignored as well.  Furthermore, arguments can be spread
534           across multiple lines, by adding a "\" (continuation character) at
535           the of a line, for example
536
537            edit /some/file:\
538              s/^OPT=.*/OPT=ok/
539
540           The commands are handled in the same order as they are in the file,
541           as if they were specified as --delete /some/file on the command
542           line.
543
544       --copy SOURCE:DEST
545           Copy files or directories recursively inside the guest.
546
547           Wildcards cannot be used.
548
549       --copy-in LOCALPATH:REMOTEDIR
550           Copy local files or directories recursively into the disk image,
551           placing them in the directory "REMOTEDIR" (which must exist).
552
553           Wildcards cannot be used.
554
555       --delete PATH
556           Delete a file from the guest.  Or delete a directory (and all its
557           contents, recursively).
558
559           You can use shell glob characters in the specified path.  Be
560           careful to escape glob characters from the host shell, if that is
561           required.  For example:
562
563            virt-customize --delete '/var/log/*.log'.
564
565           See also: --upload, --scrub.
566
567       --edit FILE:EXPR
568           Edit "FILE" using the Perl expression "EXPR".
569
570           Be careful to properly quote the expression to prevent it from
571           being altered by the shell.
572
573           Note that this option is only available when Perl 5 is installed.
574
575           See "NON-INTERACTIVE EDITING" in virt-edit(1).
576
577       --firstboot SCRIPT
578           Install "SCRIPT" inside the guest, so that when the guest first
579           boots up, the script runs (as root, late in the boot process).
580
581           The script is automatically chmod +x after installation in the
582           guest.
583
584           The alternative version --firstboot-command is the same, but it
585           conveniently wraps the command up in a single line script for you.
586
587           You can have multiple --firstboot options.  They run in the same
588           order that they appear on the command line.
589
590           Please take a look at "FIRST BOOT SCRIPTS" for more information and
591           caveats about the first boot scripts.
592
593           See also --run.
594
595       --firstboot-command 'CMD+ARGS'
596           Run command (and arguments) inside the guest when the guest first
597           boots up (as root, late in the boot process).
598
599           You can have multiple --firstboot options.  They run in the same
600           order that they appear on the command line.
601
602           Please take a look at "FIRST BOOT SCRIPTS" for more information and
603           caveats about the first boot scripts.
604
605           See also --run.
606
607       --firstboot-install PKG,PKG..
608           Install the named packages (a comma-separated list).  These are
609           installed when the guest first boots using the guest’s package
610           manager (eg. apt, yum, etc.) and the guest’s network connection.
611
612           For an overview on the different ways to install packages, see
613           "INSTALLING PACKAGES".
614
615       --hostname HOSTNAME
616           Set the hostname of the guest to "HOSTNAME".  You can use a dotted
617           hostname.domainname (FQDN) if you want.
618
619       --install PKG,PKG..
620           Install the named packages (a comma-separated list).  These are
621           installed during the image build using the guest’s package manager
622           (eg. apt, yum, etc.) and the host’s network connection.
623
624           For an overview on the different ways to install packages, see
625           "INSTALLING PACKAGES".
626
627           See also --update, --uninstall.
628
629       --link TARGET:LINK[:LINK..]
630           Create symbolic link(s) in the guest, starting at "LINK" and
631           pointing at "TARGET".
632
633       --mkdir DIR
634           Create a directory in the guest.
635
636           This uses "mkdir -p" so any intermediate directories are created,
637           and it also works if the directory already exists.
638
639       --move SOURCE:DEST
640           Move files or directories inside the guest.
641
642           Wildcards cannot be used.
643
644       --no-logfile
645           Scrub "builder.log" (log file from build commands) from the image
646           after building is complete.  If you don't want to reveal precisely
647           how the image was built, use this option.
648
649           See also: "LOG FILE".
650
651       --password USER:SELECTOR
652           Set the password for "USER".  (Note this option does not create the
653           user account).
654
655           See "USERS AND PASSWORDS" for the format of the "SELECTOR" field,
656           and also how to set up user accounts.
657
658       --password-crypto md5|sha256|sha512
659           When the virt tools change or set a password in the guest, this
660           option sets the password encryption of that password to "md5",
661           "sha256" or "sha512".
662
663           "sha256" and "sha512" require glibc ≥ 2.7 (check crypt(3) inside
664           the guest).
665
666           "md5" will work with relatively old Linux guests (eg. RHEL 3), but
667           is not secure against modern attacks.
668
669           The default is "sha512" unless libguestfs detects an old guest that
670           didn't have support for SHA-512, in which case it will use "md5".
671           You can override libguestfs by specifying this option.
672
673           Note this does not change the default password encryption used by
674           the guest when you create new user accounts inside the guest.  If
675           you want to do that, then you should use the --edit option to
676           modify "/etc/sysconfig/authconfig" (Fedora, RHEL) or
677           "/etc/pam.d/common-password" (Debian, Ubuntu).
678
679       --root-password SELECTOR
680           Set the root password.
681
682           See "USERS AND PASSWORDS" for the format of the "SELECTOR" field,
683           and also how to set up user accounts.
684
685           Note: In virt-builder, if you don't set --root-password then the
686           guest is given a random root password.
687
688       --run SCRIPT
689           Run the shell script (or any program) called "SCRIPT" on the disk
690           image.  The script runs virtualized inside a small appliance,
691           chrooted into the guest filesystem.
692
693           The script is automatically chmod +x.
694
695           If libguestfs supports it then a limited network connection is
696           available but it only allows outgoing network connections.  You can
697           also attach data disks (eg. ISO files) as another way to provide
698           data (eg. software packages) to the script without needing a
699           network connection (--attach).  You can also upload data files
700           (--upload).
701
702           You can have multiple --run options.  They run in the same order
703           that they appear on the command line.
704
705           See also: --firstboot, --attach, --upload.
706
707       --run-command 'CMD+ARGS'
708           Run the command and arguments on the disk image.  The command runs
709           virtualized inside a small appliance, chrooted into the guest
710           filesystem.
711
712           If libguestfs supports it then a limited network connection is
713           available but it only allows outgoing network connections.  You can
714           also attach data disks (eg. ISO files) as another way to provide
715           data (eg. software packages) to the script without needing a
716           network connection (--attach).  You can also upload data files
717           (--upload).
718
719           You can have multiple --run-command options.  They run in the same
720           order that they appear on the command line.
721
722           See also: --firstboot, --attach, --upload.
723
724       --scrub FILE
725           Scrub a file from the guest.  This is like --delete except that:
726
727           •   It scrubs the data so a guest could not recover it.
728
729           •   It cannot delete directories, only regular files.
730
731       --selinux-relabel
732           Relabel files in the guest so that they have the correct SELinux
733           label.
734
735           This will attempt to relabel files immediately, but if the
736           operation fails this will instead touch /.autorelabel on the image
737           to schedule a relabel operation for the next time the image boots.
738
739           You should only use this option for guests which support SELinux.
740
741       --sm-attach SELECTOR
742           Attach to a pool using "subscription-manager".
743
744           See "SUBSCRIPTION-MANAGER" for the format of the "SELECTOR" field.
745
746       --sm-credentials SELECTOR
747           Set the credentials for "subscription-manager".
748
749           See "SUBSCRIPTION-MANAGER" for the format of the "SELECTOR" field.
750
751       --sm-register
752           Register the guest using "subscription-manager".
753
754           This requires credentials being set using --sm-credentials.
755
756       --sm-remove
757           Remove all the subscriptions from the guest using
758           "subscription-manager".
759
760       --sm-unregister
761           Unregister the guest using "subscription-manager".
762
763       --ssh-inject USER[:SELECTOR]
764           Inject an ssh key so the given "USER" will be able to log in over
765           ssh without supplying a password.  The "USER" must exist already in
766           the guest.
767
768           See "SSH KEYS" for the format of the "SELECTOR" field.
769
770           You can have multiple --ssh-inject options, for different users and
771           also for more keys for each user.
772
773       --timezone TIMEZONE
774           Set the default timezone of the guest to "TIMEZONE".  Use a
775           location string like "Europe/London"
776
777       --touch FILE
778           This command performs a touch(1)-like operation on "FILE".
779
780       --truncate FILE
781           This command truncates "FILE" to a zero-length file. The file must
782           exist already.
783
784       --truncate-recursive PATH
785           This command recursively truncates all files under "PATH" to zero-
786           length.
787
788       --uninstall PKG,PKG..
789           Uninstall the named packages (a comma-separated list).  These are
790           removed during the image build using the guest’s package manager
791           (eg. apt, yum, etc.).  Dependent packages may also need to be
792           uninstalled to satisfy the request.
793
794           See also --install, --update.
795
796       --update
797           Do the equivalent of "yum update", "apt-get upgrade", or whatever
798           command is required to update the packages already installed in the
799           template to their latest versions.
800
801           See also --install, --uninstall.
802
803       --upload FILE:DEST
804           Upload local file "FILE" to destination "DEST" in the disk image.
805           File owner and permissions from the original are preserved, so you
806           should set them to what you want them to be in the disk image.
807
808           "DEST" could be the final filename.  This can be used to rename the
809           file on upload.
810
811           If "DEST" is a directory name (which must already exist in the
812           guest) then the file is uploaded into that directory, and it keeps
813           the same name as on the local filesystem.
814
815           See also: --mkdir, --delete, --scrub.
816
817       --write FILE:CONTENT
818           Write "CONTENT" to "FILE".
819

REFERENCE

821   INSTALLING PACKAGES
822       There are several approaches to installing packages or applications in
823       the guest which have different trade-offs.
824
825       Installing packages at build time
826
827       If the guest OS you are installing is similar to the host OS (eg.  both
828       are Linux), and if libguestfs supports network connections, then you
829       can use --install to install packages like this:
830
831        virt-builder fedora-27 --install inkscape
832
833       This uses the guest’s package manager and the host’s network
834       connection.
835
836       Updating packages at build time
837
838       To update the installed packages in the template at build time:
839
840        virt-builder fedora-27 --update
841
842       Most of the templates that ship with virt-builder come with a very
843       minimal selection of packages (known as a "JEOS" or "Just Enough
844       Operating System"), which are up to date at the time the template is
845       created, but could be out of date by the time you come to install an OS
846       from the template.  This option updates those template packages.
847
848       Installing packages at first boot
849
850       Another option is to install the packages when the guest first boots:
851
852        virt-builder fedora-27 --firstboot-install inkscape
853
854       This uses the guest’s package manager and the guest’s network
855       connection.
856
857       The downsides are that it will take the guest a lot longer to boot
858       first time, and there’s nothing much you can do if package installation
859       fails (eg. if a network problem means the guest can't reach the package
860       repositories).
861
862       Installing packages at build time from a side repository
863
864       If the software you want to install is not available in the main
865       package repository of the guest, then you can add a side repository.
866       Usually this is presented as an ISO (CD disk image) file containing
867       extra packages.
868
869       You can create the disk image using either genisoimage(1) or
870       virt-make-fs(1).  For genisoimage, use a command like this:
871
872        genisoimage -o extra-packages.iso -R -J -V EXTRA cdcontents/
873
874       Create a script that mounts the ISO and sets up the repository.  For
875       dnf, create /tmp/install.sh containing:
876
877        mkdir /tmp/mount
878        mount LABEL=EXTRA /tmp/mount
879
880        cat <<'EOF' > /etc/yum.repos.d/extra.repo
881        [extra]
882        name=extra
883        baseurl=file:///tmp/mount
884        enabled=1
885        EOF
886
887        dnf -y install famousdatabase
888
889       For apt, create /tmp/install.sh containing:
890
891        mkdir /tmp/mount
892        mount LABEL=EXTRA /tmp/mount
893
894        apt-cdrom -d=/tmp/mount add
895        apt-get -y install famousdatabase
896
897       Use the --attach option to attach the CD / disk image and the --run
898       option to run the script:
899
900        virt-builder fedora-27 \
901          --attach extra-packages.iso \
902          --run /tmp/install.sh
903
904   USERS AND PASSWORDS
905       The --root-password option is used to change the root password
906       (otherwise a random password is used).  This option takes a password
907       "SELECTOR" in one of the following formats:
908
909       --root-password file:FILENAME
910           Read the root password from "FILENAME".  The whole first line of
911           this file is the replacement password.  Any other lines are
912           ignored.  You should create the file with mode 0600 to ensure no
913           one else can read it.
914
915       --root-password password:PASSWORD
916           Set the root password to the literal string "PASSWORD".
917
918           Note: this is not secure since any user on the same machine can see
919           the cleartext password using ps(1).
920
921       --root-password random
922           Choose a random password, which is printed on stdout.  The password
923           has approximately 120 bits of randomness.
924
925           This is the default.
926
927       --root-password disabled
928           The root account password is disabled.  This is like putting "*" in
929           the password field.
930
931       --root-password locked:file:FILENAME
932       --root-password locked:password:PASSWORD
933       --root-password locked:random
934           The root account is locked, but a password is placed on the
935           account.  If first unlocked (using "passwd -u") then logins will
936           use the given password.
937
938       --root-password locked
939       --root-password locked:disabled
940           The root account is locked and password is disabled.
941
942       Creating user accounts
943
944       To create user accounts, use the useradd(8) command with
945       --firstboot-command like this:
946
947        virt-builder --firstboot-command \
948           'useradd -m -p "" rjones ; chage -d 0 rjones'
949
950       The above command will create an "rjones" account with no password, and
951       force the user to set a password when they first log in.  There are
952       other ways to manage passwords, see useradd(8) for details.
953
954   KEYBOARD LAYOUT
955       Because there are so many different ways to set the keyboard layout in
956       Linux distributions, virt-builder does not yet attempt to have a simple
957       command line option.  This section describes how to set the keyboard
958       for some common Linux distributions.
959
960       Keyboard layout with systemd
961
962       For distros that use systemd "localectl", use a command like this:
963
964        virt-builder fedora-27 \
965          --firstboot-command 'localectl set-keymap uk'
966
967       See localectl(1) and
968       https://www.happyassassin.net/2013/11/23/keyboard-layouts-in-fedora-20-and-previously/
969       for more details.
970
971       Keyboard layout using /etc/sysconfig/keyboard
972
973       For RHEL ≤ 6, Fedora ≤ 18 and similar, upload or modify the keyboard
974       configuration file using the --upload, --write or --edit options.  For
975       example:
976
977        virt-builder centos-6 \
978          --edit '/etc/sysconfig/keyboard: s/^KEYTABLE=.*/KEYTABLE="uk"/'
979
980       The format of this file can be found documented in many places online.
981
982       Keyboard layout with Debian-derived distros
983
984       For Debian-derived distros using /etc/default/keyboard, upload or
985       modify the keyboard file using the --upload, --write or --edit options.
986       For example:
987
988        virt-builder debian-8 \
989          --edit '/etc/default/keyboard: s/^XKBLAYOUT=.*/XKBLAYOUT="gb"/'
990
991       See https://wiki.debian.org/Keyboard.
992
993   LANGUAGE
994       Most Linux distributions support multiple locale settings so that you
995       can have guest messages printed in another language such as Russian.
996
997       However there is no single setting which controls this, since extra
998       packages may need to be installed to support console and X fonts, and
999       keyboard input methods.  The packages required, and their configuration
1000       is highly distro-specific, and it is outside the scope of virt-builder
1001       to do this.
1002
1003       This section contains examples for some common Linux distributions.
1004
1005       Setting Japanese in Fedora 25
1006
1007        virt-builder fedora-27 \
1008          --size 20G \
1009          --update \
1010          --install @japanese-support \
1011          --install @xfce \
1012          --install xorg-x11-server-Xorg,xorg-x11-drivers,rsyslog \
1013          --link /usr/lib/systemd/system/graphical.target:/etc/systemd/system/default.target \
1014          --firstboot-command 'localectl set-locale LANG=ja_JP.utf8' \
1015          --firstboot-command 'localectl set-keymap jp' \
1016          --firstboot-command 'systemctl isolate graphical.target'
1017
1018       Setting Japanese in Debian 8 (Jessie)
1019
1020       Note that although this enables Japanese in the text console too, it is
1021       unlikely that you will see properly rendered Japanese there.  However
1022       Japanese is properly rendered in X applications and terminals.
1023
1024        pkgs=locales,xfce4,\
1025        ibus,ibus-anthy,\
1026        fonts-ipafont-gothic,fonts-ipafont-mincho,\
1027        fonts-takao-mincho,\
1028        xfonts-intl-japanese,xfonts-intl-japanese-big,\
1029        iceweasel-l10n-ja,manpages-ja
1030
1031        virt-builder debian-8 \
1032          --size 20G \
1033          --install $pkgs \
1034          --edit '/etc/locale.gen: s,^#\s*ja,ja,' \
1035          --write '/etc/default/locale:LANG="ja_JP.UTF-8"' \
1036          --run-command "locale-gen"
1037
1038   LOG FILE
1039       Scripts and package installation that runs at build time (--run,
1040       --run-command, --install, --update, but not firstboot) is logged in one
1041       of the following locations:
1042
1043       /tmp/builder.log
1044           On Linux, BSD, and other non-Windows guests.
1045
1046       C:\Temp\builder.log
1047           On Windows, DOS guests.
1048
1049       /builder.log
1050           If /tmp or C:\Temp is missing.
1051
1052       If you don’t want the log file to appear in the final image, then use
1053       the --no-logfile command line option.
1054
1055   SSH KEYS
1056       The --ssh-inject option is used to inject ssh keys for users in the
1057       guest, so they can login without supplying a password.
1058
1059       The "SELECTOR" part of the option value is optional; in this case,
1060       --ssh-inject "USER" means that we look in the current user’s ~/.ssh
1061       directory to find the default public ID file.  That key is uploaded.
1062       "default public ID" is the default_ID_file file described in
1063       ssh-copy-id(1).
1064
1065       If specified, the "SELECTOR" can be in one of the following formats:
1066
1067       --ssh-inject USER:file:FILENAME
1068           Read the ssh key from FILENAME.  FILENAME is usually a .pub file.
1069
1070       --ssh-inject USER:string:KEY_STRING
1071           Use the specified "KEY_STRING".  "KEY_STRING" is usually a public
1072           string like ssh-rsa AAAA.... user@localhost.
1073
1074       In any case, the ~USER/.ssh directory and the
1075       ~USER/.ssh/authorized_keys file will be created if not existing
1076       already.
1077
1078   FIRST BOOT SCRIPTS
1079       The --firstboot and --firstboot-command options allow you to execute
1080       commands at the first boot of the guest.  To do so, an init script for
1081       the guest init system is installed, which takes care of running all the
1082       added scripts and commands.
1083
1084       Supported operating systems are:
1085
1086       Linux
1087           Init systems supported are: systemd, System-V init (known also as
1088           sysvinit), and Upstart (using the System-V scripts).
1089
1090           Note that usually init scripts run as root, but with a more limited
1091           environment than what could be available from a normal shell: for
1092           example, $HOME may be unset or empty.
1093
1094           The output of the first boot scripts is available in the guest as
1095           ~root/virt-sysprep-firstboot.log.
1096
1097       Windows
1098           rhsrvany.exe, available from sources at
1099           https://github.com/rwmjones/rhsrvany, or pvvxsvc.exe, available
1100           with SUSE VMDP is installed to run the first boot scripts.  It is
1101           required, and the setup of first boot scripts will fail if it is
1102           not present.
1103
1104           rhsrvany.exe or pvvxsvc.exe is copied from the location pointed to
1105           by the "VIRT_TOOLS_DATA_DIR" environment variable; if not set, a
1106           compiled-in default will be used (something like
1107           /usr/share/virt-tools).
1108
1109           The output of the first boot scripts is available in the guest as
1110           C:\Program Files\Guestfs\Firstboot\log.txt.
1111
1112   SUBSCRIPTION-MANAGER
1113       It is possible to automate the registration and attaching of the system
1114       using "subscription-manager".  This is typical on Red Hat Enterprise
1115       Linux guests.  There are few options which ease this process, avoid
1116       executing commands manually and exposing passwords on command line.
1117
1118       --sm-register starts the registration process, and requires
1119       --sm-credentials to be specified; the format of the "SELECTOR" of
1120       --sm-credentials is one of the following formats:
1121
1122       --sm-credentials USER:file:FILENAME
1123           Read the password for the specified "USER" from FILENAME.
1124
1125       --sm-credentials USER:password:PASSWORD
1126           Use the literal string "PASSWORD" for the specified "USER".
1127
1128       --sm-attach attaches the system to subscriptions; the format of its
1129       "SELECTOR" is one of the following:
1130
1131       --sm-attach auto
1132           "subscription-manager" attaches to the best-fitting subscriptions
1133           for the system.
1134
1135       --sm-attach file:FILENAME
1136           Read the pool ID from FILENAME.
1137
1138       --sm-attach pool:POOL
1139           Use the literal string "POOL" as pool ID.
1140
1141       --sm-remove removes all the subscriptions from the guest, while
1142       --sm-unregister completely unregister the system.
1143
1144   INSTALLATION PROCESS
1145       When you invoke virt-builder, installation proceeds as follows:
1146
1147       •   The template image is downloaded.
1148
1149           If the template image is present in the cache, the cached version
1150           is used instead.  (See "CACHING").
1151
1152       •   The template signature is checked.
1153
1154       •   The template is uncompressed to a tmp file.
1155
1156       •   The template image is resized into the destination, using
1157           virt-resize(1).
1158
1159       •   Extra disks are attached (--attach).
1160
1161       •   A new random seed is generated for the guest.
1162
1163       •   Guest customization is performed, in the order specified on the
1164           command line.
1165
1166       •   SELinux relabelling is done (--selinux-relabel).
1167
1168   IMPORTING THE DISK IMAGE
1169       Importing into libvirt
1170
1171       Import the disk image into libvirt using virt-install(1) --import
1172       option.
1173
1174        virt-install --import \
1175          --name guest --ram 2048 \
1176          --disk path=disk.img,format=raw --os-variant fedora27
1177
1178       Notes:
1179
1180       1.  You must specify the correct format.  The format is "raw" unless
1181           you used virt-builder’s --format option.
1182
1183       2.  --os-variant is highly recommended, because it will present optimum
1184           devices to enable the guest to run most efficiently.  To get a list
1185           of all variants, do:
1186
1187            osinfo-query os
1188
1189           The above tool is provided by libosinfo package.
1190
1191       3.  You can run virt-install as root or non-root.  Each works slightly
1192           differently because libvirt manages a different set of virtual
1193           machines for each user.  In particular virt-manager normally shows
1194           the root-owned VMs, whereas Boxes shows the user-owned VMs, and
1195           other tools probably work differently as well.
1196
1197       Importing into OpenStack
1198
1199       Import the image into Glance (the OpenStack image store) by doing:
1200
1201        glance image-create --name fedora-27-image --file fedora-27.img \
1202          --disk-format raw --container-format bare \
1203          --is-public True
1204
1205       The --file parameter is the virt-builder-generated disk image.  It
1206       should match virt-builder’s --output option.  The --disk-format
1207       parameter should match virt-builder’s --format option (or "raw" if you
1208       didn't use that option).  The --container-format should always be
1209       "bare" since virt-builder doesn't put images into containers.
1210
1211       You can use the "glance image-show fedora-27-image" command to display
1212       the properties of the image.
1213
1214       To boot up an instance of your image on a Nova compute node, do:
1215
1216        nova boot fedora-27-server --image fedora-27-image \
1217          --flavor m1.medium
1218
1219       Use "nova flavor-list" to list possible machine flavors.  Use
1220       "nova list" to list running instances.
1221
1222       Booting directly using qemu or KVM
1223
1224       The qemu command line is not very stable or easy to use, hence libvirt
1225       should be used if possible.  However a command line similar to the
1226       following could be used to boot the virtual machine:
1227
1228        qemu-system-x86_64 \
1229          -machine accel=kvm:tcg \
1230          -cpu host \
1231          -m 2048 \
1232          -drive file=disk.img,format=raw,if=virtio
1233
1234       As with libvirt, it is very important that the correct format is
1235       chosen.  It will be "raw" unless the --format option was used.
1236
1237   CONFIGURATION MANAGEMENT
1238       Puppet
1239
1240       To enable the Puppet agent in a guest, install the package, point the
1241       configuration at your Puppetmaster, and ensure the agent runs at boot.
1242
1243       A typical virt-builder command would be:
1244
1245        virt-builder fedora-27 \
1246          --hostname client.example.com \
1247          --update \
1248          --install puppet \
1249          --append-line '/etc/puppet/puppet.conf:[agent]' \
1250          --append-line '/etc/puppet/puppet.conf:server = puppetmaster.example.com/' \
1251          --run-command 'systemctl enable puppet' \
1252          --selinux-relabel
1253
1254       The precise instructions vary according to the Linux distro.  For
1255       further information see:
1256       https://docs.puppet.com/puppet/latest/install_pre.html
1257
1258   DEBUGGING BUILDS
1259       If virt-builder itself fails, then enable debugging (-v) and report a
1260       bug (see "BUGS" below).
1261
1262       If virt-builder fails because some script or package it is installing
1263       fails, try using --no-delete-on-failure to preserve the output file,
1264       and continue reading this section.
1265
1266       If virt-builder is successful but the image doesn't work, here are some
1267       things to try:
1268
1269       Use virt-rescue
1270           Run virt-rescue(1) on the disk image:
1271
1272            virt-rescue -a disk.img
1273
1274           This gives you a rescue shell.  You can mount the filesystems from
1275           the disk image on /sysroot and examine them using ordinary Linux
1276           commands.  You can also chroot into the guest to reinstall the
1277           bootloader.  The virt-rescue man page has a lot more information
1278           and examples.
1279
1280       Use guestfish
1281           Run guestfish(1) on the disk image:
1282
1283            guestfish -a disk.img -i
1284
1285           Use guestfish commands like "ll /directory" and "cat /file" to
1286           examine directories and files.
1287
1288       Use guestmount
1289           Mount the disk image safely on the host using FUSE and
1290           guestmount(1):
1291
1292            mkdir /tmp/mp
1293            guestmount -a disk.img -i /tmp/mp
1294            cd /tmp/mp
1295
1296           To unmount the disk image do:
1297
1298            fusermount -u /tmp/mp
1299
1300       Add a serial console
1301           If the guest hangs during boot, it can be helpful to add a serial
1302           console to the guest, and direct kernel messages to the serial
1303           console.  Adding the serial console will involve looking at the
1304           documentation for your hypervisor.  To direct kernel messages to
1305           the serial console, add the following on the kernel command line:
1306
1307            console=tty0 console=ttyS0,115200
1308
1309   SOURCES OF TEMPLATES
1310       virt-builder reads the available sources from configuration files, with
1311       the .conf extension and located in the following paths:
1312
1313       •   $XDG_CONFIG_HOME/virt-builder/repos.d/ ($XDG_CONFIG_HOME is
1314           $HOME/.config if not set).
1315
1316       •   $VIRT_BUILDER_DIRS/virt-builder/repos.d/ (where $VIRT_BUILDER_DIRS
1317           means any of the directories in that environment variable, or just
1318           /etc if not set).
1319
1320       Each .conf file in those paths has a simple text format like the
1321       following:
1322
1323        [libguestfs.org]
1324        uri=http://libguestfs.org/download/builder/index.asc
1325        gpgkey=file:///etc/xdg/virt-builder/repos.d/libguestfs.gpg
1326
1327       The part in square brackets is the repository identifier, which is used
1328       as unique identifier.
1329
1330       The following fields can appear:
1331
1332       "uri=URI"
1333           The URI of the index file which this repository refers to.
1334
1335           This field is required.
1336
1337       "gpgkey=URI"
1338           This optional field represents the URI (although only file:// URIs
1339           are accepted) of the key used to sign the index file.  If not
1340           present, the index file referred by uri=.. is not signed.
1341
1342       "proxy=MODE"
1343           This optional field specifies the proxy mode, to be used when
1344           downloading the index file of this repository.  The possible values
1345           are:
1346
1347           no, off
1348               No proxy is being used at all, even overriding the system
1349               configuration.
1350
1351           system
1352               The proxy used is the system one.
1353
1354           anything else
1355               Specifies the actual proxy configuration to be used, overriding
1356               the system configuration.
1357
1358           If not present, the assumed value is to respect the proxy settings
1359           of the system (i.e. as if system would be specified).
1360
1361       "format=FORMAT"
1362           This optional field specifies the format of the repository.  The
1363           possible values are:
1364
1365           native
1366               The native format of the "virt-builder" repository.  See also
1367               "Creating and signing the index file" below.
1368
1369           simplestreams
1370               The URI represents the root of a Simple Streams v1.0 tree of
1371               metadata.
1372
1373               For more information about Simple Streams, see also
1374               https://launchpad.net/simplestreams.
1375
1376           If not present, the assumed value is "native".
1377
1378       For serious virt-builder use, you may want to create your own
1379       repository of templates.
1380
1381       Libguestfs.org repository
1382
1383       Out of the box, virt-builder downloads the file
1384       http://libguestfs.org/download/builder/index.asc which is an index of
1385       available templates plus some information about each one, wrapped up in
1386       a digital signature.  The command "virt-builder --list" lists out the
1387       information in this index file.
1388
1389       The templates hosted on libguestfs.org were created using shell
1390       scripts, kickstart files and preseed files which can be found in the
1391       libguestfs source tree, in "builder/templates".
1392
1393       Setting up the repository
1394
1395       You can set up your own site containing an index file and some
1396       templates, and then point virt-builder at the site by creating a .conf
1397       file pointing to it.
1398
1399       Note that if your index is signed, you will need to properly fill
1400       gpgkey=.. in your .conf file, making sure to deploy also the GPG key
1401       file.
1402
1403        virt-builder --source https://example.com/builder/index.asc \
1404           --fingerprint 'AAAA BBBB ...' \
1405           --list
1406
1407       You can host this on any web or FTP server, or a local or network
1408       filesystem.
1409
1410       Setting up a GPG key
1411
1412       If you don’t have a GnuPG key, you will need to set one up.  (Strictly
1413       speaking this is optional, but if your index and template files are not
1414       signed then virt-builder users will have to use the
1415       --no-check-signature flag every time they use virt-builder.)
1416
1417       To create a key, see the GPG manual
1418       http://www.gnupg.org/gph/en/manual.html.
1419
1420       Export your GPG public key:
1421
1422        gpg --export -a "you@example.com" > pubkey
1423
1424       Create the templates
1425
1426       There are many ways to create the templates.  For example you could
1427       clone existing guests (see virt-sysprep(1)), or you could install a
1428       guest by hand (virt-install(1)).  To see how the templates were created
1429       for virt-builder, look at the scripts in "builder/templates"
1430
1431       Virt-builder supports any image format (e.g. raw, qcow2, etc) as
1432       template, both as-is, and compressed as XZ.  This way, existing images
1433       (e.g. cleaned using virt-sysprep(1)) can be used as templates.
1434
1435       For best results when compressing the templates, use the following xz
1436       options (see nbdkit-xz-plugin(1) for further explanation):
1437
1438        xz --best --block-size=16777216 disk
1439
1440       Creating and signing the index file
1441
1442       The index file has a simple text format (shown here without the digital
1443       signature):
1444
1445        [fedora-18]
1446        name=Fedora® 18
1447        osinfo=fedora18
1448        arch=x86_64
1449        file=fedora-18.xz
1450        checksum[sha512]=...
1451        format=raw
1452        size=6442450944
1453        compressed_size=148947524
1454        expand=/dev/sda3
1455
1456        [fedora-19]
1457        name=Fedora® 19
1458        osinfo=fedora19
1459        arch=x86_64
1460        file=fedora-19.xz
1461        checksum[sha512]=...
1462        revision=3
1463        format=raw
1464        size=4294967296
1465        compressed_size=172190964
1466        expand=/dev/sda3
1467
1468       The part in square brackets is the "os-version", which is the same
1469       string that is used on the virt-builder command line to build that OS.
1470
1471       The index file creation and signature can be eased with the
1472       virt-builder-repository(1) tool.
1473
1474       After preparing the "index" file in the correct format, clearsign it
1475       using the following command:
1476
1477        gpg --clearsign --armor index
1478
1479       This will create the final file called index.asc which can be uploaded
1480       to the server (and is the uri=.. URL).  As noted above, signing the
1481       index file is optional, but recommended.
1482
1483       The following fields can appear:
1484
1485       "name=NAME"
1486           The user-friendly name of this template.  This is displayed in the
1487           --list output but is otherwise not significant.
1488
1489       "osinfo=ID"
1490           This optional field maps the operating system to the associated
1491           libosinfo ID.  Virt-builder does not use it (yet).
1492
1493       "arch=ARCH"
1494           The architecture of the operating system installed within the
1495           template. This field is required.
1496
1497       "file=PATH"
1498           The path (relative to the index) of the xz-compressed template.
1499
1500           Note that absolute paths or URIs are not permitted here.  This is
1501           because virt-builder has a "same origin" policy for templates so
1502           they cannot come from other servers.
1503
1504       "sig=PATH"
1505           This option is deprecated.  Use the checksum field instead.
1506
1507           The path (relative to the index) of the GPG detached signature of
1508           the xz file.
1509
1510           Note that absolute paths or URIs are not permitted here.  This is
1511           because virt-builder has a "same origin" policy for templates so
1512           they cannot come from other servers.
1513
1514           The file can be created as follows:
1515
1516            gpg --detach-sign --armor -o disk.xz.sig disk.xz
1517
1518       "checksum[sha512]=7b882fe9b82eb0fef..."
1519           The SHA-512 checksum of the file specified in file=.. is checked
1520           after it is downloaded.  To work out the signature, do:
1521
1522            sha512sum disk.xz
1523
1524           Note if you use this, you don’t need to sign the file, ie. don’t
1525           use "sig".  This option overrides "sig".
1526
1527       "checksum=7b882fe9b82eb0fef..."
1528           "checksum" is an alias for "checksum[sha512]".
1529
1530           If you need to interoperate with virt-builder = 1.24.0 then you
1531           have to use "checksum" because that version would give a parse
1532           error with square brackets and numbers in the key of a field.  This
1533           is fixed in virt-builder ≥ 1.24.1.
1534
1535       "revision=N"
1536           The revision is an integer which is used to control the template
1537           cache.  Increasing the revision number causes clients to download
1538           the template again even if they have a copy in the cache.
1539
1540           The revision number is optional.  If omitted it defaults to 1.
1541
1542       "format=raw"
1543       "format=qcow2"
1544           Specify the format of the disk image; in case it is compressed,
1545           that is the format before the compression.  If not given, the
1546           format is autodetected, but generally it is better to be explicit
1547           about the intended format.
1548
1549           Note this is the source format, which is different from the
1550           --format option (requested output format).  Virt-builder does on-
1551           the-fly conversion from the source format to the requested output
1552           format.
1553
1554       "size=NNN"
1555           The virtual size of the image in bytes.  This is the size of the
1556           image when uncompressed.  If using a non-raw format such as qcow2
1557           then it means the virtual disk size, not the size of the qcow2
1558           file.
1559
1560           This field is required.
1561
1562           Virt-builder also uses this as the minimum size that users can
1563           request via the --size option, or as the default size if there is
1564           no --size option.
1565
1566       "compressed_size=NNN"
1567           The actual size of the disk image in bytes, i.e. what was specified
1568           in file=...  This is just used for information (when using "long",
1569           and "json" formats of --list).
1570
1571       "expand=/dev/sdaX"
1572           When expanding the image to its final size, instruct virt-resize(1)
1573           to expand the named partition in the guest image to fill up all
1574           available space.  This works like the virt-resize --expand option.
1575
1576           You should usually put the device name of the guest’s root
1577           filesystem here.
1578
1579           It’s a good idea to use this, but not required.  If the field is
1580           omitted then virt-resize will create an extra partition at the end
1581           of the disk to cover the free space, which is much less user-
1582           friendly.
1583
1584       "lvexpand=/dev/VolGroup/LogVol"
1585           When expanding the image to its final size, instruct virt-resize(1)
1586           to expand the named logical volume in the guest image to fill up
1587           all available space.  This works like the virt-resize --lv-expand
1588           option.
1589
1590           If the guest uses LVM2 you should usually put the LV of the guest’s
1591           root filesystem here.  If the guest does not use LVM2 or its root
1592           filesystem is not on an LV, don't use this option.
1593
1594       "notes=NOTES"
1595           Any notes that go with this image, especially notes describing what
1596           packages are in the image, how the image was prepared, and
1597           licensing information.
1598
1599           This information is shown in the --notes and --list --long modes.
1600
1601           You can use multi-line notes here by indenting each new line with
1602           at least one character of whitespace (even on blank lines):
1603
1604            notes=This image was prepared using
1605             the following kickstart script:
1606                                           <-- one space at beginning of line
1607             part /boot --fstype ext3
1608             ...
1609
1610       "hidden=true"
1611           Using the hidden flag prevents the template from being listed by
1612           the --list option (but it is still installable).  This is used for
1613           test images.
1614
1615       "aliases=ALIAS1 ALIAS2 ..."
1616           This optional field specifies a list of aliases, separated by
1617           spaces, for the image.  For example, an alias could be used to
1618           always point to the latest version of a certain image, leaving the
1619           old versions available in the index instead of updating the same
1620           image (see the "revision" field).
1621
1622       Running virt-builder against multiple sources
1623
1624       It is possible to use multiple sources with virt-builder.  The
1625       recommended way is to deploy .conf files pointing to the index files.
1626       Another way is to specify the sources using multiple --source and/or
1627       --fingerprint options:
1628
1629        virt-builder \
1630          --source http://example.com/s1/index.asc \
1631          --source http://example.com/s2/index.asc
1632
1633       You can provide N or 1 fingerprints.  In the case where you provide N
1634       fingerprints, N = number of sources and there is a 1-1 correspondence
1635       between each source and each fingerprint:
1636
1637        virt-builder \
1638          --source http://example.com/s1/index.asc --fingerprint '0123 ...' \
1639          --source http://example.com/s2/index.asc --fingerprint '9876 ...'
1640
1641       In the case where you provide 1 fingerprint, the same fingerprint is
1642       used for all sources.
1643
1644       You "must" provide at least 1 fingerprint.
1645
1646       Licensing of templates
1647
1648       You should be aware of the licensing of images that you distribute.
1649       For open source guests, provide a link to the source code in the
1650       "notes" field and comply with other requirements (eg. around
1651       trademarks).
1652
1653       Formal specification of the index file
1654
1655       The index file format has a formal specification defined by the flex
1656       scanner and bison parser used to parse the file.  This can be found in
1657       the following files in the libguestfs source tree:
1658
1659        builder/index-scan.l
1660        builder/index-parse.y
1661
1662       A tool called virt-index-validate(1) is available to validate the index
1663       file to ensure it is correct.
1664
1665       Note that the parser and tool can work on either the signed or unsigned
1666       index file (ie. index or index.asc).
1667
1668       The index is always encoded in UTF-8.
1669
1670   CACHING
1671       Caching templates
1672
1673       Since the templates are usually very large, downloaded templates are
1674       cached in the user’s home directory.
1675
1676       The location of the cache is $XDG_CACHE_HOME/virt-builder/ or
1677       $HOME/.cache/virt-builder.
1678
1679       You can print out information about the cache directory, including
1680       which guests are currently cached, by doing:
1681
1682        virt-builder --print-cache
1683
1684       The cache can be deleted if you want to save space by doing:
1685
1686        virt-builder --delete-cache
1687
1688       You can download all (current) templates to the local cache by doing:
1689
1690        virt-builder --cache-all-templates
1691
1692       To disable the template cache, use --no-cache.
1693
1694       Only templates are cached.  The index and detached digital signatures
1695       are not cached.
1696
1697       Caching packages
1698
1699       Virt-builder uses curl(1) to download files and it also uses the
1700       current "http_proxy" (etc) settings when installing packages
1701       (--install, --update).
1702
1703       You may therefore want to set those environment variables in order to
1704       maximize the amount of local caching that happens.  See "ENVIRONMENT
1705       VARIABLES" and curl(1).
1706
1707       Local mirrors
1708
1709       To increase both speed and reliability of installing packages, you can
1710       set up a local mirror of the target distribution, and point the guest
1711       package manager at that.
1712
1713       Using a local mirror with Fedora
1714
1715       To install a Fedora guest using a local mirror:
1716
1717        virt-builder fedora-27 \
1718          --edit '/etc/yum.repos.d/fedora.repo:
1719              s{.*baseurl=.*}{baseurl=http://example.com/mirror/};
1720              s{.*metalink=.*}{};
1721          ' \
1722          --edit '/etc/yum.repos.d/fedora-updates.repo:
1723              s{.*baseurl=.*}{baseurl=http://example.com/mirror-updates/};
1724              s{.*metalink=.*}{};
1725          ' \
1726          --run-command 'dnf -y update' \
1727          --install 'pkg1,pkg2,...'
1728
1729       Using a local mirror with Debian
1730
1731       Assuming that you are using "apt-proxy" to mirror the repository, you
1732       should create a new sources.list file to point to your proxy (see
1733       https://help.ubuntu.com/community/AptProxy) and then do:
1734
1735        virt-builder debian-8 \
1736          --upload sources.list:/etc/apt/sources.list \
1737          --run-command 'apt-get -y update' \
1738          --install 'pkg1,pkg2,...'
1739
1740   DIGITAL SIGNATURES
1741       Virt-builder uses GNU Privacy Guard (GnuPG or gpg) to verify that the
1742       index and templates have not been tampered with.
1743
1744       The source points to an index file, which is optionally signed.
1745
1746       Virt-builder downloads the index and checks that the signature is valid
1747       and the signer’s fingerprint matches the specified fingerprint (ie. the
1748       one specified in gpgkey=.. in the .conf, or with --fingerprint, in that
1749       order).
1750
1751       For checking against the built-in public key/fingerprint, this requires
1752       importing the public key into the user’s local gpg keyring (that’s just
1753       the way that gpg works).
1754
1755       When a template is downloaded, its signature is checked in the same
1756       way.
1757
1758       Although the signatures are optional, if you don’t have them then virt-
1759       builder users will have to use --no-check-signature on the command
1760       line.  This prevents an attacker from replacing the signed index file
1761       with an unsigned index file and having virt-builder silently work
1762       without checking the signature.  In any case it is highly recommended
1763       that you always create signed index and templates.
1764
1765   ARCHITECTURE
1766       Virt-builder can build a guest for any architecture no matter what the
1767       host architecture is.  For example an x86-64 guest on an ARM host.
1768
1769       However certain options may not work, specifically options that require
1770       running commands in the guest during the build process: --install,
1771       --update, --run, --run-command.  You may need to replace these with
1772       their firstboot-equivalents.
1773
1774       An x86-64 host building 32 bit i686 guests should work without any
1775       special steps.
1776
1777   SECURITY
1778       Virt-builder does not need to run as root (in fact, should not be run
1779       as root), and doesn't use setuid, "sudo" or any similar mechanism.
1780
1781       --install, --update, --run and --run-command are implemented using an
1782       appliance (a small virtual machine) so these commands do not run on the
1783       host.  If you are using the libguestfs libvirt backend and have SELinux
1784       enabled then the virtual machine is additionally encapsulated in an
1785       SELinux container (sVirt).
1786
1787       However these options will have access to the host’s network and since
1788       the template may contain untrusted code, the code might try to access
1789       host network resources which it should not.  You can use --no-network
1790       to prevent this.
1791
1792       Firstboot commands run in the context of the guest when it is booted,
1793       and so the security of your hypervisor / cloud should be considered.
1794
1795       Virt-builder injects a random seed into every guest which it builds.
1796       This helps to ensure that TCP sequence numbers, UUIDs, ssh host keys
1797       etc are truly random when the guest boots.
1798
1799       You should check digital signatures and not ignore any signing errors.
1800
1801   CLONES
1802       If you wish to create many new guests of the same type, it is tempting
1803       to run virt-builder once and then copy the output file.  You should not
1804       do this.  You should run virt-builder once for each new guest you need.
1805
1806       The reason is that each clone needs to have (at least) a separate
1807       random seed, and possibly other unique features (such as filesystem
1808       UUIDs) in future versions of virt-builder.
1809
1810       Another thing you should not do is to boot the guest, then clone the
1811       booted disk image.  The reason is that some guests create unique
1812       machine IDs, SSH host keys and so on at first boot, and you would not
1813       want clones to have duplicate identities.
1814
1815       See also: virt-sysprep(1).
1816
1817   PERFORMANCE
1818       The most important aspect of getting good performance is caching.
1819       Templates gets downloaded into the cache the first time they are used,
1820       or if you use the --cache-all-templates option.  See "CACHING" above
1821       for further information.
1822
1823       Packages required for the --install and --update options are downloaded
1824       using the host network connection.  Setting the "http_proxy",
1825       "https_proxy" and "ftp_proxy" environment variables to point to a local
1826       web cache may ensure they only need to be downloaded once.  You can
1827       also try using a local package repository, although this can be complex
1828       to set up and varies according to which Linux distro you are trying to
1829       install.
1830
1831       Using --no-sync
1832
1833       Use --no-sync.  However read the caveats in the "OPTIONS" section
1834       above, since this can cause disk corruption if not used correctly.
1835
1836       Skipping virt-resize
1837
1838       Virt-builder can skip the virt-resize step under certain conditions.
1839       This makes virt-builder much faster.  The conditions are:
1840
1841       •   the output must be a regular file (not a block device), and
1842
1843       •   the user did not use the --size option, and
1844
1845       •   the output format is the same as the template format (usually raw).
1846
1847       pxzcat
1848
1849       Virt-builder uses an internal implementation of pxzcat (parallel xzcat)
1850       if liblzma was found at build time.  If liblzma was not found at build
1851       time, regular "xzcat" is used which is single-threaded.
1852
1853   SELINUX
1854       Guests which use SELinux (such as Fedora and Red Hat Enterprise Linux)
1855       require that each file has a correct SELinux label.
1856
1857       Virt-builder does not know how to give new files a label, so there are
1858       two possible strategies it can use to ensure correct labelling:
1859
1860       Using --selinux-relabel
1861           This runs setfiles(8) just before finalizing the guest, which sets
1862           SELinux labels correctly in the disk image.
1863
1864           This is the recommended method.
1865
1866       --touch /.autorelabel
1867           Guest templates may already contain a file called /.autorelabel or
1868           you may touch it.
1869
1870           For guests that use SELinux, this causes restorecon(8) to run at
1871           first boot.  Guests will reboot themselves once the first time you
1872           use them, which is normal and harmless.
1873
1874       Please note that if your guest uses SELinux, and you are doing
1875       operations on it which might create new files or change existing ones,
1876       you are recommended to use --selinux-relabel.  This will help in making
1877       sure that files have the right SELinux labels.
1878

MACHINE READABLE OUTPUT

1880       The --machine-readable option can be used to make the output more
1881       machine friendly, which is useful when calling virt-builder from other
1882       programs, GUIs etc.
1883
1884       Use the option on its own to query the capabilities of the virt-builder
1885       binary.  Typical output looks like this:
1886
1887        $ virt-builder --machine-readable
1888        virt-builder
1889        arch
1890        config-file
1891        customize
1892        json-list
1893        pxzcat
1894
1895       A list of features is printed, one per line, and the program exits with
1896       status 0.
1897
1898       It is possible to specify a format string for controlling the output;
1899       see "ADVANCED MACHINE READABLE OUTPUT" in guestfs(3).
1900

ENVIRONMENT VARIABLES

1902       For other environment variables which affect all libguestfs programs,
1903       see "ENVIRONMENT VARIABLES" in guestfs(3).
1904
1905       "http_proxy"
1906       "https_proxy"
1907       "no_proxy"
1908           Set the proxy for downloads.  These environment variables (and
1909           more) are actually interpreted by curl(1), not virt-builder.
1910
1911       "HOME"
1912           Used to determine the location of the template cache, and the
1913           location of the user' sources.  See "CACHING" and "SOURCES OF
1914           TEMPLATES".
1915
1916       "VIRT_TOOLS_DATA_DIR"
1917           This can point to the directory containing data files used for
1918           Windows firstboot installation.
1919
1920           Normally you do not need to set this.  If not set, a compiled-in
1921           default will be used (something like /usr/share/virt-tools).
1922
1923           This directory may contain the following files:
1924
1925           rhsrvany.exe
1926               This is the RHSrvAny Windows binary, used to install a
1927               "firstboot" script in Windows guests.  It is required if you
1928               intend to use the --firstboot or --firstboot-command options
1929               with Windows guests.
1930
1931               See also: "https://github.com/rwmjones/rhsrvany"
1932
1933           pvvxsvc.exe
1934               This is a Windows binary shipped with SUSE VMDP, used to
1935               install a "firstboot" script in Windows guests.  It is required
1936               if you intend to use the --firstboot or --firstboot-command
1937               options with Windows guests.
1938
1939       "XDG_CACHE_HOME"
1940           Used to determine the location of the template cache.  See
1941           "CACHING".
1942
1943       "XDG_CONFIG_HOME"
1944           Used to determine the location of the user' sources.  See "SOURCES
1945           OF TEMPLATES".
1946
1947       "VIRT_BUILDER_DIRS"
1948           Used to determine the location of the system sources.  See "SOURCES
1949           OF TEMPLATES".
1950

EXIT STATUS

1952       This program returns 0 if successful, or non-zero if there was an
1953       error.
1954

SEE ALSO

1956       guestfs(3), guestfish(1), guestmount(1), virt-builder-repository(1),
1957       virt-copy-out(1), virt-customize(1), virt-get-kernel(1),
1958       virt-install(1), virt-rescue(1), virt-resize(1), virt-sysprep(1),
1959       oz-install(1), gpg(1), gpg2(1), curl(1), virt-make-fs(1),
1960       genisoimage(1), http://libguestfs.org/.
1961

AUTHOR

1963       Richard W.M. Jones http://people.redhat.com/~rjones/
1964
1966       Copyright (C) 2013 Red Hat Inc.
1967

LICENSE

1969       This program is free software; you can redistribute it and/or modify it
1970       under the terms of the GNU General Public License as published by the
1971       Free Software Foundation; either version 2 of the License, or (at your
1972       option) any later version.
1973
1974       This program is distributed in the hope that it will be useful, but
1975       WITHOUT ANY WARRANTY; without even the implied warranty of
1976       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1977       General Public License for more details.
1978
1979       You should have received a copy of the GNU General Public License along
1980       with this program; if not, write to the Free Software Foundation, Inc.,
1981       51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
1982

BUGS

1984       To get a list of bugs against libguestfs, use this link:
1985       https://bugzilla.redhat.com/buglist.cgi?component=libguestfs&product=Virtualization+Tools
1986
1987       To report a new bug against libguestfs, use this link:
1988       https://bugzilla.redhat.com/enter_bug.cgi?component=libguestfs&product=Virtualization+Tools
1989
1990       When reporting a bug, please supply:
1991
1992       •   The version of libguestfs.
1993
1994       •   Where you got libguestfs (eg. which Linux distro, compiled from
1995           source, etc)
1996
1997       •   Describe the bug accurately and give a way to reproduce it.
1998
1999       •   Run libguestfs-test-tool(1) and paste the complete, unedited output
2000           into the bug report.
2001
2002
2003
2004guestfs-tools-1.48.2              2022-05-26                   virt-builder(1)
Impressum