Installing FreePBX on XenServer

I know a gentlemen by the name iam has done this but I would like to get some basic instructions on how to install FreePBX into a VM under XenServer 5.6 FP1.

There are some comments on installing this into a PV guest and I would like to understand what and how to create a PV guest.

Thanks.

This method will work on just about any Linux machine with its own special kernels but here it is for freePBX. I have borrowed from the above article to make this post and give full credit to it and its author for being able to do this. I have copied and pasted the article below in case the original link disappears.

  1. Install freePBX from the distro iso using the “Other install media” template in XenCenter. Don’t waste your time using the tarball or trying to install freePBX on top of an already paravirtualized Centos machine. Its a waste of time.

Now on to the fun part.

  1. Enable SSH so you can get to the console from something else besides the console in XenCenter.

a. In XenCenter go to the freePBX console and login as root (you set this up during install of freePBX).

b. edit /etc/ssh/sshd_config file with vi, emacs or whatever you like. REMOVE the # just before PermitRootLogin yes. This will uncomment it and allow you to login as root via a console like putty (use putty to access the console since its free, just look for it on Google). Save the file. You can always come back here later and insert the # back to prevent root access after you are done for security.

c. Login as root using putty.

  1. Install the Linux Xen kernel.

a. At the command line type the following command at the prompt: yum install kernel-xen kernel-xen-devel

This will install both the xen kernel and optionally the xen devel rpm in case there are future changes.

(information) the xen aware kernel is installed and entries are created in grub. YOU ARE NOT DONE HERE! Make sure you do the rest or you will get an ELF error on boot meaning that the xen kernel is trying to boot in dom0 instead of domU!

  1. Build a new initrd without the SCSI drivers and with the xen PV drivers (REALLY important that you do this!)

a. cd /boot

b. mkinitrd --omit-scsi-modules --with=xennet --with=xenblk --preload=xenblk initrd-$(uname -r)xen-no-scsi.img $(uname -r)xen

(information) This builds a new initrd for booting with pygrub that does not include SCSI drivers which are known to cause issues with pygrub and Xen virtual disk devices.

  1. Modify the grub boot loader menu (the default entries are not pygrub compatible)

Open /boot/grub/menu.lst in the editor of your choice

a. Remove the kernel entry with ‘gz’ in the name (MISS THIS AND YOU GET AND ELF ERROR IN XENCENTER!)

b. Rename the first “module” entry to “kernel”

c. Rename the second “module” entry to “initrd”

(information). SuSE and Debian require that entries that point to root device locations described by a direct path such as: “/dev/hd*” or “/dev/sd*” be modified to point to /dev/xvd*

d. Correct the .img pointer to the new initrd.img created in step 4

e. (optional) Modify the title of this entry

f. Edit the line “default=” to point to the modified xen kernel entry

g. The entries begin counting at 0 – the first entry in the list is 0, the second entry is 1 and so on

h. In our example the desired default entry “0”

i. (optional) Comment the “hiddenmenu” line if it is there (this will allow a kernel choice during boot if needed for recovery)

j. Save your changes

  1. Shut down the guest but do not reboot. DO NOT REBOOT! Just shut it down. Some changes have to be made in XenServer first.

a. At the command prompt type: shutdown -h now

Edit the VM record of the freePBX VM to convert it to PV boot mode

Substitute the actual name of your vm in the example where it shows the word “freePBX” if the name of the vm is different.

To get the name look at the name in the properties of the vm. I suggest renaming it to something simple like freePBX to make the next steps easier. You can always change it late to whatever you like.

Next we need to tell XenServer that this vm is now a para-virtualized system.

  1. From the console of the XenServer host (NOT THE VM) execute the following xe commands: (REMEMBER THAT TAB COMPLETE IS YOUR FRIEND HERE!) Type the following command in the XenServer console.

a. xe vm-list name-label=freePBX params=uuid (retrieve the UUID of the vm)

b. xe vm-param-set uuid= HVM-boot-policy=”” (clear the HVM boot mode)

