KVM+qemuCentOS6: Difference between revisions

From DrewWiki
Jump to navigation Jump to search
(Created page with "KVM Centos6 http://www.howtoforge.com/how-to-install-kvm-and-libvirt-on-centos-6.2-with-bridged-networking http://centos.digitalcompass.net/centos/6.2/os/x86_64/ ---Grub -> vm...")
 
m (Drew moved page KVM+qemu CentOS6 to KVM+qemuCentOS6 without leaving a redirect: rename to KVM+qemuCentOS6)
 
(2 intermediate revisions by the same user not shown)
Line 3: Line 3:
http://centos.digitalcompass.net/centos/6.2/os/x86_64/ ---Grub -> vmlinuz initrd=initrd.img console=ttyS0,115200 text
http://centos.digitalcompass.net/centos/6.2/os/x86_64/ ---Grub -> vmlinuz initrd=initrd.img console=ttyS0,115200 text


<pre># yum install qemu-kvm
<syntaxhighlight lang=bash>
# yum install qemu-kvm
# chkconfig libvirtd on
# chkconfig libvirtd on
# groupadd libvirt; usermod -a -G drew
# groupadd libvirt; usermod -a -G drew
-> fix policykit permissions on /dev/kvm  
-> fix policykit permissions on /dev/kvm  
# groupadd tun; chown root:tun /dev/net/tun; usermod -a -G tun drew</pre>
# groupadd tun; chown root:tun /dev/net/tun; usermod -a -G tun drew
</syntaxhighlight>


<pre># cat /etc/sysconfig/network-scripts/ifcfg-eth0;
<syntaxhighlight lang=bash>
# cat /etc/sysconfig/network-scripts/ifcfg-eth0;
DEVICE="eth0"
DEVICE="eth0"
HWADDR="BC:30:5B:DF:E7:59"
HWADDR="BC:30:5B:DF:E7:59"
ONBOOT="yes"
ONBOOT="yes"
BRIDGE=br0</pre>
BRIDGE=br0
</syntaxhighlight>


<pre># cat /etc/sysconfig/network-scripts/ifcfg-br0;
<syntaxhighlight lang=bash>
# cat /etc/sysconfig/network-scripts/ifcfg-br0;
DEVICE="br0"
DEVICE="br0"
TYPE=Bridge
TYPE=Bridge
Line 22: Line 27:
BOOTPROTO=static
BOOTPROTO=static
IPADDR=96.31.87.178
IPADDR=96.31.87.178
NETMASK=255.255.255.192</pre>
NETMASK=255.255.255.192
</syntaxhighlight>


<pre>$ virt-install --name drew01 --ram 512 --vcpus=1 --arch=x86_64 --hvm --os-type=linux --nographics --disk path=/home/aholt/drew.img,size=5,sparse=true --cdrom CentOS-6.2-x86_64-netinstall.iso
<syntaxhighlight lang=bash>
$ virt-install --name drew01 --ram 512 --vcpus=1 --arch=x86_64 --hvm --os-type=linux --nographics --disk path=/home/aholt/drew.img,size=5,sparse=true --cdrom CentOS-6.2-x86_64-netinstall.iso
$ virt-install --name drew01 --ram 512 --vcpus=1 --arch=x86_64 --hvm --os-type=linux --nographics --import --disk path=/home/aholt/drew.img
$ virt-install --name drew01 --ram 512 --vcpus=1 --arch=x86_64 --hvm --os-type=linux --nographics --import --disk path=/home/aholt/drew.img
$ virsh --connect=qemu:///system start drew01
$ virsh --connect=qemu:///system start drew01
$ virsh autostart drew01</pre>
$ virsh autostart drew01
</syntaxhighlight>


<pre>$ virt-install --name connor01 --ram 512 --vcpus=1 --arch=x86_64 --hvm --os-type=linux --disk path=/home/cpenhale/cpenhale.img,size=5,sparse=true --cdrom pfSense-2.0.1-RELEASE-amd64.iso --hvm --vnc --noautoconsole</pre>
<syntaxhighlight lang=bash>
$ virt-install --name connor01 --ram 512 --vcpus=1 --arch=x86_64 --hvm --os-type=linux --disk path=/home/cpenhale/cpenhale.img,size=5,sparse=true --cdrom pfSense-2.0.1-RELEASE-amd64.iso --hvm --vnc --noautoconsole
</syntaxhighlight>


