Difference between revisions of "Virt-sysprep"

From wikieduonline
Jump to navigation Jump to search
Tags: Mobile web edit, Mobile edit
 
(10 intermediate revisions by the same user not shown)
Line 1: Line 1:
<code>[[virt-sysprep]]</code><ref>http://libguestfs.org/virt-sysprep.1.html</ref> command included in <code>[[libguestfs-tools]]</code> package reset, unconfigure or customize a virtual machine so clones can be made.  
+
<code>[[virt-sysprep]]</code><ref>http://libguestfs.org/virt-sysprep.1.html</ref> command included in <code>[[libguestfs-tools]]</code> package reset, unconfigure or customize a virtual machine so [[clone]]s can be made.  
  
 
'''WARNING:''' Using <code>virt-sysprep</code> on live virtual machines, or concurrently with other disk editing tools, can be dangerous, potentially causing disk corruption. Virtual Machine must be shut down.
 
'''WARNING:''' Using <code>virt-sysprep</code> on live virtual machines, or concurrently with other disk editing tools, can be dangerous, potentially causing disk corruption. Virtual Machine must be shut down.
Line 8: Line 8:
 
:::<code>[[virt-sysprep --list-operations]]</code>
 
:::<code>[[virt-sysprep --list-operations]]</code>
 
* Performs a read-only "dry run" sysprep operation:  
 
* Performs a read-only "dry run" sysprep operation:  
:::<code>virt-sysprep --dry-run TEST_VM_TO_RESET</code>
+
:::<code>virt-sysprep --[[dry-run]] TEST_VM_TO_RESET</code>
 
* To reset everything:  
 
* To reset everything:  
 
:::<code>virt-sysprep -d TEST_VM_TO_RESET</code>
 
:::<code>virt-sysprep -d TEST_VM_TO_RESET</code>
 
* To Change name and force to keep user account MY_USERNAME_TO_KEEP
 
* To Change name and force to keep user account MY_USERNAME_TO_KEEP
:::<code>virt-sysprep -d testvm --hostname testvm --enable user-account --keep-user-accounts MY_USERNAME_TO_KEEP</code>
+
:::<code>virt-sysprep -d testvm --[[hostname]] testvm --enable user-account --keep-user-accounts MY_USERNAME_TO_KEEP</code>
 +
 
 +
* <code>virt-sysprep -d bionic</code><ref>https://docs.openstack.org/image-guide/ubuntu-image.html</ref>
  
 
== Related commands ==
 
== Related commands ==
 
* <code>[[virt-builder]]</code>
 
* <code>[[virt-builder]]</code>
 +
* <code>[[virt-install]]</code>
 +
 +
== Help ==
 +
 +
virt-sysprep
 +
virt-sysprep: error: you must give either -a or -d options.  Read
 +
virt-sysprep(1) man page for further information.
 +
 +
If reporting bugs, run virt-sysprep with debugging enabled and include the
 +
complete output:
 +
 +
  virt-sysprep -v -x [...]
 +
 +
 +
 +
virt-sysprep --help
 +
virt-sysprep: reset or unconfigure a virtual machine so clones can be made
 +
 +
  virt-sysprep [--options] -d domname
 +
 +
  virt-sysprep [--options] -a disk.img [-a disk.img ...]
 +
 +
A short summary of the options is given below.  For detailed help please
 +
read the man page virt-sysprep(1).
 +
 +