c. xe vm-param-set uuid= PV-bootloader=pygrub (set pygrub as the boot loader)

d. xe vm-param-set uuid= PV-args=“console=xvc0” (THIS IS WHAT IS NEEDED IN CURRENT VERSIONS OF XENSERVER)

i. Other possible options are: “console=hvc0 xencons=hvc” or “console=tty0” or “console=hvc0”

  1. xe vm-disk-list uuid= (this is to discover the UUID of the interface of the virtual disk)

  2. xe vbd-param-set uuid= bootable=true (this sets the disk device as bootable)

Now it should boot up so go ahead and start the virtual machine. It may take a minute the first time so be patient.

NEXT we need to install the XenTools!

You’ll have to install the xentools but its VERY important NOT to run the install script. Just install the xenstore and xentools rpms directly. If you use the install script then it will replace the xen kernel we installed earlier with a generic kernel and freePBX won’t work correctly.

  1. Select xs-tool.iso from the CDROM drop down menu of the freePBX vm in XenCenter.

  2. Type this command to mount the cdrom temporarily: mount /dev/xvdd /mnt

  3. Then type: cd /mnt/Linux

  4. Type: ls to see all the files

  5. Use the rpm command to INSTALL JUST the 2 guest utilities you need

Example:

rpm -ivh xe-guest-utilities-xenstore-6.0.0-743.i386.rpm
rpm -ivh xe-guest-utilities_6.0.0-743_i386.rpm

You have to install the xenstore first and of course use the version you see on your screen, not just type what you see here.

Afterwards you can reboot the machine and you will have a completely paravirtualized system.

Quick NOTE of useful information about configuring the ethernet interface-----You may loose the ethernet configuration information.

Use the command: system-config-network to get a handy gui that will help you reconfigure everything. If you are missing an interface for eth0, just create a new one.

Hope this helps!

P.S. If anyone has a real need for a XenServer para-virtualizaed vm and can’t get it done with the above instructions then contact me and we’ll get you one.

References:

Here is a copy of the article that was used from the link above, saved in case the link above stops working.

PV enabling an HVM from VMware on XenServer (CentOS RedHat)
This example works for RedHat and CentOS, the instructions are slightly different for SLES and Debian.
As a condition for paravirtualization to work, a kernel that supports the Xen hypervisor needs to be installed and booted in the virtual machine.
Installing the XenServer Supported Kernel:

  1. After importing the vm as HVM, boot the virtual machine and open the console.

  2. (optional) update the modules within the vm to the latest revision
    a. If the kernel-xen package is installed from an online repository – best practice is to fully update the distribution to avoid problems between package build revisions.

  3. Install the Linux Xen kernel.
    a. yum install kernel-xen
    i. the xen aware kernel is installed and entries are created in grub

  4. Build a new initrd without the SCSI drivers and with the xen PV drivers
    a. cd /boot
    b. mkinitrd --omit-scsi-modules --with=xennet --with=xenblk --preload=xenblk initrd-$(uname -r)xen-no-scsi.img $(uname -r)xen
    i. This builds a new initrd for booting with pygrub that does not include SCSI drivers which are known to cause issues with pygrub and Xen virtual disk devices.

  5. Modify the grub boot loader menu (the default entries are not pygrub compatible)
    Open /boot/grub/menu.lst in the editor of your choice

