Skip to content

This is some simple scripts used to deploy vm's on KVM

License

Notifications You must be signed in to change notification settings

ltdenard/centos7kvm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 

Repository files navigation

centos7kvm

This is some simple scripts used to deploy vm's on KVM

For host setup, refer to the following:

First, install the necessary packages.
yum -y install kvm virt-manager libvirt virt-install qemu-kvm xauth dejavu-lgc-sans-fonts bridge-utils policycoreutils-python

Enable the kernel to do IP forwarding
echo "net.ipv4.ip_forward = 1"|sudo tee /etc/sysctl.d/99-ipforward.conf

Apply the new kernel settings
sysctl -p /etc/sysctl.d/99-ipforward.conf

Start libvirt and set it to start on boot
systemctl start libvirtd
systemctl enable libvirtd

Create a network bridge for the VM's to share
vi /etc/sysconfig/network-scripts/ifcfg-br0

DEVICE="br0"
ONBOOT="yes"
TYPE="Bridge"
BOOTPROTO="dhcp"
STP="on"
DELAY="0.0"

Tell your network interface to be a slave to the bridge
vi /etc/sysconfig/network-scripts/ifcfg-enp6s0f0

DEVICE="enp3s0"
ONBOOT="yes"
BRIDGE="br0"

Make sure to set your hostname
vi /etc/hostname

hypervisor01.example.com

Start networking to make sure the changes take effect
systemctl restart network

Make the directory to be your VM image folder
mkdir /data

Set the selinux policy on that new folder
semanage fcontext -a -t virt_image_t "/data(/.*)?"
restorecon -R /data

Tell libvirt you want to use the above folder for VMs
virsh pool-destroy default
virsh pool-undefine default
virsh pool-define-as --name default --type dir --target /data
virsh pool-autostart default
virsh pool-build default
virsh pool-start default

About

This is some simple scripts used to deploy vm's on KVM

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages