2.7.14

quickstart w/ libvirt

Simple recipe for spinning up VMs on Libvirt from zero

su -c "yum install @virtualization"

This sets up all the virtualization entries.  I never remember to use it, but more about why you should use it here.


Create disk for a VM and attach it

qemu-img create -f raw /VirtualMachines/fedora-disk-2.img 10G


Set up a FEDORA VM from source:
 
IMGNAME=vm1-fedora
# create image file
virt-install \
--name $IMGNAME \
--ram 5000 \
--cpu host \
--vcpus 2 \
--os-type=linux \
--os-variant=rhel6 \
--location=http://mirror.pnl.gov/fedora/linux/releases/20/Fedora/x86_64/os/ \
--disk path=/var/lib/libvirt/images/$IMGNAME.$EXT,size=10,format=qcow2
Then attach the above created disk:

virsh attach-disk vm1-fedora /VirtualMachines/idh2.img --target vda --driver qemu

And in case you wanted CentOS, just for diversity, we'll add the same snippet here.  Notice not much change. 

Set up a CentOS VM from source.
IMGNAME=vm2-centos
# create image file
virt-install \
--name $IMGNAME \
--ram 5000 \
--cpu host \
--vcpus 2 \
--os-type=linux \
--os-variant=rhel6 \
--location=http://mirror.catn.com/pub/centos/6/os/x86_64 \
--disk path=/var/lib/libvirt/images/$IMGNAME.$EXT,size=10,format=qcow2


No comments:

Post a Comment