<pre>$ virsh -c qemu+ssh://[email protected]/system sysinfo  
<syntaxhighlight lang=bash>
$ virsh -c qemu+ssh://[email protected]/system sysinfo  
$ virsh -c qemu:///system console drew01
$ virsh -c qemu:///system console drew01
$ virsh -c qemu:///system sysinfo
$ virsh -c qemu:///system sysinfo
Line 39: Line 50:
$ virsh destroy <vm> # hard shutdown, essentially pulling the power cord
$ virsh destroy <vm> # hard shutdown, essentially pulling the power cord
$ virsh suspend <vm>
$ virsh suspend <vm>
$ virsh resume <vm></pre>
$ virsh resume <vm>
</syntaxhighlight>




Instead of allowing virt-manager to create a new drive image, simply direct it to use the image you created in the previous step.
Instead of allowing virt-manager to create a new drive image, simply direct it to use the image you created in the previous step.
3. Create the overlay:
3. Create the overlay:
<pre>$ qemu-img create -f qcow2 -b <image name>.qcow2 <image name>.ovl</pre>
<syntaxhighlight lang=bash>
$ qemu-img create -f qcow2 -b <image name>.qcow2 <image name>.ovl
</syntaxhighlight>

Latest revision as of 17:36, 4 March 2018

KVM Centos6 http://www.howtoforge.com/how-to-install-kvm-and-libvirt-on-centos-6.2-with-bridged-networking http://centos.digitalcompass.net/centos/6.2/os/x86_64/ ---Grub -> vmlinuz initrd=initrd.img console=ttyS0,115200 text

# yum install qemu-kvm
# chkconfig libvirtd on
# groupadd libvirt; usermod -a -G drew
-> fix policykit permissions on /dev/kvm 
# groupadd tun; chown root:tun /dev/net/tun; usermod -a -G tun drew
# cat /etc/sysconfig/network-scripts/ifcfg-eth0;
DEVICE="eth0"
HWADDR="BC:30:5B:DF:E7:59"
ONBOOT="yes"
BRIDGE=br0
# cat /etc/sysconfig/network-scripts/ifcfg-br0;
DEVICE="br0"
TYPE=Bridge
DELAY=0
ONBOOT="yes"
BOOTPROTO=static
IPADDR=96.31.87.178
NETMASK=255.255.255.192
$ virt-install --name drew01 --ram 512 --vcpus=1 --arch=x86_64 --hvm --os-type=linux --nographics --disk path=/home/aholt/drew.img,size=5,sparse=true --cdrom CentOS-6.2-x86_64-netinstall.iso
$ virt-install --name drew01 --ram 512 --vcpus=1 --arch=x86_64 --hvm --os-type=linux --nographics --import --disk path=/home/aholt/drew.img
$ virsh --connect=qemu:///system start drew01
$ virsh autostart drew01
$ virt-install --name connor01 --ram 512 --vcpus=1 --arch=x86_64 --hvm --os-type=linux --disk path=/home/cpenhale/cpenhale.img,size=5,sparse=true --cdrom pfSense-2.0.1-RELEASE-amd64.iso --hvm --vnc --noautoconsole
$ virsh -c qemu+ssh://[email protected]/system sysinfo 
$ virsh -c qemu:///system console drew01
$ virsh -c qemu:///system sysinfo
$ virsh undefine <vm>
$ virsh start <vm>
$ virsh shutdown <vm> # graceful shutdown
$ virsh destroy <vm> # hard shutdown, essentially pulling the power cord
$ virsh suspend <vm>
$ virsh resume <vm>


Instead of allowing virt-manager to create a new drive image, simply direct it to use the image you created in the previous step. 3. Create the overlay:

$ qemu-img create -f qcow2 -b <image name>.qcow2 <image name>.ovl