VirtualBox 4.0 on SME Server v8 beta 6

From SME Server
Revision as of 05:10, 24 September 2012 by Compsos (talk | contribs) (→‎Installation)
Jump to navigationJump to search

Maintainer

CompSOS

Support

For questions or comments regarding this HOWTO, contact Shiena Tadeo of Computing SOS or Sorolo Systems Inc. at this email address.

Description

Below are instructions on how to install VirtualBox version 4.1 on a fresh install SME Server v8 beta 6 and higher. Plus installing and configuring phpVirtualBox to control (create, edit, remove) your virtual machine on its web interface. In addition, scripts to automatically start the vbox service and the virtual machines in case of power failure can be found at the end of this article.

This has been tested using the following:

  • one SME Server Release 8.0
  • two VirtualBox-4.1-4.1.22_80657_el5-1
  • three Kernel is 2.6.18-308.13.1.el5

Requirements

Computer with SME server version 8 beta 6 and higher installed.

Installation

  1. Setup SME Server v8 beta 6.
  2. Do a yum update.
  3. yum upgrade
  4. If any updates were applied, update and reboot the server.
  5. signal-event post-upgrade
    signal-event reboot
  6. Check your current kernel.
  7. uname -r
  8. Install kernel-devel to get the latest development tree. Latest kernel at the time of writing is 2.6.18-308.13.1.el5.
    Use this command only if you have a PAE kernel installed:
    yum clean all
    yum install kernel-PAE-devel kernel-headers
    yum info kernel-headers

    Otherwise,

    yum install kernel-devel kernel-headers
  9. Check if the compiler (GCC) is installed by issuing this command.
    rpm –qa | grep gcc

    You will have an output, similar to this:

    libgcc-4.1.2-52.el5_8.1
    gcc-4.1.2-52.el5_8.1

    If not installed, install it.

    yum install gcc

    If you will get an error "No package gcc available. Nothing to do" then do this:

    cd /tmp
    wget ftp://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/releases/gcc-4.7.1/gcc-4.7.1.tar.gz
  10. Update SME, and reboot again.
  11. signal-event post-upgrade
    signal-event reboot
  12. Change your kernel boot options.
    Optionally, for best results with SME 8.x and earlier versions, modify /etc/grub.conf, adding divider=10 to the kernel boot options in order to reduce the idle CPU load with VirtualBox. For example, if your kernel boot line is:
    kernel /vmlinuz-2.6.18-308.13.1.el5 ro root=/dev/main/root 

    change it to:

    kernel /vmlinuz-2.6.18-308.13.1.el5 ro root=/dev/main/root divider=10

    Reminder: if you subsequently update SME Server to use a newer kernel, you may need to change your kernel boot line to reflect the update.

  13. Create a symbolic link.

    NOTE: Be careful if you cut-and-paste the command below. Pay particular attention to the dashes (-) and the backticks (`). There aren't any single quote marks in the command below - they are all supposed to be backticks.

    ln -s /usr/src/kernels/`uname -r`-`uname -m` /lib/modules/`uname -r`/build

    Reminder: if you subsequently update SME Server to use a newer kernel, you may need to recreate the symbolic link.

  14. Check that the symbolic link was properly created by doing a directory listing.

    NOTE: Be careful if you cut-and-paste the command below. In some terminal windows, from some browsers, the parts of the command in bold font do not paste correctly. Pay particular attention to the dashes (-) and the backticks (`). There aren't any single quote marks in the command below - they are all supposed to be backticks.

    ls -la /lib/modules/`uname -r`/build
  15. Install the Fedora Epel repository using the instructions here.
  16. Install Dynamic Kernel Module Support (DKMS)
  17. yum install --enablerepo=epel dkms
  18. Install the VirtualBox repository using the instructions here.
  19. Install VirtualBox (At the time of the last update to these instructions, the latest version was v4.1-4.1.22).
  20. yum install --enablerepo=virtualbox VirtualBox-4.1
  21. Review the VirtualBox installation log to ensure that the installation was successful.
  22. tail /var/log/vbox-install.log
  23. Remove the compiler install (for security best practices)
  24. rpm -e gcc
  25. Update SME, and reboot again
  26. signal-event post-upgrade
    signal-event reboot
  27. Setup VirtualBox as a service so it starts automatically after a reboot. Copy the command below on putty console then hit Enter.
  28. for file in $(ls /etc/rc5.d/S??vbox*); do cp "$file" /etc/rc7.d/. ;done
  29. Create a vbox.cfg file on your /etc/vbox/.
  30. nano /etc/vbox/vbox.cfg

    vbox.cfg should have this content.

    VBOXWEB_USER='root'
    VBOXWEB_HOST=127.0.0.1
    VBOXWEB_PORT=18083

    Note: Without the vbox.cfg, vbox services on your rc7.d folder will not start.

  31. Login to the server-manager page and create an iBay for phpvbox. For instructions on how to create and configure an ibay, please see the SME Server Administration manual.
  32. After creating the ibay, do not forget to assign a password.
  33. Before we install phpVirtualBox, make sure you first install SOAP.
  34. yum install php-soap

    As of 2012-09-03 a fresh sme8b6 with updates installed, the above line tries to install php-soap-5.3.3-13.el5.sme.1.x86_64. If yum complains about a missing dependency php-common-5.3.3-13.el5.sme.1, verify whether you have installed php-common-5.3 by issuing this command "rpm -qa | grep php-common". If so, you can obtain php-soap-5.3.3-1.el5.sme.6 by invoking "yum install --enablerepo smedev php-soap-5.3.3-1.el5.sme.6". Integration test passed.

    To avoid this error message “PHP does not have the SOAP extension enabled” especially if you have no plan of restarting the server.

    svc -t /service/httpd-e-smith/
  35. Install phpVirtualBox
  36. cd /tmp
    wget `wget -q -O - http://phpvirtualbox.googlecode.com/files/LATEST.txt` -O phpvirtualbox-latest.zip
    unzip phpvirtualbox-latest.zip

    Note: at the time of the last update, the latest version was 4.1-8. Please adjust the following for later versions.

    cd phpvirtualbox-4.1-8
    cp –R * /home/e-smith/files/ibays/phpvbox/html
  37. Create a tmp folder inside the /phpvbox/html folder.
  38. cd /home/e-smith/files/ibays/phpvbox/html
    mkdir tmp
    chmod 777 tmp/
  39. Create a config file using the example file provided.
  40. cp config.php-example config.php
  41. Open config.php (located on your /phpvbox/html/ folder). Uncomment some lines (by removing the '#' at the beginning of the line).
    nano /home/e-smith/files/ibays/phpvbox/html/config.php
    /* SOAP URL of vboxwebsrv (not phpVirtualBox's URL) */
    var $location = 'http://127.0.0.1:18083/';
    // Disable authentication
    var $noAuth = true;

    Set the consoleHost parameter to the hostname of the server running VirtualBox

    // Host / ip to use for console connections
    //var $consoleHost = 'host-name-of-the-server-running-virtualbox';
    /* Enable advanced configuration items (normally hidden in the VirtualBox GUI)
     * Note that some of these items may not be translated to languages other than $
     */
    var $enableAdvancedConfig = true;
    // Authentication library.
    //var $authLib = 'Builtin';

    Change the tmp location as per below.

    // Path
    var $cachePath = '../tmp';
  42. Disable authentication of vboxwebsrv (this is not recommended, but at this stage, this is the only setup that works). Login to the server’s SSH and type this command.
  43. vboxmanage setproperty websrvauthlibrary null
  44. Install VirtualBox extension pack to enable support for USB 2.0 devices, VirtualBox RDP and PXE boot for Intel cards. Please install the extension pack with the same version as your installed version of VirtualBox!
  45. You can find the extension packs here. The following commands download and install the extension pack for VirtualBox 4.1.8.
    wget http://download.virtualbox.org/virtualbox/4.1.8/Oracle_VM_VirtualBox_Extension_Pack-4.1.8-75467.vbox-extpack
    vboxmanage extpack install Oracle_VM_VirtualBox_Extension_Pack-4.1.8-75467.vbox-extpack
  46. Update SME, and reboot again
  47. signal-event post-upgrade
    signal-event reboot
  48. Ensure that the extension pack is installed correctly. Open a console window, then
    vboxmanage list extpacks
  49. At this point, VirtualBox should now be configured and running correctly. To check this, we will now log into the ibay we created for phpVirtualBox and attempt to create a new virtual machine. If you encounter problems, please recheck that you have setup VirtualBox as a service so it starts automatically after a reboot, and that your vbox.cfg file is configured correctly. To manage VirtualBox and any virtual machines, use the command line utility VBoxManage. See VBoxManage --help . For a list of available switches for VBoxManage, see this list. Finally,
  50. Open a terminal window to the SME Server and create a directory to store the virtual machine images.
  51. mkdir -p /opt/VMs
  52. Download the VirtualBox Guest Additions iso for later installation into your virtual machine guests.
  53. mkdir -p /var/lib/VirtualBox/addons
    cd /var/lib/VirtualBox/addons
    wget http://download.virtualbox.org/virtualbox/4.1.2/VBoxGuestAdditions_4.1.2.iso
  54. Using a web browser, Go to http://yourdomain.com/phpvbox and connect to the phpVirtualBox web application.
    • From the menu provided, go to select File->Preferences.
    • Select the "General" tab.
    • Change the Default Machine Folder to:
      /opt/VMs

    At this point, VirtualBox should now be configured and running correctly. If you encounter problems, please recheck that you have setup VirtualBox as a service so it starts automatically after a reboot, and that your vbox.cfg file is configured correctly. To manage VirtualBox and any virtual machines, use the command line utility VBoxManage. See VBoxManage --help . For a list of available switches for VBoxManage, see this list.

  55. Download the VirtualBox Guest Additions ISO for later installation into your Guests Virtual Machine.
    mkdir -p /opt/VMs/addons
    cd /opt/VMs/addons
    wget http://download.virtualbox.org/virtualbox/4.1.8/VBoxGuestAdditions_4.1.8.iso
  56. Creating a Virtual Machine

  57. Using a web browser, go to http://yourdomain.com/phpvbox to create your virtual machine.
    • Create a new virtual machine (e.g. vmXP)
    • Enable network card (either NAT or Bridged) so you can connect to your new VM console.

    Virtual box.jpg

  58. Ensure you are connected to the server's internal network, then open a Remote Desktop client program.
    • On Windows, open an RDP client (run->mstsc) then type your server’s domain name, (e.g. mydomain.com), hostname (e.g. myserver), or ip address (e.g. 192.168.100.254)
  59. Install the VirtualBox Guest Additions iso into your newly setup VM.

