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

NAME

6       virt-sysprep - Reset, unconfigure or customize a virtual machine so
7       clones can be made
8

SYNOPSIS

10        virt-sysprep [--options] -d domname
11
12        virt-sysprep [--options] -a disk.img [-a disk.img ...]
13

WARNING

15       Using "virt-sysprep" on live virtual machines, or concurrently with
16       other disk editing tools, can be dangerous, potentially causing disk
17       corruption.  The virtual machine must be shut down before you use this
18       command, and disk images must not be edited concurrently.
19

DESCRIPTION

21       Virt-sysprep can reset or unconfigure a virtual machine so that clones
22       can be made from it.  Steps in this process include removing SSH host
23       keys, removing persistent network MAC configuration, and removing user
24       accounts.  Virt-sysprep can also customize a virtual machine, for
25       instance by adding SSH keys, users or logos.  Each step can be enabled
26       or disabled as required.
27
28       Virt-sysprep modifies the guest or disk image in place.  The guest must
29       be shut down.  If you want to preserve the existing contents of the
30       guest, you must snapshot, copy or clone the disk first.  See "COPYING
31       AND CLONING" below.
32
33       You do not need to run virt-sysprep as root.  In fact we'd generally
34       recommend that you don't.  The time you might want to run it as root is
35       when you need root in order to access the disk image, but even in this
36       case it would be better to change the permissions on the disk image to
37       be writable as the non-root user running virt-sysprep.
38
39       "Sysprep" stands for "system preparation" tool.  The name comes from
40       the Microsoft program sysprep.exe which is used to unconfigure Windows
41       machines in preparation for cloning them.  Having said that, virt-
42       sysprep does not currently work on Microsoft Windows guests.  We plan
43       to support Windows sysprepping in a future version, and we already have
44       code to do it.
45

OPTIONS

