Difference between revisions of "Virtual Machine (KVM)"

Jump to navigation Jump to search
m
→‎Create Workstation (GUI): Added note on cancelling he command
(Added Add Disk)
m (→‎Create Workstation (GUI): Added note on cancelling he command)
(2 intermediate revisions by the same user not shown)
Line 83: Line 83:
--cdrom=/mnt/md0/kvm/iso/ubuntu-16.04.3-desktop-amd64.iso \
--cdrom=/mnt/md0/kvm/iso/ubuntu-16.04.3-desktop-amd64.iso \
--network=bridge=br0,model=virtio \
--network=bridge=br0,model=virtio \
--graphics vnc \
--graphics vnc,listen=0.0.0.0 \
--disk path=/mnt/md0/kvm/vm/ubuntu-desktop.img,size=40,bus=virtio
--disk path=/mnt/md0/kvm/vm/ubuntu-desktop.img,size=40,bus=virtio
</pre>
</pre>


Once the command has got as far as <code>Waiting for installation to complete.</code> you need to connect to the VNC console session, to find the port number to connect on query the config from anothet SSH session connected to the host (typically VNC uses ports starting from 5900 upwards).
Once the command has got as far as <code>Waiting for installation to complete.</code> you need to connect to the VNC console session, to find the port number to connect on query the config from ''another'' SSH session connected to the host (typically VNC uses ports starting from 5900 upwards).  Cancelling the command causes the VM/domain to power off, which you won't want to happen until you've completed setup of the VM.
   virsh dumpxml ubuntu-desktop | grep vnc
   virsh dumpxml ubuntu-desktop | grep vnc


Line 109: Line 109:
== Add Disk ==
== Add Disk ==
# Create new disk image file
# Create new disk image file
#* EG <code> qemu-img create -f qcow2 /var/lib/libvirt/images/elk-disk1.img 20G </code>
#* EG <code> qemu-img create -f qcow2 /var/lib/libvirt/images/vm-name-disk1.img 20G </code>
# Attach disk image to virtual machine
# Attach disk image to virtual machine
#* Use <code>df</code> in the VM to determine next disk label, eg <code>vdb</code>
#* Use <code>df</code> in the VM to determine next disk label, eg <code>vdb</code>
#* EG <code> qemu-img create -f qcow2 /var/lib/libvirt/images/elk-disk1.img 20G -o preallocation=full </code>
#* EG <code> qemu-img create -f qcow2 /var/lib/libvirt/images/vm-name-disk1.img 20G -o preallocation=full </code>
#** To create a thin provisioned file use the following (however you may find the disk the OS sees is small (~200K), if so, use the command above)
#** To create a thin provisioned file use the following (however you may find the disk the OS sees is small (~200K), if so, use the command above)
#** EG <code> virsh attach-disk elk /var/lib/libvirt/images/elk-disk1.img vdb --cache none </code>
#** EG <code> virsh attach-disk vm-name /var/lib/libvirt/images/vm-name-disk1.img vdb --cache none </code>
# Update file owner and group to match other disk images
# Update file owner and group to match other disk images
#* EG <code>  chown libvirt-qemu /var/lib/libvirt/images/elk-disk1.img </code>
#* EG <code>  chown libvirt-qemu /var/lib/libvirt/images/vm-name-disk1.img </code>
#* EG <code>  chgrp libvirt-qemu /var/lib/libvirt/images/elk-disk1.img </code>
#* EG <code>  chgrp libvirt-qemu /var/lib/libvirt/images/vm-name-disk1.img </code>
# Attach disk
# Attach disk
#* EG <code> virsh attach-disk --domain elk /var/lib/libvirt/images/elk-disk1.img --target vdb --persistent --config --live </code>
#* EG <code> virsh attach-disk --domain vm-name /var/lib/libvirt/images/vm-name-disk1.img --target vdb --persistent --config --live </code>
# In the VM, format the disk using defaults..
# In the VM, format the disk using defaults..
#* EG <code> fdisk /dev/vdb </code>
#* EG <code> fdisk /dev/vdb </code>

Navigation menu