4,348
edits
→Configure bridged networking: create and set up a storage pool |
mNo edit summary |
||
(11 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
= Installation = | = Installation = | ||
== Creating a RHEL 8.2 VM == | |||
{{testedon|2020-06-30|RHEL 8.2}} | |||
<source lang="console"> | |||
# virt-install --name=iqbal --vcpus=2 --memory=2048 --cdrom=/home/mhan/Downloads/rhel-8.2-x86_64-boot.iso --disk size=5 --os-variant=rhel8.2 --graphics vnc | |||
</source> | |||
Checking which port VNC is connected to | |||
<source lang="console"> | |||
# virsh vncdisplay vm-name | |||
</source> | |||
Attaching a CD-ROM | |||
<source lang="console"> | |||
# virsh attach-disk iqbal /var/lib/libvirt/boot/rhel-8.2-x86_64-boot.iso --type cdrom --mode readonly --target sda --targetbus sata | |||
</source> | |||
== Installing on CentOS 7.5 == | == Installing on CentOS 7.5 == | ||
Line 30: | Line 50: | ||
irqbypass 13503 1 kvm | irqbypass 13503 1 kvm | ||
</source> | </source> | ||
= Configuration = | |||
== Configure bridged networking == | == Configure bridged networking == | ||
Line 119: | Line 142: | ||
Pool libvirt-images started | Pool libvirt-images started | ||
</source> | </source> | ||
== Instantiation == | |||
== Create a VM == | |||
This example creates an Ubuntu VM: | |||
<source lang="bash"> | |||
# virt-install --virt-type=kvm --name ubuntu1 --memory 4096 --vcpus 2 --os-variant ubuntu17.04 --os-type Linux --cdrom=/var/lib/libvirt/boot/ubuntu-18.04-desktop-amd64.iso --network bridge=br0,model=virtio --graphics vnc --disk path=/var/lib/libvirt/images/ubuntu1.qcow2,size=40,bus=virtio,format=qcow2 | |||
WARNING Unable to connect to graphical console: virt-viewer not installed. Please install the 'virt-viewer' package. | |||
WARNING No console to launch for the guest, defaulting to --wait -1 | |||
Starting install... | |||
Allocating 'ubuntu1.qcow2' | 40 GB 00:00:00 | |||
Domain installation still in progress. Waiting for installation to complete. | |||
</source> | |||
== Connect via VNC and complete installation == | |||
Get port number for VNC: | |||
<source lang="bash"> | |||
# virsh dumpxml ubuntu1 | grep vnc | |||
<graphics type='vnc' port='5900' autoport='yes' listen='127.0.0.1'> | |||
</source> | |||
Create a SSH tunnel: | |||
<source lang="bash"> | |||
$ ssh mhan@chara -L 5900:127.0.0.1:5900 | |||
</source> | |||
and then use a VNC client to connect to 127.0.0.1 (aka localhost) with port of 5900. | |||
== Mount guest image == | |||
Make sure to have right packages: | |||
<source lang="bash"> | |||
# yum install libguestfs-tools | |||
</source> | |||
Mount to /mnt: | |||
<source lang="bash"> | |||
# guestmount -a /var/lib/libvirt/images/ubuntu1.qcow2 -m /dev/sda1 /mnt | |||
</source> | |||
Unmount /mnt: | |||
<source lang="bash"> | |||
# guestunmount /mnt | |||
</source> | |||
= Commands = | |||
== Deleting == | |||
Note storage files. Shutdown. And delete. | |||
<source lang="console"> | |||
# virsh dumpxml --domain openbsd | grep 'source file' | |||
# virsh shutdown --domain openbsd | |||
# virsh destroy -- domain openbsd | |||
# virsh undefine -- domain openbsd | |||
# rm -rf /var/lib/libvirt/images/openbsd.qcow2 | |||
</source> | |||
When there are snapshots. | |||
<source lang="console"> | |||
# virsh snapshot-list --domain openbsd | |||
# virsh snapshot-delete --domain openbsd --snapshotname 3sep2016u1 | |||
</source> | |||
Removing with all storage. | |||
<source lang="console"> | |||
# virsh undefine --domain mysql-server | |||
</source> | |||
= Links = | |||
* https://www.cyberciti.biz/faq/how-to-install-kvm-on-centos-7-rhel-7-headless-server/ | |||
* https://www.thegeekstuff.com/2014/10/linux-kvm-create-guest-vm/ | |||
* https://www.techotopia.com/index.php/Installing_a_KVM_Guest_OS_from_the_Command-line_(virt-install) | |||
* https://www.tecmint.com/kvm-management-tools-to-manage-virtual-machines/ | |||
* https://www.server-world.info/en/note?os=Ubuntu_18.04&p=kvm&f=2 | |||
* Image management | |||
** https://support.hpe.com/hpsc/doc/public/display?docId=emr_na-c02814204 | |||
* QEMU (System Emulation) | |||
** [https://www.qemu.org/docs/master/system/quickstart.html System Emulation User Guide] | |||
** [https://www.kraxel.org/blog/2019/09/display-devices-in-qemu/ VGA and other display devices in qemu] |