47       --help
48           Display brief help.
49
50       -a file
51       --add file
52           Add file which should be a disk image from a virtual machine.
53
54           The format of the disk image is auto-detected.  To override this
55           and force a particular format use the --format option.
56
57       -a URI
58       --add URI
59           Add a remote disk.  The URI format is compatible with guestfish.
60           See "ADDING REMOTE STORAGE" in guestfish(1).
61
62       --colors
63       --colours
64           Use ANSI colour sequences to colourize messages.  This is the
65           default when the output is a tty.  If the output of the program is
66           redirected to a file, ANSI colour sequences are disabled unless you
67           use this option.
68
69       -c URI
70       --connect URI
71           If using libvirt, connect to the given URI.  If omitted, then we
72           connect to the default libvirt hypervisor.
73
74           If you specify guest block devices directly (-a), then libvirt is
75           not used at all.
76
77       -d guest
78       --domain guest
79           Add all the disks from the named libvirt guest.  Domain UUIDs can
80           be used instead of names.
81
82       -n
83       --dry-run
84           Perform a read-only "dry run" on the guest.  This runs the sysprep
85           operation, but throws away any changes to the disk at the end.
86
87       --enable operations
88           Choose which sysprep operations to perform.  Give a comma-separated
89           list of operations, for example:
90
91            --enable ssh-hostkeys,udev-persistent-net
92
93           would enable ONLY "ssh-hostkeys" and "udev-persistent-net"
94           operations.
95
96           If the --enable option is not given, then we default to trying most
97           sysprep operations (see --list-operations to show which are
98           enabled).
99
100           Regardless of the --enable option, sysprep operations are skipped
101           for some guest types.
102
103           Use --list-operations to list operations supported by a particular
104           version of virt-sysprep.
105
106           See "OPERATIONS" below for a list and an explanation of each
107           operation.
108
109       --operation operations
110       --operations operations
111           Choose which sysprep operations to perform.  Give a comma-separated
112           list of operations, for example:
113
114            --operations ssh-hostkeys,udev-persistent-net
115
116           would enable ONLY "ssh-hostkeys" and "udev-persistent-net"
117           operations.
118
119           --operations allows you to enable and disable any operation,
120           including the default ones (which would be tried when specifying
121           neither --operations nor --enable) and all the available ones;
122           prepending a "-" in front of an operation name removes it from the
123           list of enabled operations, while the meta-names "defaults" and
124           "all" represent respectively the operations enabled by default and
125           all the available ones.  For example:
126
127            --operations firewall-rules,defaults,-tmp-files
128
129           would enable the "firewall-rules" operation (regardless whether it
130           is enabled by default), all the default ones, and disable the
131           "tmp-files" operation.
132
133           --operations can be specified multiple times; the first time the
134           set of enabled operations is empty, while any further --operations
135           affects the operations enabled so far.
136
137           If the --operations option is not given, then we default to trying
138           most sysprep operations (see --list-operations to show which are
139           enabled).
140
141           Regardless of the --operations option, sysprep operations are
142           skipped for some guest types.
143
144           Use --list-operations to list operations supported by a particular
145           version of virt-sysprep.
146
147           See "OPERATIONS" below for a list and an explanation of each
148           operation.
149
150       --echo-keys
151           When prompting for keys and passphrases, virt-sysprep normally
152           turns echoing off so you cannot see what you are typing.  If you
153           are not worried about Tempest attacks and there is no one else in
154           the room you can specify this flag to see what you are typing.
155
156       --format raw|qcow2|..
157       --format auto
158           The default for the -a option is to auto-detect the format of the
159           disk image.  Using this forces the disk format for -a options which
160           follow on the command line.  Using --format auto switches back to
161           auto-detection for subsequent -a options.
162
163           For example:
164
165            virt-sysprep --format raw -a disk.img
166
167           forces raw format (no auto-detection) for disk.img.
168
169            virt-sysprep --format raw -a disk.img --format auto -a another.img
170
171           forces raw format (no auto-detection) for disk.img and reverts to
172           auto-detection for another.img.
173
174           If you have untrusted raw-format guest disk images, you should use
175           this option to specify the disk format.  This avoids a possible
176           security problem with malicious guests (CVE-2010-3851).
177
178       --key SELECTOR
179           Specify a key for LUKS, to automatically open a LUKS device when
180           using the inspection.  "ID" can be either the libguestfs device
181           name, or the UUID of the LUKS device.
182
183           --key "ID":key:KEY_STRING
184               Use the specified "KEY_STRING" as passphrase.
185
186           --key "ID":file:FILENAME
187               Read the passphrase from FILENAME.
188
189           --key "ID":clevis
190               Attempt passphrase-less unlocking for "ID" with Clevis, over
191               the network.  Please refer to "ENCRYPTED DISKS" in guestfs(3)
192               for more information on network-bound disk encryption (NBDE).
193
194               Note that if any such option is present on the command line,
195               QEMU user networking will be automatically enabled for the
196               libguestfs appliance.
197
198       --keys-from-stdin
199           Read key or passphrase parameters from stdin.  The default is to
200           try to read passphrases from the user by opening /dev/tty.
201
202           If there are multiple encrypted devices then you may need to supply
203           multiple keys on stdin, one per line.
204
205       --list-operations
206           List the operations supported by the virt-sysprep program.
207
208           These are listed one per line, with one or more single-space-
209           separated fields, eg:
210
211            $ virt-sysprep --list-operations
212            bash-history * Remove the bash history in the guest
213            cron-spool * Remove user at-jobs and cron-jobs
214            dhcp-client-state * Remove DHCP client leases
215            dhcp-server-state * Remove DHCP server leases
216            [etc]
217
218           The first field is the operation name, which can be supplied to
219           --enable.  The second field is a "*" character if the operation is
220           enabled by default or blank if not.  Subsequent fields on the same
221           line are the description of the operation.
222
223           Before libguestfs 1.17.33 only the first (operation name) field was
224           shown and all operations were enabled by default.
225
226       --mount-options mp:opts[;mp:opts;...]
227           Set the mount options used when libguestfs opens the disk image.
228           Note this has no effect on the guest.  It is used when opening
229           certain guests such as ones using the UFS (BSD) filesystem.
230
231           Use a semicolon-separated list of "mountpoint:options" pairs.  You
232           may need to quote this list to protect it from the shell.
233
234           For example:
235
236            --mount-options "/:noatime"
237
238           will mount the root directory with "notime".  This example:
239
240            --mount-options "/:noatime;/var:rw,nodiratime"
241
242           will do the same, plus mount /var with "rw,nodiratime".
243
244       -q
245       --quiet
246           Don’t print log messages.
247
248           To enable detailed logging of individual file operations, use -x.
249
250       --network
251       --no-network
252           Enable or disable network access from the guest during the
253           installation.
254
255           In virt-sysprep, the network is disabled by default.  You must use
256           --network to enable it, in order that options such as --install or
257           --update will work.
258
259           virt-builder(1) has more information about the security advantages
260           of disabling the network.
261
262       -v
263       --verbose
264           Enable verbose messages for debugging.
265
266       -V
267       --version
268           Display version number and exit.
269
270       --wrap
271           Wrap error, warning, and informative messages.  This is the default
272           when the output is a tty.  If the output of the program is
273           redirected to a file, wrapping is disabled unless you use this
274           option.
275
276       -x  Enable tracing of libguestfs API calls.
277
278       --append-line FILE:LINE (see "customize" below)
279           Append a single line of text to the "FILE".  If the file does not
280           already end with a newline, then one is added before the appended
281           line.  Also a newline is added to the end of the "LINE" string
282           automatically.
283
284           For example (assuming ordinary shell quoting) this command:
285
286            --append-line '/etc/hosts:10.0.0.1 foo'
287
288           will add either "10.0.0.1 foo⏎" or "⏎10.0.0.1 foo⏎" to the file,
289           the latter only if the existing file does not already end with a
290           newline.
291
292           "⏎" represents a newline character, which is guessed by looking at
293           the existing content of the file, so this command does the right
294           thing for files using Unix or Windows line endings.  It also works
295           for empty or non-existent files.
296
297           To insert several lines, use the same option several times:
298
299            --append-line '/etc/hosts:10.0.0.1 foo'
300            --append-line '/etc/hosts:10.0.0.2 bar'
301
302           To insert a blank line before the appended line, do:
303
304            --append-line '/etc/hosts:'
305            --append-line '/etc/hosts:10.0.0.1 foo'
306
307       --chmod PERMISSIONS:FILE (see "customize" below)
308           Change the permissions of "FILE" to "PERMISSIONS".
309
310           Note: "PERMISSIONS" by default would be decimal, unless you prefix
311           it with 0 to get octal, ie. use 0700 not 700.
312
313       --commands-from-file FILENAME (see "customize" below)
314           Read the customize commands from a file, one (and its arguments)
315           each line.
316
317           Each line contains a single customization command and its
318           arguments, for example:
319
320            delete /some/file
321            install some-package
322            password some-user:password:its-new-password
323
324           Empty lines are ignored, and lines starting with "#" are comments
325           and are ignored as well.  Furthermore, arguments can be spread
326           across multiple lines, by adding a "\" (continuation character) at
327           the of a line, for example
328
329            edit /some/file:\
330              s/^OPT=.*/OPT=ok/
331
332           The commands are handled in the same order as they are in the file,
333           as if they were specified as --delete /some/file on the command
334           line.
335
336       --copy SOURCE:DEST (see "customize" below)
337           Copy files or directories recursively inside the guest.
338
339           Wildcards cannot be used.
340
341       --copy-in LOCALPATH:REMOTEDIR (see "customize" below)
342           Copy local files or directories recursively into the disk image,
343           placing them in the directory "REMOTEDIR" (which must exist).
344
345           Wildcards cannot be used.
346
347       --delete PATH (see "customize" below)
348           Delete a file from the guest.  Or delete a directory (and all its
349           contents, recursively).
350
351           You can use shell glob characters in the specified path.  Be
352           careful to escape glob characters from the host shell, if that is
353           required.  For example:
354
355            virt-customize --delete '/var/log/*.log'.
356
357           See also: --upload, --scrub.
358
359       --edit FILE:EXPR (see "customize" below)
360           Edit "FILE" using the Perl expression "EXPR".
361
362           Be careful to properly quote the expression to prevent it from
363           being altered by the shell.
364
365           Note that this option is only available when Perl 5 is installed.
366
367           See "NON-INTERACTIVE EDITING" in virt-edit(1).
368
369       --firstboot SCRIPT (see "customize" below)
370           Install "SCRIPT" inside the guest, so that when the guest first
371           boots up, the script runs (as root, late in the boot process).
372
373           The script is automatically chmod +x after installation in the
374           guest.
375
376           The alternative version --firstboot-command is the same, but it
377           conveniently wraps the command up in a single line script for you.
378
379           You can have multiple --firstboot options.  They run in the same
380           order that they appear on the command line.
381
382           Please take a look at "FIRST BOOT SCRIPTS" in virt-builder(1) for
383           more information and caveats about the first boot scripts.
384
385           See also --run.
386
387       --firstboot-command 'CMD+ARGS' (see "customize" below)
388           Run command (and arguments) inside the guest when the guest first
389           boots up (as root, late in the boot process).
390
391           You can have multiple --firstboot options.  They run in the same
392           order that they appear on the command line.
393
394           Please take a look at "FIRST BOOT SCRIPTS" in virt-builder(1) for
395           more information and caveats about the first boot scripts.
396
397           See also --run.
398
399       --firstboot-install PKG,PKG.. (see "customize" below)
400           Install the named packages (a comma-separated list).  These are
401           installed when the guest first boots using the guest’s package
402           manager (eg. apt, yum, etc.) and the guest’s network connection.
403
404           For an overview on the different ways to install packages, see
405           "INSTALLING PACKAGES" in virt-builder(1).
406
407       --hostname HOSTNAME (see "customize" below)
408           Set the hostname of the guest to "HOSTNAME".  You can use a dotted
409           hostname.domainname (FQDN) if you want.
410
411       --install PKG,PKG.. (see "customize" below)
412           Install the named packages (a comma-separated list).  These are
413           installed during the image build using the guest’s package manager
414           (eg. apt, yum, etc.) and the host’s network connection.
415
416           For an overview on the different ways to install packages, see
417           "INSTALLING PACKAGES" in virt-builder(1).
418
419           See also --update, --uninstall.
420
421       --keep-user-accounts USERS (see "user-account" below)
422           The user accounts to be kept in the guest.  The value of this
423           option is a list of user names separated by comma, where specifying
424           an user means it is going to be kept.  For example:
425
426            --keep-user-accounts mary
427
428           would keep the user account "mary".
429
430           This option can be specified multiple times.
431
432       --link TARGET:LINK[:LINK..] (see "customize" below)
433           Create symbolic link(s) in the guest, starting at "LINK" and
434           pointing at "TARGET".
435
436       --mkdir DIR (see "customize" below)
437           Create a directory in the guest.
438
439           This uses "mkdir -p" so any intermediate directories are created,
440           and it also works if the directory already exists.
441
442       --move SOURCE:DEST (see "customize" below)
443           Move files or directories inside the guest.
444
445           Wildcards cannot be used.
446
447       --no-logfile (see "customize" below)
448           Scrub "builder.log" (log file from build commands) from the image
449           after building is complete.  If you don't want to reveal precisely
450           how the image was built, use this option.
451
452           See also: "LOG FILE".
453
454       --no-selinux-relabel (see "customize" below)
455           Do not attempt to correct the SELinux labels of files in the guest.
456
457           In such guests that support SELinux, customization automatically
458           relabels files so that they have the correct SELinux label.  (The
459           relabeling is performed immediately, but if the operation fails,
460           customization will instead touch /.autorelabel on the image to
461           schedule a relabel operation for the next time the image boots.)
462           This option disables the automatic relabeling.
463
464           The option is a no-op for guests that do not support SELinux.
465
466       --password USER:SELECTOR (see "customize" below)
467           Set the password for "USER".  (Note this option does not create the
468           user account).
469
470           See "USERS AND PASSWORDS" in virt-builder(1) for the format of the
471           "SELECTOR" field, and also how to set up user accounts.
472
473       --password-crypto md5|sha256|sha512 (see "customize" below)
474           When the virt tools change or set a password in the guest, this
475           option sets the password encryption of that password to "md5",
476           "sha256" or "sha512".
477
478           "sha256" and "sha512" require glibc ≥ 2.7 (check crypt(3) inside
479           the guest).
480
481           "md5" will work with relatively old Linux guests (eg. RHEL 3), but
482           is not secure against modern attacks.
483
484           The default is "sha512" unless libguestfs detects an old guest that
485           didn't have support for SHA-512, in which case it will use "md5".
486           You can override libguestfs by specifying this option.
487
488           Note this does not change the default password encryption used by
489           the guest when you create new user accounts inside the guest.  If
490           you want to do that, then you should use the --edit option to
491           modify "/etc/sysconfig/authconfig" (Fedora, RHEL) or
492           "/etc/pam.d/common-password" (Debian, Ubuntu).
493
494       --remove-user-accounts USERS (see "user-account" below)
495           The user accounts to be removed from the guest.  The value of this
496           option is a list of user names separated by comma, where specifying
497           an user means it is going to be removed.  For example:
498
499            --remove-user-accounts bob,eve
500
501           would only remove the user accounts "bob" and "eve".
502
503           This option can be specified multiple times.
504
505       --root-password SELECTOR (see "customize" below)
506           Set the root password.
507
508           See "USERS AND PASSWORDS" in virt-builder(1) for the format of the
509           "SELECTOR" field, and also how to set up user accounts.
510
511           Note: In virt-builder, if you don't set --root-password then the
512           guest is given a random root password.
513
514       --run SCRIPT (see "customize" below)
515           Run the shell script (or any program) called "SCRIPT" on the disk
516           image.  The script runs virtualized inside a small appliance,
517           chrooted into the guest filesystem.
518
519           The script is automatically chmod +x.
520
521           If libguestfs supports it then a limited network connection is
522           available but it only allows outgoing network connections.  You can
523           also attach data disks (eg. ISO files) as another way to provide
524           data (eg. software packages) to the script without needing a
525           network connection (--attach).  You can also upload data files
526           (--upload).
527
528           You can have multiple --run options.  They run in the same order
529           that they appear on the command line.
530
531           See also: --firstboot, --attach, --upload.
532
533       --run-command 'CMD+ARGS' (see "customize" below)
534           Run the command and arguments on the disk image.  The command runs
535           virtualized inside a small appliance, chrooted into the guest
536           filesystem.
537
538           If libguestfs supports it then a limited network connection is
539           available but it only allows outgoing network connections.  You can
540           also attach data disks (eg. ISO files) as another way to provide
541           data (eg. software packages) to the script without needing a
542           network connection (--attach).  You can also upload data files
543           (--upload).
544
545           You can have multiple --run-command options.  They run in the same
546           order that they appear on the command line.
547
548           See also: --firstboot, --attach, --upload.
549
550       --script SCRIPT (see "script" below)
551           Run the named "SCRIPT" (a shell script or program) against the
552           guest.  The script can be any program on the host.  The script’s
553           current directory will be the guest’s root directory.
554
555           Note: If the script is not on the $PATH, then you must give the
556           full absolute path to the script.
557
558       --scriptdir SCRIPTDIR (see "script" below)
559           The mount point (an empty directory on the host) used when the
560           "script" operation is enabled and one or more scripts are specified
561           using --script parameter(s).
562
563           Note: "SCRIPTDIR" must be an absolute path.
564
565           If --scriptdir is not specified then a temporary mountpoint will be
566           created.
567
568       --scrub FILE (see "customize" below)
569           Scrub a file from the guest.  This is like --delete except that:
570
571           •   It scrubs the data so a guest could not recover it.
572
573           •   It cannot delete directories, only regular files.
574
575       --selinux-relabel (see "customize" below)
576           This is a compatibility option that does nothing.
577
578       --sm-attach SELECTOR (see "customize" below)
579           Attach to a pool using "subscription-manager".
580
581           See "SUBSCRIPTION-MANAGER" in virt-builder(1) for the format of the
582           "SELECTOR" field.
583
584       --sm-credentials SELECTOR (see "customize" below)
585           Set the credentials for "subscription-manager".
586
587           See "SUBSCRIPTION-MANAGER" in virt-builder(1) for the format of the
588           "SELECTOR" field.
589
590       --sm-register (see "customize" below)
591           Register the guest using "subscription-manager".
592
593           This requires credentials being set using --sm-credentials.
594
595       --sm-remove (see "customize" below)
596           Remove all the subscriptions from the guest using
597           "subscription-manager".
598
599       --sm-unregister (see "customize" below)
600           Unregister the guest using "subscription-manager".
601
602       --ssh-inject USER[:SELECTOR] (see "customize" below)
603           Inject an ssh key so the given "USER" will be able to log in over
604           ssh without supplying a password.  The "USER" must exist already in
605           the guest.
606
607           See "SSH KEYS" in virt-builder(1) for the format of the "SELECTOR"
608           field.
609
610           You can have multiple --ssh-inject options, for different users and
611           also for more keys for each user.
612
613       --timezone TIMEZONE (see "customize" below)
614           Set the default timezone of the guest to "TIMEZONE".  Use a
615           location string like "Europe/London"
616
617       --touch FILE (see "customize" below)
618           This command performs a touch(1)-like operation on "FILE".
619
620       --truncate FILE (see "customize" below)
621           This command truncates "FILE" to a zero-length file. The file must
622           exist already.
623
624       --truncate-recursive PATH (see "customize" below)
625           This command recursively truncates all files under "PATH" to zero-
626           length.
627
628       --uninstall PKG,PKG.. (see "customize" below)
629           Uninstall the named packages (a comma-separated list).  These are
630           removed during the image build using the guest’s package manager
631           (eg. apt, yum, etc.).  Dependent packages may also need to be
632           uninstalled to satisfy the request.
633
634           See also --install, --update.
635
636       --update (see "customize" below)
637           Do the equivalent of "yum update", "apt-get upgrade", or whatever
638           command is required to update the packages already installed in the
639           template to their latest versions.
640
641           See also --install, --uninstall.
642
643       --upload FILE:DEST (see "customize" below)
644           Upload local file "FILE" to destination "DEST" in the disk image.
645           File owner and permissions from the original are preserved, so you
646           should set them to what you want them to be in the disk image.
647
648           "DEST" could be the final filename.  This can be used to rename the
649           file on upload.
650
651           If "DEST" is a directory name (which must already exist in the
652           guest) then the file is uploaded into that directory, and it keeps
653           the same name as on the local filesystem.
654
655           See also: --mkdir, --delete, --scrub.
656
657       --write FILE:CONTENT (see "customize" below)
658           Write "CONTENT" to "FILE".
659