a. Remove the kernel entry with ‘gz’ in the name
b. Rename the first “module” entry to “kernel”
c. Rename the second “module” entry to “initrd”
i. SuSE and Debian require that entries that point to root device locations described by a direct path such as: “/dev/hd*” or “/dev/sd*” be modified to point to /dev/xvd*
d. Correct the .img pointer to the new initrd.img created in step 4
e. (optional) Modify the title of this entry
f. Edit the line “default=” to point to the modified xen kernel entry
i. The entries begin counting at 0 – the first entry in the list is 0, the second entry is 1 and so on
ii. In our example the desired default entry “0”
g. (optional) Comment the “hiddenmenu” line if it is there (this will allow a kernel choice during boot if needed for recovery)
h. Save your changes

  1. Shut down the guest but do not reboot.
    a. Shutdown now -h
    Edit the VM record of the CentOS VM to convert it to PV boot mode
    In this example the VM is named “centos”
  2. From the console of the XenServer host execute the following xe commands:
    a. xe vm-list name-label=centos params=uuid (retrieve the UUID of the vm)
    b. xe vm-param-set uuid= HVM-boot-policy=”” (clear the HVM boot mode)
    c. xe vm-param-set uuid= PV-bootloader=pygrub (set pygrub as the boot loader)
    d. xe vm-param-set uuid= PV-args=“console=tty0 xencons=tty” (set the display arguments)
    i. Other possible options are: “console=hvc0 xencons=hvc” or “console=tty0” or “console=hvc0”
  3. xe vm-disk-list uuid= (this is to discover the UUID of the interface of the virtual disk)
  4. xe vbd-param-set uuid= bootable=true (this sets the disk device as bootable)

The vm should now boot paravirtualized using a Xen aware kernel.
When booting the virtual machine, it should start up in text-mode with the high-speed PV kernel. If the virtual machine fails to boot, the most likely cause is an incorrect grub configuration; run the xe-edit-bootloader (i.e. xe-edit-bootloader –n centos) script at the XenServer host console to edit the grub.conf of the virtual machine until it boots.
Note: If the VM boots and mouse and keyboard control does not work properly, closing and re-opening XenCenter generally resolves this issue. If the issue is still not resolved, try other console settings for PV-args, being sure to reboot the vm and close and re-open XenCenter between each setting change.
Installing the XenServer Tools within the virtual machine:
Install the XenServer tools within the guest:

  1. Boot the paravirtualized VM (if not already running) into the xen kernel.

  2. Select the console tab of the VM

  3. Select and right-click the name of the virtual machine and click “Install XenServer Tools”

  4. Acknowledge the warning.

  5. At the top of the console window you will notice that the “xs-tools.iso” is attached to the DVD drive. And the Linux device id within the vm.

  6. Within the console of the virtual machine:
    a. mkdir /media/cdrom (Create a mount point for the ISO)
    b. mount /dev/xvdd /media/cdrom (mount the DVD device)
    c. cd /media/cdrom/Linux (change to the dvd root / Linux folder)
    d. bash install.sh (run the installation script)
    e. answer “y” to accept the changes
    f. cd ~ (to return to home)
    g. umount /dev/xvdd (to cleanly dismount the ISO)
    h. In the DVD Drive, set the selection to “”
    i. reboot (to complete the tool installation)

  7. Following reboot the general tab of the virtual machine should report the Virtualization state of the virtual machine as “Optimized”
    Posted by BrianEh at 10:27 AM
    Email ThisBlogThis!Share to TwitterShare to Facebook
    Labels: CentOS, Conversion Tools, RedHat, XenServer
    17 comments:
    Anonymous said…
    Hi great tutorial.
    Testet with a VM from VMWare2.0 to XenServer 5.0.
    I Have only Problems with the PV-args. I can see everything on the xen center but can not edit something into the console.
    with PV-args=“console=tty0 xencons=tty” the console hangs.
    With PV-args="" or PV-args=“console=hvc0 xencons=hvc” i can see it but have no edit function.
    September 25, 2009 1:56 AM
    BrianEh said…
    There are many PV-args options that are possible.

What do you mean by: “I can see it but have no edit function.”

This should be editable through xe commands at any time that the VM is not running.

Sometimes only the console= is required.
Sometimes you might also see a console= declaration in the bootloader entry. And I have better luck when I delete it from the grub entry.

I have found that I generally have to play around with it.