Automatically Start Virtual Machine

  1. Edit your vbox file on /etc/sysconfig/
  2. nano /etc/sysconfig/vbox

    vbox code should look like this:

    # Virtual box machines to autostart
    # Example to start 2 machines
    #       VBOX_AUTOSTART = "MachineName1 MachineName2"
    
    VBOX_AUTOSTART="vmXP"
    
  3. Edit your vbox file located on /etc/init.d/
    #!/bin/sh
    #
    # chkconfig: - 91 35
    # description: Starts and stops vbox autostart VMs.
    
    ### BEGIN INIT INFO
    # Provides: vbox
    # Required-Start: $network $named $vboxdrv
    # Required-Stop: $network $named
    # Default-Start:
    # Default-Stop: 0 1 2 3 4 5 6
    # Short-Description: Autostart some Virtual Box VMs
    # Description: Autostart some Virtual Box VMs that are mentioned in /etc/sysconfig/vbox file
    # Written by Alex Amiryan
    ### END INIT INFO
    
    . /etc/rc.d/init.d/functions
    
    MANAGE_CMD=vboxmanage
    
    [ -r /etc/sysconfig/vbox ] && . /etc/sysconfig/vbox
    
    prog=$"Virtual Box Machines"
    
    start()
    {
            echo -n $"Starting $prog: "
            RETVAL=0
    
            for vbox_name in ${VBOX_AUTOSTART}
            do
                SERVS=1
                echo -n "${vbox_name} "
                daemon $MANAGE_CMD startvm "${vbox_name}" -type headless >/dev/null 2>&1
                RETVAL=$?
                [ "$RETVAL" -eq 0 ] || break
            done
            if [ -z "$SERVS" ]; then
                echo -n "no virtual machines configured "
                failure
                RETVAL=6
            else
                if [ "$RETVAL" -eq 0 ]; then
                    success $"vbox startup"
                    touch /var/lock/subsys/vbox
                else
                    failure $"vbox start"
                fi
            fi
            echo
            return "$RETVAL"
    }
    
    stop()
    {
            echo -n $"Shutting down $prog: "
            for vbox_name in ${VBOX_AUTOSTART}
            do
                echo -n "${vbox_name} "
                runuser root -c "$MANAGE_CMD -q controlvm "${vbox_name}" savestate" >/dev/null 2>&1
            done
            RETVAL=$?
            [ "$RETVAL" -eq 0 ] && success $"vbox shutdown" || \
                failure $"vbox shutdown"
            echo
            [ "$RETVAL" -eq 0 ] && rm -f /var/lock/subsys/vbox
            return "$RETVAL"
    }
    
    status()
    {
            for vbox_name in ${VBOX_AUTOSTART}
            do
                echo -n "${vbox_name} "
                $MANAGE_CMD showvminfo "${vbox_name}"|grep "^State:\s*.*$"
            done
    }
    
    case "$1" in
      start)
            start
            ;;
      stop)
            stop
            ;;
      restart|force-reload)
            stop
            start
            ;;
      status)
            status
            ;;
      *)
            echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|status}" >&2
            exit 3
            ;;
    esac
    

Troubleshooting

  1. PhpVirtualBox throws an error attribute does not exist or method 'getVDENetwork' does not exist in the object.

    Solution: Check config.php file located on /home/e-smith/files/ibays/phpvbox/html/ and comment out the line var $enableVDE = true;

  2. #var $enableVDE = true;
  3. Virtual machine with a guest Windows XP installed takes too long to load.

    Solution: The Windows XP disk you might have used is slipstreamed with Intel ICH9 or ICH10. Uninstall iastor.sys on Safe Mode. Once you restart, it will reinstall it for you. Iastor.sys is an Intel Matrix storage manager, used to access RAID drives system driver file.