using libguestfs virt-customize tool to modify qcow2 image and reset root password.


ibguestfs is a C library and a set of tools for accessing and modifying virtual disk images used in platform virtualization. The tools can be used for viewing and editing virtual machines managed by libvirt and files inside VMs, scripting changes to VMs, creating VMs, and much else beside.

virt-customize is one of them as example.
If you forgot root user password here is how you can modify .

# virsh shutdown debian9-vm1
# virt-customize -a /var/lib/libvirt/images/debian9-vm1.qcow2 --root-password password:NewRootUserPasswordHere 


not only this but you can edit many more.

The –run-command option is used to execute any command inside a virtual image file.
1) register with rhel subscription
virt-customize -a rhel-server-7.6.qcow2 --run-command 'subscription-manager attach --pool [subscription-pool]'
 
 
Install software or packages-
virt-customize -a rhel-server-7.6.qcow2 --install net-tools

 Upload a file into image

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

Setup timezone

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

Upload your ssh public key
virt-customize -a rhel-server-7.6.qcow2  --ssh-inject jmutai:file:./id_rsa.pub


Comments

Popular posts from this blog

Running web ssh client on port 443 /80 with nginx as reverse proxy

Running cockpit behind nginx reverse proxy with nginx ssl and cockpit non ssl

Setup VOD streaming server with nginx using RTMP on Ubuntu 18.04