Options:
 +
  -a, --add <file>                    Add disk image file
 +
  --append-line <FILE:LINE>          Append line(s) to the file
 +
  -c, --connect <uri>                Set libvirt URI
 +
  --chmod <PERMISSIONS:FILE>          Change the permissions of a file
 +
  --color, --colors, --colour, --colours
 +
                                      Use ANSI colour sequences even if not tty
 +
  --commands-from-file <FILENAME>    Read customize commands from file
 +
  --copy <SOURCE:DEST>                Copy files in disk image
 +
  --copy-in <LOCALPATH:REMOTEDIR>    Copy local files or directories into image
 +
  -d, --domain <domain>              Set libvirt guest name
 +
  --delete <PATH>                    Delete a file or directory
 +
  -n, --dryrun, --dry-run            Perform a dry run
 +
  --echo-keys                        Don’t turn off echo for passphrases
 +
  --edit <FILE:EXPR>                  Edit file using Perl expression
 +
  --enable <operations>              Enable specific operations
 +
  --firstboot <SCRIPT>                Run script at first guest boot
 +
  [[--firstboot-command]] <'CMD+ARGS'>    Run command at first guest boot
 +
  --firstboot-install <PKG,PKG..>    Add package(s) to install at first boot
 +
  --format <format>                  Set format (default: auto)
 +
  --help                              Display brief help
 +
  --hostname <HOSTNAME>              Set the hostname
 +
  --install <PKG,PKG..>              Add package(s) to install
 +
  --keep-user-accounts <users>        Users to keep
 +
  --key <SELECTOR>                    Specify a LUKS key
 +
  --keys-from-stdin                  Read passphrases from stdin
 +
  --link <TARGET:LINK[:LINK..]>      Create symbolic links
 +
  --list-operations                  List supported operations
 +
  --mkdir <DIR>                      Create a directory
 +
  --mount-options <opts>              Set mount options (eg /:noatime;/var:rw,noatime)
 +
  --move <SOURCE:DEST>                Move files in disk image
 +
  --network                          Enable appliance network
 +
  --no-logfile                        Scrub build log file
 +
  --no-network                        Disable appliance network (default)
 +
  --no-selinux-relabel                Compatibility option, does nothing
 +
  --operation, --operations <operations>
 +
                                      Enable/disable specific operations
 +
  --password <USER:SELECTOR>          Set user password
 +
  --password-crypto <md5|sha256|sha512>
 +
                                      Set password crypto
 +
  -q, --quiet                        Don’t print progress messages
 +
  --remove-user-accounts <users>      Users to remove
 +
  --root-password <SELECTOR>          Set root password
 +
  --run <SCRIPT>                      Run script in disk image
 +
  --run-command <'CMD+ARGS'>          Run command in disk image
 +
  --script <script>                  Script or program to run on guest
 +
  --scriptdir <dir>                  Mount point on host
 +
  --scrub <FILE>                      Scrub a file
 +
  --selinux-relabel                  Relabel files with correct SELinux labels
 +
  --sm-attach <SELECTOR>              Attach to a subscription-manager pool
 +
  --sm-credentials <SELECTOR>        Credentials for subscription-manager
 +
  --sm-register                      Register using subscription-manager
 +
  --sm-remove                        Remove all the subscriptions
 +
  --sm-unregister                    Unregister using subscription-manager
 +
  --ssh-inject <USER[:SELECTOR]>      Inject a public key into the guest
 +
  --timezone <TIMEZONE>              Set the default timezone
 +
  --touch <FILE>                      Run touch on a file
 +
  --truncate <FILE>                  Truncate a file to zero size
 +
  --truncate-recursive <PATH>        Recursively truncate all files in directory
 +
  --uninstall <PKG,PKG..>            Uninstall package(s)
 +
  --update                            Update packages
 +
  --upload <FILE:DEST>                Upload local file to destination
 +
  -V, --version                      Display version and exit
 +
  -v, --verbose                      Enable libguestfs debugging messages
 +
  --write <FILE:CONTENT>              Write file
 +
  -x                                  Enable tracing of libguestfs calls
  
 +
== Activities ==
 +
* Read https://www.cyberciti.biz/faq/reset-a-kvm-clone-virtual-machines-with-virt-sysprep-on-linux/
  
 
== See also ==
 
== See also ==

Latest revision as of 07:31, 4 April 2021

virt-sysprep[1] command included in libguestfs-tools package reset, unconfigure or customize a virtual machine so clones can be made.

WARNING: Using virt-sysprep on live virtual machines, or concurrently with other disk editing tools, can be dangerous, potentially causing disk corruption. Virtual Machine must be shut down.

Command examples[edit]

  • List operations:
virt-sysprep --list-operations
  • Performs a read-only "dry run" sysprep operation:
virt-sysprep --dry-run TEST_VM_TO_RESET
  • To reset everything:
virt-sysprep -d TEST_VM_TO_RESET
  • To Change name and force to keep user account MY_USERNAME_TO_KEEP
virt-sysprep -d testvm --hostname testvm --enable user-account --keep-user-accounts MY_USERNAME_TO_KEEP
  • virt-sysprep -d bionic[2]

Related commands[edit]