Oh! And if you change this console setting and you are using XenCenter - you will most likely have to close and re-open XenCenter. The only reason that I can figure for this is that the video is captured following editing this setting, but the mouse and keyboard are lost.
September 25, 2009 7:56 AM
Jeremy said…
Just wanted to say this post solved an issue unrelated to what it was written about but none-the-less saved me hours of work. Thanks!
December 12, 2009 3:07 PM
daniel said…
Hi, great infos! they saved me hours of search.

I followed the tutorial applying it to a Fedora 12, the shipped kernel already supports booting as DomU and stock grub.conf looks already pygrub compatible.

but pygrub fails to find the partition with the kernel on it! what might it be?
I just realized that the VM boots in a LVM which may not be supported by xenserver, any ideas?
December 29, 2009 3:57 PM
BrianEh said…
I have not tried this with Fedora 12, so I am only specilating here.

I have generally found that the RedHat and Fedora installation - ‘just work’ when moving them about as an HVM type VM.

The only way that this will work as a PV’d machine is if Fedora has a kernel-xen and then when the kern-xen is loaded new disk devices come into play - thi sis where the xvd* type devices socome from.

LVM should not matter. But most likely the device driver that we expect is not loading properly and the device that Grub is looking for is not there.

I have also seen QEMU devices appear as well.
In general, Anaconda picks these hardware changes up.

I know that I have not directly answered this, but I am not familiar wit hte xen PV kernel in Fedora 12 enough to provide any concrete answers.
December 30, 2009 7:56 AM
Jorge said…
Hi, can you post a guide for Paravirtualizing a Linux VM not coming from VMware but installing from scratch - ISO/DVD?

In my case I need to install ClearOS Gateway (www.clearfoundation.com) based in CentOS 5.4, I can’t install it using CentOS 5.3 template in Xenserver so I will need some of your help.

I also posted this problem in Citrix Forums: http://forums.citrix.com/thread.jspa?messageID=1426741&#1426741

Thank you very much!
January 4, 2010 7:24 PM
BrianEh said…
The steps are nearly the same.

Optimally, you want to use the XenServer provided template - it is more than just VM hardware settings, far more.

In your case, you create a new VM as an HVM (just as if it came from VMware) with one of the Windows templates. (do not use ‘other’).

Then you install the OS.
Add the kernel-xen and shut down the vm - then in the XenServer cli you modify the VM to make it PV.

Then boot the VM and in the boot menu select the kernel-xen. You now have a VM that can boot as either a paravirtualized or HVM type machine. Making it uber portable.

Anil outlined the steps for Ubuntu here: http://community.citrix.com/display/ocb/2008/07/02/Installing+Ubuntu+on+XenServer
January 5, 2010 8:04 AM
Jorge said…
I actually tried to use (and I prefer it) the Xenserver provided template for CentOS 5.3 but I’m always asked for a CDROM driver and can’t get away with it that’s why I can’t continue. Also even NFS and FTP installation doesn’t work. Maybe it’s because of the 5.3 difference over 5.4? You have any suggestion?

Trying your guide now on a Windows 2003 template. Will let you know the results.
January 5, 2010 9:34 PM
Jorge said…
I was able to successfully install ClearOS 5.1 (based in CentOS 5.4) xen kernel and follow your instructions without problem. I did get my VM paravirtualized!

But after looking to all possible causes I still can’t make the NIC’s in my VM to work and connect. The NIC are present and detected by the VM but can’t get an IP which is working well before doing the PV guide.

Result of ifconfig -a && cat /etc/sysconfig/network-scripts/ifcfg-eth0:
http://pastebin.com/m74a5f9e8

Content of /var/xapi/state.db: http://pastebin.com/m2bfd2d39

Please help me make it work, been working this for 2 days already :frowning:

Thanks a lot!
Jorge
January 6, 2010 1:31 AM
Anonymous said…
Thank you!
This worked perfectly in order to get my CentOS 5.4 installation to work with XenServer 5.5.

I had to set the PV-args to an empty string (""), and when I booted the machine, the network configurations settings file was renamed making the network disabled.

