Friday, March 18, 2022

Editing networks using virsh

 

Editing networks using virsh

virsh net-edit somenetwork
virsh net-destroy somenetwork
virsh net-start somenetwork


Unless you destroy and start it again it won't be effect. 

To verify the changes:

virsh net-dumpxml somenetwork 


Creating storage pool using virsh


Creating storage pool using virsh:


virsh pool-create-as default dir --target /var/lib/libvirt/images

virsh pool-dumpxml default > storage-pool.xml

virsh pool-define storage-pool.xml 

virsh pool-autostart default


Friday, March 11, 2022

Default username fedora - AWS

 

Default username for fedora instance in AWS: fedora  

For ubuntu OS, it is ubuntu.

For all others, ec2-user

Please refer AWS documentation for more authentic detail :)

https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/managing-users.html

Wednesday, March 9, 2022

Copy excluding specific file types

 


Copy/backup excluding specific file types: 

rsync -av -e ssh --exclude='*.qcow2' <directory to copy>  root@centos7:/home/username/


Wednesday, March 2, 2022

Removing virsh VMs and associated storage contents

 

To delete a VM and its corresponding storage: (Use with caution you are deleting all the associated storage)

# virsh undefine --domain {VM_NAME_HERE} --remove-all-storage
 

 To delete the snapshots too:

 # virsh undefine --domain {VM_NAME_HERE} --delete-snapshots --remove-all-storage

 

 Another safer approach is

# virsh list --all# virsh dumpxml  {VM_NAME_HERE} // get the corresponding image.

# virsh undefine --domain {VM_NAME_HERE}

# rm -rf  /path/to/image

 

I faced a error like this:

error: Refusing to undefine while domain managed save image exists

First run this command:

sudo virsh managedsave-remove  --domain <domain name> 

Next:
# virsh undefine --domain {VM_NAME_HERE} --remove-all-storage

If you face error saying "cannot define domain with nvram" use --nvram with above command.

# virsh undefine --nvram --domain {VM_NAME_HERE} --remove-all-storage


source: https://www.cyberciti.biz/faq/howto-linux-delete-a-running-vm-guest-on-kvm/