大网数据广告活动
Linux 与通用命令

virt-sysprep · 常用命令示例

· 52CE 我爱测

Reset, unconfigure, or customize a virtual machine image. > This command can be used on a virtual machine or directly on a virtual machine disk image. > Note: You may need to pass `--connect URI` to the commands or set up the URI in `$XDG_CONFIG_HOME/libvirt/libvirt.conf`. > More

virt-sysprep

Reset, unconfigure, or customize a virtual machine image. This command can be used on a virtual machine or directly on a virtual machine disk image. Note: You may need to pass --connect URI to the commands or set up the URI in $XDG_CONFIG_HOME/libvirt/libvirt.conf. More information: https://libguestfs.org/virt-sysprep.1.html.

  • List all supported operations (default enabled operations are indicated with asterisks):

virt-sysprep --list-operations

  • Run only the specified operations:

sudo virt-sysprep --operations

  • Remove sensitive system data from a virtual machine image (operations marked as default):

sudo virt-sysprep

  • Simulate running all enabled operations on a virtual machine specified by its name:

sudo virt-sysprep

  • Reset NetworkManager network configurations, persistent MAC mappings, and the hostname to avoid network conflicts:

sudo virt-sysprep --operations machine-id,net-hwaddr,net-hostname,net-nmconn,customize --hostname

  • Set the root password for a disk image:

sudo virt-sysprep --operations customize --root-password password:

  • Inject a new user with a defined password and add them to the sudo group:

sudo virt-sysprep --run-command 'useradd -m && echo : | chpasswd && usermod -aG sudo '

  • Install specific package(s) on a disk image (use --update to upgrade all installed packages to latest):

sudo virt-sysprep --operations customize --network --install

来源:tldr-pages contributors · 作者与贡献记录 · CC BY 4.0。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
tldr-pages contributors
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。