OPERATIONS

661       If the --enable/--operations option is not given, then most sysprep
662       operations are enabled.
663
664       Use "virt-sysprep --list-operations" to list all operations for your
665       virt-sysprep binary.  The ones which are enabled by default are marked
666       with a "*" character.  Regardless of the --enable/--operations options,
667       sysprep operations are skipped for some guest types.
668
669       Operations can be individually enabled using the --enable/--operations
670       options.  Use a comma-separated list, for example:
671
672        virt-sysprep --operations ssh-hostkeys,udev-persistent-net [etc..]
673
674       Future versions of virt-sysprep may add more operations.  If you are
675       using virt-sysprep and want predictable behaviour, specify only the
676       operations that you want to have enabled.
677
678       "*" = enabled by default when no --enable/--operations option is given.
679
680   abrt-data *
681       Remove the crash data generated by ABRT.
682
683       Remove the automatically generated ABRT crash data in
684       "/var/spool/abrt/".
685
686   backup-files *
687       Remove editor backup files from the guest.
688
689       The following files are removed from anywhere in the guest filesystem:
690
691       ·   *.bak
692
693       ·   *~
694
695       On Linux and Unix operating systems, only the following filesystems
696       will be examined:
697
698       ·   /etc
699
700       ·   /root
701
702       ·   /srv
703
704       ·   /tmp
705
706       ·   /var
707
708   bash-history *
709       Remove the bash history in the guest.
710
711       Remove the bash history of user "root" and any other users who have a
712       ".bash_history" file in their home directory.
713
714       Notes on bash-history
715
716       Currently this only looks in "/root" and "/home/*" for home
717       directories, so users with home directories in other locations won't
718       have the bash history removed.
719
720   blkid-tab *
721       Remove blkid tab in the guest.
722
723   ca-certificates
724       Remove CA certificates in the guest.
725
726       In case any certificate is removed, the system CA store is updated.
727
728   crash-data *
729       Remove the crash data generated by kexec-tools.
730
731       Remove the automatically generated kdump kernel crash data.
732
733   cron-spool *
734       Remove user at-jobs and cron-jobs.
735
736   customize *
737       Customize the guest.
738
739       Customize the guest by providing virt-customize(1) options for
740       installing packages, editing files and so on.
741
742   dhcp-client-state *
743       Remove DHCP client leases.
744
745   dhcp-server-state *
746       Remove DHCP server leases.
747
748   dovecot-data *
749       Remove Dovecot (mail server) data.
750
751   firewall-rules
752       Remove the firewall rules.
753
754       This removes custom firewall rules by removing
755       "/etc/sysconfig/iptables" or custom firewalld configuration in
756       "/etc/firewalld/*/*".
757
758       Note this is not enabled by default since it may expose guests to
759       exploits.  Use with care.
760
761   flag-reconfiguration
762       Flag the system for reconfiguration.
763
764       For Linux guests, this touches "/.unconfigured", which causes the first
765       boot to interactively query the user for settings such as the root
766       password and timezone.
767
768   fs-uuids
769       Change filesystem UUIDs.
770
771       On guests and filesystem types where this is supported, new random
772       UUIDs are generated and assigned to filesystems.
773
774       Notes on fs-uuids
775
776       The fs-uuids operation is disabled by default because it does not yet
777       find and update all the places in the guest that use the UUIDs.  For
778       example "/etc/fstab" or the bootloader.  Enabling this operation is
779       more likely than not to make your guest unbootable.
780
781       See: https://bugzilla.redhat.com/show_bug.cgi?id=991641
782
783   ipa-client *
784       Remove the IPA files.
785
786       Remove all the files related to an IPA (Identity, Policy, Audit)
787       system.  This effectively unenrolls the guest from an IPA server
788       without interacting with it.
789
790       This operation does not run "ipa-client".
791
792   kerberos-data
793       Remove Kerberos data in the guest.
794
795   kerberos-hostkeytab *
796       Remove the Kerberos host keytab file in the guest.
797
798   logfiles *
799       Remove many log files from the guest.
800
801       On Linux the following files are removed:
802
803       ·   /etc/Pegasus/*.cnf
804
805       ·   /etc/Pegasus/*.crt
806
807       ·   /etc/Pegasus/*.csr
808
809       ·   /etc/Pegasus/*.pem
810
811       ·   /etc/Pegasus/*.srl
812
813       ·   /root/anaconda-ks.cfg
814
815       ·   /root/anaconda-post.log
816
817       ·   /root/initial-setup-ks.cfg
818
819       ·   /root/install.log
820
821       ·   /root/install.log.syslog
822
823       ·   /root/original-ks.cfg
824
825       ·   /var/cache/fontconfig/*
826
827       ·   /var/cache/gdm/*
828
829       ·   /var/cache/man/*
830
831       ·   /var/lib/AccountService/users/*
832
833       ·   /var/lib/fprint/*
834
835       ·   /var/lib/logrotate.status
836
837       ·   /var/log/*.log*
838
839       ·   /var/log/BackupPC/LOG
840
841       ·   /var/log/ConsoleKit/*
842
843       ·   /var/log/anaconda.syslog
844
845       ·   /var/log/anaconda/*
846
847       ·   /var/log/apache2/*_log
848
849       ·   /var/log/apache2/*_log-*
850
851       ·   /var/log/apt/*
852
853       ·   /var/log/aptitude*
854
855       ·   /var/log/audit/*
856
857       ·   /var/log/btmp*
858
859       ·   /var/log/ceph/*.log
860
861       ·   /var/log/chrony/*.log
862
863       ·   /var/log/cron*
864
865       ·   /var/log/cups/*_log*
866
867       ·   /var/log/debug*
868
869       ·   /var/log/dmesg*
870
871       ·   /var/log/exim4/*
872
873       ·   /var/log/faillog*
874
875       ·   /var/log/firewalld*
876
877       ·   /var/log/gdm/*
878
879       ·   /var/log/glusterfs/*glusterd.vol.log
880
881       ·   /var/log/glusterfs/glusterfs.log
882
883       ·   /var/log/grubby*
884
885       ·   /var/log/httpd/*log
886
887       ·   /var/log/installer/*
888
889       ·   /var/log/jetty/jetty-console.log
890
891       ·   /var/log/journal/*
892
893       ·   /var/log/lastlog*
894
895       ·   /var/log/libvirt/libvirtd.log
896
897       ·   /var/log/libvirt/libxl/*.log
898
899       ·   /var/log/libvirt/lxc/*.log
900
901       ·   /var/log/libvirt/qemu/*.log
902
903       ·   /var/log/libvirt/uml/*.log
904
905       ·   /var/log/lightdm/*
906
907       ·   /var/log/mail/*
908
909       ·   /var/log/maillog*
910
911       ·   /var/log/messages*
912
913       ·   /var/log/ntp
914
915       ·   /var/log/ntpstats/*
916
917       ·   /var/log/ppp/connect-errors
918
919       ·   /var/log/rhsm/*
920
921       ·   /var/log/sa/*
922
923       ·   /var/log/secure*
924
925       ·   /var/log/setroubleshoot/*.log
926
927       ·   /var/log/spooler*
928
929       ·   /var/log/squid/*.log
930
931       ·   /var/log/syslog*
932
933       ·   /var/log/tallylog*
934
935       ·   /var/log/tuned/tuned.log
936
937       ·   /var/log/wtmp*
938
939       ·   /var/log/xferlog*
940
941       ·   /var/named/data/named.run
942
943   lvm-system-devices *
944       Remove LVM2 system.devices file.
945
946       On Linux guests, LVM2's scanning for physical volumes (PVs) may be
947       restricted to those block devices whose WWIDs are listed in
948       "/etc/lvm/devices/system.devices".  When cloning VMs, WWIDs may change,
949       breaking "lvm pvscan".  Remove "/etc/lvm/devices/system.devices".
950
951   lvm-uuids *
952       Change LVM2 PV and VG UUIDs.
953
954       On Linux guests that have LVM2 physical volumes (PVs) or volume groups
955       (VGs), new random UUIDs are generated and assigned to those PVs and
956       VGs.
957
958   machine-id *
959       Remove the local machine ID.
960
961       The machine ID is usually generated from a random source during system
962       installation and stays constant for all subsequent boots.  Optionally,
963       for stateless systems it is generated during runtime at boot if it is
964       found to be empty.
965
966   mail-spool *
967       Remove email from the local mail spool directory.
968
969   net-hostname *
970       Remove HOSTNAME and DHCP_HOSTNAME in network interface configuration.
971
972       For Fedora and Red Hat Enterprise Linux, this is removed from "ifcfg-*"
973       files.
974
975   net-hwaddr *
976       Remove HWADDR (hard-coded MAC address) configuration.
977
978       For Fedora and Red Hat Enterprise Linux, this is removed from "ifcfg-*"
979       files.
980
981   net-nmconn *
982       Remove system-local NetworkManager connection profiles (keyfiles).
983
984       On Fedora and Red Hat Enterprise Linux, remove the
985       "/etc/NetworkManager/system-connections/*.nmconnection" files.
986
987   pacct-log *
988       Remove the process accounting log files.
989
990       The system wide process accounting will store to the pacct log files if
991       the process accounting is on.
992
993   package-manager-cache *
994       Remove package manager cache.
995
996   pam-data *
997       Remove the PAM data in the guest.
998
999   passwd-backups *
1000       Remove /etc/passwd- and similar backup files.
1001
1002       On Linux the following files are removed:
1003
1004       ·   /etc/group-
1005
1006       ·   /etc/gshadow-
1007
1008       ·   /etc/passwd-
1009
1010       ·   /etc/shadow-
1011
1012       ·   /etc/subgid-
1013
1014       ·   /etc/subuid-
1015
1016   puppet-data-log *
1017       Remove the data and log files of puppet.
1018
1019   rh-subscription-manager *
1020       Remove the RH subscription manager files.
1021
1022   rhn-systemid *
1023       Remove the RHN system ID.
1024
1025   rpm-db *
1026       Remove host-specific RPM database files.
1027
1028       Remove host-specific RPM database files and locks.  RPM will recreate
1029       these files automatically if needed.
1030
1031   samba-db-log *
1032       Remove the database and log files of Samba.
1033
1034   script *
1035       Run arbitrary scripts against the guest.
1036
1037       The "script" module lets you run arbitrary shell scripts or programs
1038       against the guest.
1039
1040       Note this feature requires FUSE support.  You may have to enable this
1041       in your host, for example by adding the current user to the "fuse"
1042       group, or by loading a kernel module.
1043
1044       Use one or more --script parameters to specify scripts or programs that
1045       will be run against the guest.
1046
1047       The script or program is run with its current directory being the
1048       guest’s root directory, so relative paths should be used.  For example:
1049       "rm etc/resolv.conf" in the script would remove a Linux guest’s DNS
1050       configuration file, but "rm /etc/resolv.conf" would (try to) remove the
1051       host’s file.
1052
1053       Normally a temporary mount point for the guest is used, but you can
1054       choose a specific one by using the --scriptdir parameter.
1055
1056       Note: This is different from --firstboot scripts (which run in the
1057       context of the guest when it is booting first time).  --script scripts
1058       run on the host, not in the guest.
1059
1060   smolt-uuid *
1061       Remove the Smolt hardware UUID.
1062
1063   ssh-hostkeys *
1064       Remove the SSH host keys in the guest.
1065
1066       The SSH host keys are regenerated (differently) next time the guest is
1067       booted.
1068
1069       If, after cloning, the guest gets the same IP address, ssh will give
1070       you a stark warning about the host key changing:
1071
1072        @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
1073        @    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
1074        @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
1075        IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
1076
1077   ssh-userdir *
1078       Remove ".ssh" directories in the guest.
1079
1080       Remove the ".ssh" directory of user "root" and any other users who have
1081       a ".ssh" directory in their home directory.
1082
1083       Notes on ssh-userdir
1084
1085       Currently this only looks in "/root" and "/home/*" for home
1086       directories, so users with home directories in other locations won't
1087       have the ssh files removed.
1088
1089   sssd-db-log *
1090       Remove the database and log files of sssd.
1091
1092   tmp-files *
1093       Remove temporary files.
1094
1095       This removes temporary files under "/tmp" and "/var/tmp".
1096
1097   udev-persistent-net *
1098       Remove udev persistent net rules.
1099
1100       Remove udev persistent net rules which map the guest’s existing MAC
1101       address to a fixed ethernet device (eg. eth0).
1102
1103       After a guest is cloned, the MAC address usually changes.  Since the
1104       old MAC address occupies the old name (eg. eth0), this means the fresh
1105       MAC address is assigned to a new name (eg. eth1) and this is usually
1106       undesirable.  Erasing the udev persistent net rules avoids this.
1107
1108   user-account
1109       Remove the user accounts in the guest.
1110
1111       By default remove all the user accounts and their home directories.
1112       The "root" account is not removed.
1113
1114       See the --remove-user-accounts parameter for a way to specify how to
1115       remove only some users, or to not remove some others.
1116
1117   utmp *
1118       Remove the utmp file.
1119
1120       This file records who is currently logged in on a machine.  In modern
1121       Linux distros it is stored in a ramdisk and hence not part of the
1122       virtual machine’s disk, but it was stored on disk in older distros.
1123
1124   yum-uuid *
1125       Remove the yum UUID.
1126
1127       Yum creates a fresh UUID the next time it runs when it notices that the
1128       original UUID has been erased.
1129

COPYING AND CLONING

1131       Virt-sysprep can be used as part of a process of cloning guests, or to
1132       prepare a template from which guests can be cloned.  There are many
1133       different ways to achieve this using the virt tools, and this section
1134       is just an introduction.
1135
1136       A virtual machine (when switched off) consists of two parts:
1137
1138       configuration
1139           The configuration or description of the guest.  eg. The libvirt XML
1140           (see "virsh dumpxml"), the running configuration of the guest, or
1141           another external format like OVF.
1142
1143           Some configuration items that might need to be changed:
1144
1145           •   name
1146
1147           •   UUID
1148
1149           •   path to block device(s)
1150
1151           •   network card MAC address
1152
1153       block device(s)
1154           One or more hard disk images, themselves containing files,
1155           directories, applications, kernels, configuration, etc.
1156
1157           Some things inside the block devices that might need to be changed:
1158
1159           •   hostname and other net configuration
1160
1161           •   UUID
1162
1163           •   SSH host keys
1164
1165           •   Windows unique security ID (SID)
1166
1167           •   Puppet registration
1168
1169   COPYING THE BLOCK DEVICE
1170       Starting with an original guest, you probably wish to copy the guest
1171       block device and its configuration to make a template.  Then once you
1172       are happy with the template, you will want to make many clones from it.
1173
1174                               virt-sysprep
1175                                    |
1176                                    v
1177        original guest --------> template ---------->
1178                                             \------> cloned
1179                                              \-----> guests
1180                                               \---->
1181
1182       You can, of course, just copy the block device on the host using cp(1)
1183       or dd(1).
1184
1185                          dd                 dd
1186        original guest --------> template ---------->
1187                                             \------> cloned
1188                                              \-----> guests
1189                                               \---->
1190
1191       There are some smarter (and faster) ways too:
1192
1193                                 snapshot
1194                       template ---------->
1195                                   \------> cloned
1196                                    \-----> guests
1197                                     \---->
1198
1199       You may want to run virt-sysprep twice, once to reset the guest (to
1200       make a template) and a second time to customize the guest for a
1201       specific user:
1202
1203                           virt-sysprep        virt-sysprep
1204                             (reset)      (add user, keys, logos)
1205                                |                   |
1206                        dd      v          dd       v
1207        original guest ----> template ---------> copied ------> custom
1208                                                 template       guest
1209
1210       •   Create a snapshot using qemu-img:
1211
1212            qemu-img create -f qcow2 -o backing_file=original snapshot.qcow
1213
1214           The advantage is that you don’t need to copy the original (very
1215           fast) and only changes are stored (less storage required).
1216
1217           Note that writing to the backing file once you have created guests
1218           on top of it is not possible: you will corrupt the guests.
1219
1220       •   Create a snapshot using "lvcreate --snapshot".
1221
1222       •   Other ways to create snapshots include using filesystems-level
1223           tools (for filesystems such as btrfs).
1224
1225           Most Network Attached Storage (NAS) devices can also create cheap
1226           snapshots from files or LUNs.
1227
1228       •   Get your NAS to duplicate the LUN.  Most NAS devices can also
1229           duplicate LUNs very cheaply (they copy them on-demand in the
1230           background).
1231
1232       •   Prepare your template using virt-sparsify(1).  See below.
1233
1234   VIRT-CLONE
1235       A separate tool, virt-clone(1), can be used to duplicate the block
1236       device and/or modify the external libvirt configuration of a guest.  It
1237       will reset the name, UUID and MAC address of the guest in the libvirt
1238       XML.
1239
1240       virt-clone(1) does not use libguestfs and cannot look inside the disk
1241       image.  This was the original motivation to write virt-sysprep.
1242
1243   SPARSIFY
1244                     virt-sparsify
1245        original guest --------> template
1246
1247       virt-sparsify(1) can be used to make the cloning template smaller,
1248       making it easier to compress and/or faster to copy.
1249
1250       Notice that since virt-sparsify also copies the image, you can use it
1251       to make the initial copy (instead of "dd").
1252
1253   RESIZE
1254                                virt-resize
1255                       template ---------->
1256                                   \------> cloned
1257                                    \-----> guests
1258                                     \---->
1259
1260       If you want to give people cloned guests, but let them pick the size of
1261       the guest themselves (eg. depending on how much they are prepared to
1262       pay for disk space), then instead of copying the template, you can run
1263       virt-resize(1).  Virt-resize performs a copy and resize, and thus is
1264       ideal for cloning guests from a template.
1265

FIRSTBOOT VS SCRIPT

1267       The two options --firstboot and --script both supply shell scripts that
1268       are run against the guest.  However these two options are significantly
1269       different.
1270
1271       --firstboot script uploads the file "script" into the guest and
1272       arranges that it will run, in the guest, when the guest is next booted.
1273       (The script will only run once, at the "first boot").
1274
1275       --script script runs the shell "script" on the host, with its current
1276       directory inside the guest filesystem.
1277
1278       If you needed, for example, to "yum install" new packages, then you
1279       must not use --script for this, since that would (a) run the "yum"
1280       command on the host and (b) wouldn't have access to the same resources
1281       (repositories, keys, etc.) as the guest.  Any command that needs to run
1282       on the guest must be run via --firstboot.
1283
1284       On the other hand if you need to make adjustments to the guest
1285       filesystem (eg. copying in files), then --script is ideal since (a) it
1286       has access to the host filesystem and (b) you will get immediate
1287       feedback on errors.
1288
1289       Either or both options can be used multiple times on the command line.
1290

SECURITY

1292       Virtual machines that employ full disk encryption internally to the
1293       guest should not be considered for cloning and distribution, as it
1294       provides multiple parties with the same internal volume key, enabling
1295       any one such party to decrypt all the other clones.  Refer to the LUKS
1296       FAQ for details.
1297
1298       Although virt-sysprep removes some sensitive information from the
1299       guest, it does not pretend to remove all of it.  You should examine the
1300       "OPERATIONS" above and the guest afterwards.
1301
1302       Sensitive files are simply removed.  The data they contained may still
1303       exist on the disk, easily recovered with a hex editor or undelete tool.
1304       The --scrub option can be used to scrub files instead of just deleting
1305       them.  virt-sparsify(1) is another way to remove this content.  See
1306       also the scrub(1) command to get rid of deleted content in directory
1307       entries and inodes.
1308
1309   RANDOM SEED
1310       (This section applies to Linux guests only)
1311
1312       For supported guests, virt-sysprep writes a few bytes of randomness
1313       from the host into the guest’s random seed file.
1314
1315       If this is just done once and the guest is cloned from the same
1316       template, then each guest will start with the same entropy, and things
1317       like SSH host keys and TCP sequence numbers may be predictable.
1318
1319       Therefore you should arrange to add more randomness after cloning from
1320       a template too, which can be done by enabling just the customize
1321       module:
1322
1323        cp template.img newguest.img
1324        virt-sysprep --enable customize -a newguest.img
1325

SELINUX

1327       For guests which make use of SELinux, special handling for them might
1328       be needed when using operations which create new files or alter
1329       existing ones.
1330
1331       For further details, see "SELINUX" in virt-builder(1).
1332

WINDOWS 8

1334       Windows 8 "fast startup" can prevent virt-sysprep from working.  See
1335       "WINDOWS HIBERNATION AND WINDOWS 8 FAST STARTUP" in guestfs(3).
1336

EXIT STATUS

1338       This program returns 0 on success, or 1 if there was an error.
1339

ENVIRONMENT VARIABLES

1341       "VIRT_TOOLS_DATA_DIR"
1342           This can point to the directory containing data files used for
1343           Windows firstboot installation.
1344
1345           Normally you do not need to set this.  If not set, a compiled-in
1346           default will be used (something like /usr/share/virt-tools).
1347
1348           This directory may contain the following files:
1349
1350           rhsrvany.exe
1351               This is the RHSrvAny Windows binary, used to install a
1352               "firstboot" script in Windows guests.  It is required if you
1353               intend to use the --firstboot or --firstboot-command options
1354               with Windows guests.
1355
1356               See also: "https://github.com/rwmjones/rhsrvany"
1357
1358           pvvxsvc.exe
1359               This is a Windows binary shipped with SUSE VMDP, used to
1360               install a "firstboot" script in Windows guests.  It is required
1361               if you intend to use the --firstboot or --firstboot-command
1362               options with Windows guests.
1363
1364       For other environment variables, see "ENVIRONMENT VARIABLES" in
1365       guestfs(3).
1366

SEE ALSO

1368       guestfs(3), guestfish(1), virt-builder(1), virt-clone(1),
1369       virt-customize(1), virt-rescue(1), virt-resize(1), virt-sparsify(1),
1370       virsh(1), lvcreate(8), qemu-img(1), scrub(1), http://libguestfs.org/,
1371       http://libvirt.org/.
1372

AUTHORS

1374       Richard W.M. Jones http://people.redhat.com/~rjones/
1375
1376       Wanlong Gao, Fujitsu Ltd.
1377
1379       Copyright (C) 2011-2020 Red Hat Inc.
1380
1381       Copyright (C) 2012 Fujitsu Ltd.
1382

LICENSE

1384       This program is free software; you can redistribute it and/or modify it
1385       under the terms of the GNU General Public License as published by the
1386       Free Software Foundation; either version 2 of the License, or (at your
1387       option) any later version.
1388
1389       This program is distributed in the hope that it will be useful, but
1390       WITHOUT ANY WARRANTY; without even the implied warranty of
1391       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1392       General Public License for more details.
1393
1394       You should have received a copy of the GNU General Public License along
1395       with this program; if not, write to the Free Software Foundation, Inc.,
1396       51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
1397

BUGS

1399       To get a list of bugs against libguestfs, use this link:
1400       https://bugzilla.redhat.com/buglist.cgi?component=libguestfs&product=Virtualization+Tools
1401
1402       To report a new bug against libguestfs, use this link:
1403       https://bugzilla.redhat.com/enter_bug.cgi?component=libguestfs&product=Virtualization+Tools
1404
1405       When reporting a bug, please supply:
1406
1407       •   The version of libguestfs.
1408
1409       •   Where you got libguestfs (eg. which Linux distro, compiled from
1410           source, etc)
1411
1412       •   Describe the bug accurately and give a way to reproduce it.
1413
1414       •   Run libguestfs-test-tool(1) and paste the complete, unedited output
1415           into the bug report.
1416
1417
1418
1419guestfs-tools-1.49.7              2022-12-10                   virt-sysprep(1)
Impressum