Just renamed the file right back, and everything works!
January 30, 2010 3:22 AM
Peter Kline said…
Great article! - one catch I had of note - might even want to be part of the article.

On my CentOS 5.5 distro, I HAD to rebuild the init ramdisk. I was misled into not doing this when yum install placed an image with the same name in the /boot directory. Nonetheless, it wouldn’t find the block devices and thus my LVM PVs until I rebuild the initrd with the xenblk drivers.

Also - if you are accessing the console via XenCenter you must restart the XenCenter software or it can cause issues with your keyboard not making it to the console.
June 26, 2010 4:39 PM
Alien Life Form said…
This post is really a golden nugget.
Thanks a 1000.
June 29, 2010 4:33 AM
Anonymous said…
Hi, I run into same problem with NICs as Jorge.
My xenservr is 5.6.0, host os is ClearOS 5.2.
August 31, 2010 4:18 PM
BrianEh said…
These new articles might be useful to you:

Installing Ubuntu Server 10.04 (32bit and 64bit) LTS
http://community.citrix.com/display/xs/Installing+Ubuntu+Server+10.04+(32bit+and+64bit)+LTS

Configuring RHEL 5.5 Guests on XenServer 5.5 and 5.6
http://community.citrix.com/display/xs/Configuring+RHEL+5.5+Guests+on+XenServer+5.5+and+5.6

Configuring CentOS 5.5 Guests on XenServer 5.5 and 5.6
http://community.citrix.com/display/xs/Configuring+CentOS+5.5+Guests+on+XenServer+5.5+and+5.6

http://community.citrix.com/display/xs/The+Operation+of+Unsupported+Guests+on+XenServer+5.5+and+5.6
September 2, 2010 12:08 PM
Mike said…
Thanks Brian for this, if I had found it sooner it would have saved me a bunch of hours of banging my head against a wall trying to PV-ise a VM which had been setup incorrectly.

FYI I had to go with the PV-args=“console=hvc0” also. My next challenge is to get the graphical UI working again, but I’ll tackle that another day :slight_smile:

Cheers,

Mike.
April 12, 2011 12:12 AM
SDB69 said…
After a week of trying to get XenServer Tools installed, then realizing the converted CentOS 5.5 64-bit was a HVM, but needed to be a PV… your blog was hands down the most useful information that I found on the topic. Thank you much for the help.
April 13, 2011 6:03 PM
BrianEh said…
This post is getting a bit old. But folks contribute over time to the things I can’t.

Here is some new help that came through a Citrix XenConvert forum:

I needed to update my kernel for the mkinitrd step to work. Otherwise I’d end up with the error “no modules available for kernel”. To update your kernel, run “yum -y update kernel kernel-headers”. Be sure to reboot once you’ve done this.

The initial PV-args setting that the article suggests caused my console to not allow keyboard input. The PV-args setting that ultimately worked for me was “console=tty0”.

The cdrom device that you need to mount for the xen-tools.iso installation step will vary. For us, it was /dev/xvdc instead of /dev/xvdd as the article suggests.
October 7, 2011 11:32 AM

I`m trying to do this but the boot is failing

Booting ‘CentOS (2.6.18-308.4.1.el5xen)’

root (hd0,0)
Filesystem type is ext2fs, partition type 0x83
kernel /vmlinuz-2.6.18-308.4.1.el5xen ro root=/dev/hda2

Error 13: Invalid or unsupported executable format

Press any key to continue

@raymonvdm

I got error 13 when following this guide. Check the file name of the newly created initrd file is the same as that which you are pointing to in the menu.1st file.

Make sure all other steps to do with menu.1st are correct.

hope it helps

Used it to PV two Elastix installs. Once point that may save some people a little pain - when you first boot into PV mode (so before the network is working to allow SSH), you can’t type in the console in XenCenter, so can’t get in to fix the network.
Close XenCenter and restart it and it’s all fine again.

I also had to install kmod-dahdi-xen before the meetme would work
yum install -y kmod-dahdi-xen
modprobe dahdi (necessary?)
service dahdi start