Difference between revisions of "Virtual Machine (KVM)"

Jump to navigation Jump to search
1,627 bytes added ,  20:47, 26 July 2020
Added Add Disk
(→‎Move Virtual Machine: Updated CPU type / mode info)
(Added Add Disk)
Line 106: Line 106:
# Start the VM
# Start the VM
#* EG <code> virsh start <VMName> </code>
#* EG <code> virsh start <VMName> </code>
== Add Disk ==
# Create new disk image file
#* EG <code> qemu-img create -f qcow2 /var/lib/libvirt/images/elk-disk1.img 20G </code>
# Attach disk image to virtual machine
#* 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>
#** 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>
# 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>  chgrp libvirt-qemu /var/lib/libvirt/images/elk-disk1.img </code>
# Attach disk
#* EG <code> virsh attach-disk --domain elk /var/lib/libvirt/images/elk-disk1.img --target vdb --persistent --config --live </code>
# In the VM, format the disk using defaults..
#* EG <code> fdisk /dev/vdb </code>
#** EG <code>Command: n </code>
#** EG <code>Partition type: p, </code>
#** EG <code>Partition number: <default>, </code>
#** EG <code>First sector: <default> </code>
#** EG <code>Last sector: <default> </code>
#** EG <code>Command: w </code>
# Format new partition
#* EG <code> mkfs.ext4 /dev/vdb1 </code>
# Create mount directory
#* EG <code> mkdir /vdb1/ </code>
# Mount the the disk
#* EG <code> mount /dev/vdb1 /vdb1/ </code>
# Add an appropriate entry to fstab so the disk gets mounted on next boot
#* EG <code> /dev/vdb1    /vdb1    ext4    defaults    0 0 </code>


== Other Config ==
== Other Config ==
Line 114: Line 144:
To disable issue
To disable issue
  virsh autostart vm-name --disable
  virsh autostart vm-name --disable
 
 
[[Category:KVM]]
[[Category:KVM]]

Navigation menu