KVM.v7

From Access Information
Jump to: navigation, search


Installing New Server Mrepo smartd RAID Hardening YUM Crontabs LogWatch systemctl firewalld CentOS 7
Packages
Apache Bind Cacti DHCP mariadb Samba Sarg Sendmail Smokeping Rsync Work Apps
Problems VPN VPN Win Extras Bash MailScanner Horde Google CE Wake Up KVM
Other Computer Lab ISO2USB aiContact Google CE Android USB Live SRS XML

http://www.server-world.info/en/note?os=CentOS_7&p=kvm

KVM Prep

yum upgrade

Can your server be a VM host?

egrep '(vmx|svm)' --color=always /proc/cpuinfo

Get an idea of the CPUs

dmesg |grep cpu

Installing a KMV Server

resources : http://wiki.centos.org/HowTos/KVM This page got me going at first: http://www.cyberciti.biz/faq/rhel-linux-kvm-virtualization-bridged-networking-with-libvirt/ Most of what follows is a plagiarisation from them. HowTo:KMV:Maintaining v 7 does not have kmod-kvm python-virtinst

yum install kvm  virt-manager libvirt libvirt-python virt-manager libvirt qemu-system-x86 openssh-askpass qemu-kvm virt-install bridge-utils
yum -y install @virt* dejavu-lgc-* xorg-x11-xauth tigervnc libguestfs-tools policycoreutils-python
yum grouplist
yum -y groupinstall "Desktop" "Desktop Platform" "GNOME Desktop" "Fonts"

Starting Services

systemctl start libvirtd 
systemctl enable libvirtd

Setting up Network cards

The configuration I am looking for

My Local   Switch    Virt Server       	
   LAN	    Local                    The Internet
                       eth0		eth1
192.168.x.x   <==>  192.168.x.254    123.123.123.123
255.255.255.0       255.255.255.0    255.255.255.0
                     against eth0
                     xp VM 1
                     192.168.x.x			
                     xp VM 2
                     192.168.x.x			
                     xp VM 3
                     192.168.x.x			
                     CentOS VM
                     192.168.x.253
  1. We use NetworkManager (mine is on by default)
  2. Make dure you have a copy of the ifcfg-eno### file

add bridge "br0"

(I write these to a file and run the file)

NIC=enp4s0
BR=br0
IP=192.168.7.77/24
GW=192.168.7.254
nmcli c add type bridge autoconnect yes con-name $BR ifname $BR
#should get a comment like this:
#Connection 'br0' (0f4b7bc8-8c7a-461a-bff1-d516b941a6ec) successfully added.
#set IP for br0, I use the same IP address as from the current connection of ifcfg-eno###
nmcli c modify $BR ipv4.addresses $IP ipv4.method manual 
#set Gateway for br0
nmcli c modify $BR ipv4.gateway $GW
#set DNS for "br0"
nmcli c modify $BR ipv4.dns $GW
#remove the current setting (This has to be done at the server not via vnc.)
nmcli c delete $NIC
#The ifcfg-eno### file has been deleted
#add an interface again as a member of br0
nmcli c add type bridge-slave autoconnect yes con-name $NIC ifname $NIC master $BR
#The ifcfg-eno### file has been recreated
systemctl stop NetworkManager
systemctl start NetworkManager 
reboot

etc/sysconfig/network

emacs /etc/sysconfig/networks
NETWORKING=yes
FORWARD_IPV4=true
HOSTNAME=mail.me.co.nz
DOMAINNAME=me.co.nz
GATEWAY=br1

/etc/sysconfig/network-scripts/ifcfg-eth0

emacs /etc/sysconfig/network-scripts/ifcfg-enp3s0
TYPE=Ethernet
NAME=enp3s0
UUID=922cb52f-a731-4ad9-853d-d7aea9ddbe6e
DEVICE=enp3s0
ONBOOT=yes
BRIDGE=br0

/etc/sysconfig/network-scripts/ifcfg-br0

emacs /etc/sysconfig/network-scripts/ifcfg-br0
DEVICE=br0
STP=yes
TYPE=Bridge
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=br0
UUID=a8e0e8f4-86a0-4045-ac36-27b8ff7ef270
ONBOOT=yes
BRIDGING_OPTS=priority=32768
IPADDR=192.168.20.7
PREFIX=24
GATEWAY=192.168.20.254
DNS1=192.168.20.254
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes

NOTE Bridge must be spelt with a capital B

Check with

brctl show

bridge name	bridge id		STP enabled	interfaces
br0		8000.6cf0495e2918	yes		enp3s0
virbr0		8000.5254001c0211	yes		virbr0-nic

To check all is well:

ip addr show br0
ip route
ping google.com

This got me a nice ways along, but when I started up xp VM, it is still using the NAT settings. This is where this page set me to the next step.

http://wiki.libvirt.org/page/Networking

The extra things I did from this pages:

# cat >> /etc/sysctl.conf <<EOF
net.bridge.bridge-nf-call-ip6tables = 0
net.bridge.bridge-nf-call-iptables = 0
net.bridge.bridge-nf-call-arptables = 0
EOF
# sysctl -p /etc/sysctl.conf

Here are some iptables rules that I did not use.

# echo "-I FORWARD -m physdev --physdev-is-bridged -j ACCEPT" > /etc/sysconfig/iptables-forward-bridged 
# lokkit --custom-rules=ipv4:filter:/etc/sysconfig/iptables-forward-bridged
# service libvirtd reload

Disks

ntfs

Do these commands inside the VM.

wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
rpm -ihv epel-release-7-5.noarch.rpm
yum install ntfs-3g ntfsprogs

You can not mount and format ntfs partitions.

iSCSI

yum install iscsi-initiator-utils

ISSUES

=Get F8

Get Out of Full Screen

When in full screen mode, hit Ctrl-Alt to 'unhinge' the mouse and move the mouse to the top-middle of the screen. A little applet drops down to allow you to leave full screen and send key-combinations.

Create VMs

Setup the directories, in my case

/home/kvm/iso
/home/kvm/images

Simple command to create the container.

qemu-img create /home/kvm/images/snakedoctor.img 40G

Create a KVM from a Clonezilla image

Playing around with HD images

hattip http://blogging.dragon.org.uk/index.php/mini-howtos/how-to-make-a-blank

New HD

qemu-img create -f raw new_drive.img 8G

Resize HD

cat small.img new_drive.img > bigger.img

(Untested)

Server Backups

https://en.wikibooks.org/wiki/QEMU/Images

qemu-img create -f qcow2 winsrvBK.img 100G

Creates an image which is only

-rw-r--r--  1 root   root  194K Aug 13 09:57 winsrvBK.img
mkdir /mnt/winsrvBK

Hmmm http://dgc.uchicago.edu/20130530/mounting-a-kvm-disk-image-without-kvm/

http://blogs.operationaldynamics.com/andrew/software/research/mounting-a-kvm-image-on-a-host-system

https://www.suse.com/documentation/opensuse121/book_kvm/data/cha_qemu_guest_inst_qemu-img.html

  • Did you find this page useful?
  • Do you have an issue that you have not yet fixed?

We can do this for you.

I am available for technical support. Please follow this link. Tech Support Request.
+64-6-880-0000 : ++1-808-498-7146 : help@ai.net.nz
Getting us to help you