Tech
- Details
- Category: Xen Howtos
1. First we need to download the YUM repository file for the updated Xen.
wget http://www.gitco.de/linux/x86_64/centos/5/CentOS-GITCO.repo -O /etc/yum.repos.d/gitco.repo
2. Uninstall old Virtualization files
yum groupremove Virtualization
3. Install the relevant packages using YUM
yum groupinstall -y Virtualization
Yum will probably want to upgrade some other files along with the ones we've chosen.
Warning! If you get an error message from grubby this is bad!
Installing: kernel-xen ####################### [ 9/13]
grubby fatal error: unable to find a suitable template
This means that your grub.conf file couldn't be written to for whaterver reason so you won't be able to successfully reboot. If you get this message you need to edit your /boot/grub/grub.conf file and make the kernel lines match the kernel you installed.
Get your installed kernel version:
[ root@vs / ] rpm -q kernel-xen
kernel-xen-2.6.18-128.4.1.el5
Now edit your /boot/grub/grub.conf to match this
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/vgsys/lvroot
# initrd /initrd-version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.18-128.4.1.el5xen)
root (hd0,0)
kernel /xen.gz-3.4.0
module /vmlinuz-2.6.18-128.4.1.el5xen ro root=/dev/vgsys/lvroot rhgb quiet
module /initrd-2.6.18-128.4.1.el5xen.img
4. Reboot - no really I mean it.
5. Try it out by using the xm dmesg command
\ \/ /___ _ __ |___ / |___ / / _ \
\ // _ \ '_ \ |_ \ |_ \| | | |
/ \ __/ | | | ___) | ___) | |_| |
/_/\_\___|_| |_| |____(_)____(_)___/
(XEN) Xen version 3.3.0 (
(XEN) Latest ChangeSet: unavailable
(XEN) Command line:
(XEN) Video information:
(XEN) VGA is text mode 80x25, font 8x16
(XEN) VBE/DDC methods: V2; EDID transfer time: 2 seconds
(XEN) Disc information:
(XEN) Found 1 MBR signatures
(XEN) Found 1 EDD information structures
(XEN) Xen-e820 RAM map:
That's about all. If you have any questions drop a comment here.
- Details
- Category: KVM/QEMU Howtos
So here's a quick howto on getting KVM to work on CentOS5.x. I'll add more tutorials when I start using KVM more. For now I spend all my time on VirtualBox at work and Xen everywhere else. KVM is maturing fast but still not where Xen is for the most part. It also needs VT support in the CPUs which means not everyone can use it. My 4 core, 8 vcpu Xeon machine in the garage won't run KVM so I'm not spending a lot of time with it right now. One of the reasons I don't use KVM in a production environment is it moves too fast and the distros are just too far behind as you'll see in the howto
1. First you need to see if you're CPU has the needed hardware VT support
egrep 'vmx|svm' /proc/cpuinfo
If you have an Intel CPU with VT support you should get back vmx and svm if it's AMD with VT support. If you get nothing you need to use Xen or VirtualBox as both support Virtualization without the hardware VT support.
2. Install KVM and QEMU
yum install kvm kmod-kvm qemu
The current version of KVM is 36 which is ancient (August 2007) but stable as far as KVM goes. Even with this version I've gotten lockups and strange behavior. The most recent version of KVM is 74 so you can imagine what's been added since version 36. If you want to check it out yourself here's the changelog.
- Details
- Category: Xen Howtos
Scenario: In the Dom0 (Host) you have an LVM Logical Volume that you export to the DomU (Guest) and it appears as a hard drive partition which you want to make larger.
Example- Dom0: /dev/VolGroup00/LogVol00 -> DomU: /dev/xvda1
Resizing an LVM Logical Volume used as a DomU partition
When you use an LVM Logical Volume as a DomU partition it will show up in the DomU as /dev/xvda1 as apposed to /dev/xvda. The line in the DomU config file will look something like this.
disk = ['phy:vgsys/lvvirt,xvda1,w']
Get the Logical Volume name and path
So you gave your Xen virtual machine a 10GB Logical Volume and not it's not enough eh? This is easy to fix.
We start by using the lvdisplay command to get the path to the Logical Volume
[ root@vs /srv/xen ] lvdisplay
--- Logical volume ---
LV Name /dev/vgsys/lvvirt
VG Name vgsys
LV UUID XMWzWW-oZih-A5uH-91Sa-7l1y-8cqf-18KcNB
LV Write Access read/write
LV Status available
# open 1
LV Size 60.00 GB
Current LE 1920
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:2
- Details
- Category: Xen Howtos
Scenario: In the Dom0 (Host) you have an LVM Logical Volume that you export to the DomU (Guest) and it appears as an entire hard drive which you want to make larger.
Example- Dom0: /dev/VolGroup00/LogVol00 -> DomU: /dev/xvda
Resizing an LVM Logical Volume used as a DomU drive
A Logical Volume used as a DomU drive will appear in the DomU as /dev/xvda. A Logical Volume used as a DomU partition will appear in the DomU as /dev/xvda1. Please note the difference.
The disk line in the Xen Domain config file stored in /etc/xen on the Dom0 will look something like this.
disk = ['phy:vgsys/lvvirt,xvda,w']
Get the Logical Volume name and path in Dom0
On the Dom0 we need to expand the Logical Volume. We start by using the lvdisplay command to get the path to the Logical Volume
[ root@vs /srv/xen ] lvdisplay
--- Logical volume ---
LV Name /dev/vgsys/lvvirt
VG Name vgsys
LV UUID XMWzWW-oZih-A5uH-91Sa-7l1y-8cqf-18KcNB
LV Write Access read/write
LV Status available
# open 1
LV Size 60.00 GB
Current LE 1920
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:2
- Details
- Category: Xen Howtos
How to move from a tap:aio file to an LVM Logical Volume.
In Xen we can provide virtualized hard drives several different ways. It's not uncommon to create a large empty file using dd and then specify it as the hard drive like this.
- Details
- Category: Xen Howtos
dd if=/dev/zero of=/vm/Ubuntu-Hardy-base.img bs=1024k count=4000
dd if=/dev/zero of=/vm/Ubuntu-Hardy-swap.img bs=1024k count=400
/sbin/mkfs.ext3 /vm/Ubuntu-Hardy-base.img
/sbin/mkfs.ext3 /vm/Ubuntu-Hardy-swap.img
/sbin/mkswap /vm/Ubuntu-Hardy-swap.img
chmod 640 /vm/Ubuntu*
mkdir /mnt/xenfs
mount -o loop /vm/Ubuntu-Hardy-base.img /mnt/xenfs
wget ftp://ftp.muug.mb.ca/mirror/
rpm -Uvh debootstrap*
export PATH=$PATH"/usr/sbin":/sbin (so chroot will not fail)
/usr/sbin/debootstrap --arch i386 --include=linux-image-2.6.24-
WAIT..................
chroot /mnt/xen or just make xure all edits go to /mnt/xenfs/ from this point on:
mv /lib/tls /lib/tls.disabled
create /edit /etc/fstab
proc /proc proc defaults 0 0
/dev/hda1 / ext3 defaults,errors=remount-ro 0 1
/dev/hda2 none swap sw 0 0
# mkdir -p /boot/grub
# update-grub
edit /boot/grub/menu.lst
title Ubuntu 8.04, kernel 2.6.24-16-xen
root (hd0,0)
kernel /boot/vmlinuz-2.6.24-16-
initrd /boot/initrd.img-2.6.24-16-xen
title Ubuntu 8.04, kernel 2.6.24-16-xen (recovery mode)
root (hd0,0)
kernel /boot/vmlinuz-2.6.24-16-xen root=/dev/xvda1 ro single console=xvc0
initrd /boot/initrd.img-2.6.24-16-xen
# cd /etc/event.d
# cp tty1 xvc0
# sed -i -e "s/tty1/xvc0/g" xvc0
Add xvc0 to /etc/securetty to allow root to login
# update-rc.d -f hwclockfirst remove
# update-rc.d -f hwclock remove
# rm /etc/udev/rules.d/85-hwclock.
Now download the updated linux-image and headers from http://www.il.is.s.u-tokyo.ac.
and install them, otherwise no network when you boot the domU
Create our guest config file :
bootloader = '/usr/bin/pygrub'
memory = 512
name = "Ubuntu-Hardy-Base"
disk = ['file:/vm/Ubuntu-Hardy-base.
vif = [ '' ]
Boot the domU.
Hope this helps
Chris
- Details
- Category: Xen Howtos
wget http://voxel.dl.sourceforge.net/sourceforge/asteriskathome/trixbox-2.6.1-i386.iso
First we'll need to make a disk image for our VOIP server.
dd if=/dev/zero of=/srv/xen/voipserver.img bs=1024 count=5000000
- Details
- Category: Xen Howtos
NOTE! I have not tried this rpm kernel! Until I get to it take it as a howto with no possible gaurantee. I will get to testing it extensively the first week of September as I'm on vacation.
I just did a howto on compiling Xen 3.2.1 for CentOS5 but then I found this kernel and Xen rpms that you can just download and install.
For x86_64
- wget http://www.halsign.com/files/TurboGate-HTools-1.2-rhel5-x86_64.tar
- tar -xvpf TurboGate-HTools-1.2-rhel5-x86_64.tar
- cd TurboGate-HTools-1.2-rhel5-x86_64/
- rpm -ivh *.rpm
- reboot and select new kernel at grub prompt
For i386
- wget http://www.halsign.com/files/TurboGate-HTools-1.2-rhel5-i386.tar
- tar -xvpf TurboGate-HTools-1.2-rhel5-i386.tar
- cd TurboGate-HTools-1.2-rhel5-i386/
- rpm -ivh *.rpm
- reboot and select new kernel at grub prompt
I haven't as of yet used this new kernel and Xen but it might make it a lot easier than compiling Xen 3.2.1 from scratch.
- Details
- Category: Xen Howtos
I thought about updating this to include Xen 3.3 but in all reality the gitco repositories work great for i386 and x86_64 so I don't see a reason to compile xen. However, I'm leaving this up in case someone wants to use it as a loose guide to compile xen 3.3.1.
CentOS 5.2/RHEL 5.2 comes with a very highly modified Xen 3.03 which if I'm correct is in fact Xen 3.1 backported. If you want to use the latest Xen 3.2.1 you need to update the hypervisor. This tutorial is for x86_64 because that's what I'm running on grantmcwilliams.com. If you want the 32 bit version modify the appropriate paths and file names.
- rpm -i http://bits.xensource.com/oss-
xen/release/3.2.0/centos-5.1/ xen-3.2.0-0xs.centos5.src.rpm 2> /dev/null - cd /usr/src/redhat/SOURCES ; wget http://bits.xensource.com/oss-
xen/release/3.2.1/xen-3.2.1. tar.gz - vi ../SPECS/xen.spec
- - Change "Version: 3.2.0" to "Version 3.2.1"
- - Change "Source0: xen-3.2.0.tar.gz" to "Source0: xen-3.2.1.tar.gz"
- - Uncomment "# /usr/lib/xen/boot/hvmloader"
- yum -y install transfig texi2html tetex-latex gtk2-devel libaio-devel gnutls-devel
- cd /usr/src/redhat/SPECS ; rpmbuild -ba ./xen.spec
- Grab some coffee...
... after the rpms are built do this
- vi /etc/yum.conf and temporarily set "gpgcheck=0" to "gpgcheck=1" since RPMs aren't signed.
- cd /usr/src/redhat/RPMS/x86_64 ; yum -y install xen-3.2.1-0xs.x86_64.rpm xen-libs-3.2.1-0xs.x86_64.rpm xen-devel-3.2.1-0xs.x86_64.rpm
- vi /etc/yum.conf and set gpgcheck back to "gpgcheck=1".
- edit /boot/grub/grub.conf and switch all references of /boot/xen-3.1.. to /boot/xen-3.2..
Now you can reboot and enjoy your new Xen 3.2.1.
- Details
- Category: VirtualBox Howtos
If you're moving from a real server installation to a VirtualBox virtualized configuration you may want to take your real physical disk and just turn it into a virtual disk. There are advantages to creating a new disk and rsyncing your OS into it but this tutorial will show you how to make an exact copy of it. Note the exact copy will be the same size as the real physical disk so make sure you have enough drive space. This is most useful for Operating System images with shared storage for data. I wouldn't advise anyone to make a 1TB copy of their new drive and turn it into a VDI file!
To get the image from the disk use the dd command.
- dd if=/dev/hda of=./hda.img
- VBoxManage convertdd hda.img hda.vdi
grant@workstation:~$ dd if=/dev/hda of=./hda.img
grant@workstation:~$ VBoxManage convertdd hda.img hda.vdi
VirtualBox Command Line Management Interface Version 1.6.0
(C) 2005-2008 Sun Microsystems, Inc.
All rights reserved.
Converting VDI: from DD image file="hda.img" to file="hda.vdi"...
Creating fixed image with size 1024966656 bytes (978MB)...
This will make an exact copy of /dev/hda to the raw image file hda.img. Then VBoxManage will convert the raw disk hda.img to hda.vdi for use with VirtualBox.