config in cloud image

how to customize cloud image config

change cloud image default config

⚠ EOL (End-of-Life) notice: RHEL 7 reached EOL on 2024-06-30. The examples below use rhel-server-7.6.qcow2 — an EOL release, and yum is the RHEL 7-era package manager. virt-customize itself is unchanged and fully supported on RHEL 8/9, AlmaLinux and Rocky Linux (install via dnf, e.g. sudo dnf install -y libguestfs-tools). For a modern target, replace the image with an up-to-date cloud image, for example:

install package

1
2
3
4
5
6
# RHEL 7 / CentOS 7 era (EOL): yum
sudo yum install -y libguestfs-tools
# or
sudo yum install -y libguestfs-tools-c
# RHEL 8/9 / AlmaLinux / Rocky Linux: dnf
sudo dnf install -y libguestfs-tools

Set root password

1
virt-customize -a rhel-server-7.6.qcow2 --root-password password:StrongRootPassword

Register System

1
2
3
virt-customize -a overcloud-full.qcow2 --run-command 'subscription-manager register --username=[username] --password=[password]'

virt-customize -a rhel-server-7.6.qcow2 --run-command 'subscription-manager attach --pool [subscription-pool]'

Install Software packages inside an image

1
2
3
virt-customize -a rhel-server-7.6.qcow2 --install [vim,bash-completion,wget,curl,telnet,unzip]

virt-customize -a rhel-server-7.6.qcow2 --install net-tools

Upload SSH public key

1
2
3
4
5
# set ssh-key for a user(The user must exist in image)
virt-customize -a rhel-server-7.6.qcow2  --ssh-inject root:file:./id_rsa.pub
# or
virt-customize -a rhel-server-7.6.qcow2 --run-command 'useradd mystic' \
	--ssh-inject mystic:file:~/.ssh/id_rsa.pub

Uploading files

1
2
3
4
5
virt-customize -a rhel-server-7.6.qcow2 --upload rhsm.conf:/etc/rhsm/rhsm.conf

virt-customize -a rhel-server-7.6.qcow2 --upload yum.conf:/etc/yum.conf

virt-customize -a rhel-server-7.6.qcow2 --upload proxy.sh:/etc/profile.d/

The format: local_file_path:image_file_path

Set Timezone

1
virt-customize -a rhel-server-7.6.qcow2 --timezone "Asia/Shanghai"

Relabel SELinux

1
virt-customize -a rhel-server-7.6.qcow2 --selinux-relabel
Licensed under CC BY-NC-SA 4.0
Last updated on Aug 14, 2026 00:00 UTC