Help[edit]

virt-sysprep
virt-sysprep: error: you must give either -a or -d options.  Read
virt-sysprep(1) man page for further information.

If reporting bugs, run virt-sysprep with debugging enabled and include the
complete output:

 virt-sysprep -v -x [...]


virt-sysprep --help
virt-sysprep: reset or unconfigure a virtual machine so clones can be made

 virt-sysprep [--options] -d domname

 virt-sysprep [--options] -a disk.img [-a disk.img ...]

A short summary of the options is given below.  For detailed help please
read the man page virt-sysprep(1).

Options:
  -a, --add <file>                    Add disk image file
  --append-line <FILE:LINE>           Append line(s) to the file
  -c, --connect <uri>                 Set libvirt URI
  --chmod <PERMISSIONS:FILE>          Change the permissions of a file
  --color, --colors, --colour, --colours
                                      Use ANSI colour sequences even if not tty
  --commands-from-file <FILENAME>     Read customize commands from file
  --copy <SOURCE:DEST>                Copy files in disk image
  --copy-in <LOCALPATH:REMOTEDIR>     Copy local files or directories into image
  -d, --domain <domain>               Set libvirt guest name
  --delete <PATH>                     Delete a file or directory
  -n, --dryrun, --dry-run             Perform a dry run
  --echo-keys                         Don’t turn off echo for passphrases
  --edit <FILE:EXPR>                  Edit file using Perl expression
  --enable <operations>               Enable specific operations
  --firstboot <SCRIPT>                Run script at first guest boot
  --firstboot-command <'CMD+ARGS'>    Run command at first guest boot
  --firstboot-install <PKG,PKG..>     Add package(s) to install at first boot
  --format <format>                   Set format (default: auto)
  --help                              Display brief help
  --hostname <HOSTNAME>               Set the hostname
  --install <PKG,PKG..>               Add package(s) to install
  --keep-user-accounts <users>        Users to keep
  --key <SELECTOR>                    Specify a LUKS key
  --keys-from-stdin                   Read passphrases from stdin
  --link <TARGET:LINK[:LINK..]>       Create symbolic links
  --list-operations                   List supported operations
  --mkdir <DIR>                       Create a directory
  --mount-options <opts>              Set mount options (eg /:noatime;/var:rw,noatime)
  --move <SOURCE:DEST>                Move files in disk image
  --network                           Enable appliance network
  --no-logfile                        Scrub build log file
  --no-network                        Disable appliance network (default)
  --no-selinux-relabel                Compatibility option, does nothing
  --operation, --operations <operations>
                                      Enable/disable specific operations
  --password <USER:SELECTOR>          Set user password
  --password-crypto <md5|sha256|sha512>
                                      Set password crypto
  -q, --quiet                         Don’t print progress messages
  --remove-user-accounts <users>      Users to remove
  --root-password <SELECTOR>          Set root password
  --run <SCRIPT>                      Run script in disk image
  --run-command <'CMD+ARGS'>          Run command in disk image
  --script <script>                   Script or program to run on guest
  --scriptdir <dir>                   Mount point on host
  --scrub <FILE>                      Scrub a file
  --selinux-relabel                   Relabel files with correct SELinux labels
  --sm-attach <SELECTOR>              Attach to a subscription-manager pool
  --sm-credentials <SELECTOR>         Credentials for subscription-manager
  --sm-register                       Register using subscription-manager
  --sm-remove                         Remove all the subscriptions
  --sm-unregister                     Unregister using subscription-manager
  --ssh-inject <USER[:SELECTOR]>      Inject a public key into the guest
  --timezone <TIMEZONE>               Set the default timezone
  --touch <FILE>                      Run touch on a file
  --truncate <FILE>                   Truncate a file to zero size
  --truncate-recursive <PATH>         Recursively truncate all files in directory
  --uninstall <PKG,PKG..>             Uninstall package(s)
  --update                            Update packages
  --upload <FILE:DEST>                Upload local file to destination
  -V, --version                       Display version and exit
  -v, --verbose                       Enable libguestfs debugging messages
  --write <FILE:CONTENT>              Write file
  -x                                  Enable tracing of libguestfs calls

Activities[edit]

See also[edit]

Text is available under the Creative Commons Attribution-ShareAlike License; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy.

Source: wikiversity

Advertising: