Difference between revisions of "VirtualBox 4.0 on SME Server v8 beta 6"
Line 101: | Line 101: | ||
<b>Note: Without the ''virtualbox'' file, vbox services on your rc7.d folder will not start.</b> | <b>Note: Without the ''virtualbox'' file, vbox services on your rc7.d folder will not start.</b> | ||
− | <li value="20"> | + | <li value="20">Install phpVirtualBox using this link http://wiki.contribs.org/Phpvirtualbox#DB_Configuration |
− | |||
− | + | <li value="21">Ensure that the extension pack is installed correctly. | |
− | |||
− | <li value="21 | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
Open a console window, then | Open a console window, then | ||
<pre>vboxmanage list extpacks</pre> | <pre>vboxmanage list extpacks</pre> | ||
Line 169: | Line 111: | ||
Finally, | Finally, | ||
− | <li value=" | + | <li value="22">Open a terminal window to the SME Server and create a directory to store the virtual machine images.</li> |
<pre>mkdir -p /opt/vms</pre> | <pre>mkdir -p /opt/vms</pre> | ||
− | <li value=" | + | <li value="23">Download the VirtualBox Guest Additions iso for later installation into your virtual machine guests.</li> |
<pre>mkdir -p /opt/vms/addons | <pre>mkdir -p /opt/vms/addons | ||
cd /opt/vms/addons | cd /opt/vms/addons | ||
wget http://download.virtualbox.org/virtualbox/4.3.6/VBoxGuestAdditions_4.3.6.iso</pre> | wget http://download.virtualbox.org/virtualbox/4.3.6/VBoxGuestAdditions_4.3.6.iso</pre> | ||
− | <li value=" | + | <li value="24">Using a web browser, Go to http://yourdomain.com/phpvirtualbox and connect to the phpVirtualBox web application. |
<ul> | <ul> | ||
<li>From the menu provided, go to select File->Preferences.</li> | <li>From the menu provided, go to select File->Preferences.</li> |
Revision as of 07:14, 15 January 2014
Maintainer
Support
For questions or comments regarding this HOWTO, contact Shiena 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:
- SME Server Release 8.0
- VirtualBox-4.3
- Kernel is 2.6.18-348.6.1.el5
Requirements
Computer with SME server version 8 and higher installed.
Installation
- Setup SME Server v8.
- Do a yum update.
- If any updates were applied, update and reboot the server.
- Check your current kernel.
- 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
Note : if you do not want to update your kernel, because of kmdl not available you can search for the right kernel-headers and kernel-devel in http://vault.centos.org/
- 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-54.el5 gcc-4.1.2-54.el5
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
- Update SME, and reboot again.
- 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-348.6.1.el5 ro root=/dev/main/root
change it to:
kernel /vmlinuz-2.6.18-348.6.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.
- 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.
- 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
- Install the Fedora Epel repository using the instructions here.
- Install Dynamic Kernel Module Support (DKMS)
- Install the VirtualBox repository using the instructions here.
- Install VirtualBox (At the time of the last update to these instructions, the latest version was v4.3-4.3.6-91406).
- Review the VirtualBox installation log to ensure that the installation was successful.
- Remove the compiler install (for security best practices)
- Update SME, and reboot again
- Setup VirtualBox as a service so it starts automatically after a reboot. Copy the command below on putty console then hit Enter.
- Create a virtualbox file on your /etc/default/.
- Install phpVirtualBox using this link http://wiki.contribs.org/Phpvirtualbox#DB_Configuration
- Ensure that the extension pack is installed correctly.
Open a console window, then
vboxmanage list extpacks
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,
- Open a terminal window to the SME Server and create a directory to store the virtual machine images.
- Download the VirtualBox Guest Additions iso for later installation into your virtual machine guests.
- Using a web browser, Go to http://yourdomain.com/phpvirtualbox 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.
yum upgrade
signal-event post-upgrade; signal-event reboot
uname -r
signal-event post-upgrade; signal-event reboot
yum install --enablerepo=epel dkms
yum install --enablerepo=virtualbox VirtualBox-4.3
tail /var/log/vbox-install.log
rpm -e gcc
signal-event post-upgrade; signal-event reboot
for file in $(ls /etc/rc5.d/S??vbox*); do cp "$file" /etc/rc7.d/. ;done
nano /etc/default/virtualbox
virtualbox should have this content.
VBOXWEB_USER='root' VBOXWEB_HOST=127.0.0.1 VBOXWEB_PORT=18083 VBOXWEB_LOGFILE=/var/log/vboxweb INSTALL_DIR=/usr/lib/virtualbox
Note: Without the virtualbox file, vbox services on your rc7.d folder will not start.
mkdir -p /opt/vms
mkdir -p /opt/vms/addons cd /opt/vms/addons wget http://download.virtualbox.org/virtualbox/4.3.6/VBoxGuestAdditions_4.3.6.iso
Creating a Virtual Machine
- 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.
- Even when the extension is installed, the VRDP server is disabled by default. On console:
- 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 hostname:port number (e.g. myserver:9000), or your Server's (not your Guest) IP address followed by colon then the port number as shown on above image (Remote Desktop Server Port under Display) (e.g. 192.168.100.1:9000). NOTE: No need to change to port number to 9000 (as per above) in your Windows registry (HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\TerminalServer\WinStations\RDP-Tcp\PortNumber). It will still be using port 3389 even though phpVirtualBox is using port 9000.
- Install the VirtualBox Guest Additions ISO into your newly setup VM.
vboxmanage modifyvm "vmXP" --vrde on
Access VM outside the Network
- On SME Server Manager page, on Port Forwarding left menu, open port 9000 (as per Remote Desktop Server Port under Display) using your desired Source Port: Protocol: TCP
- Now you can access your VM thru RDP using this hostname domain.com:33900
Source Ports: 33900
Destination IP: 192.168.5.1 (which is also the guest IP)
Destination Port: 9000
Allow Hosts: <you can leave it blank, or place your Public IP so only your IP can access the VM)
Rule Comment: <eg. vmXP for SOS>
Automatically Start Virtual Machine
- Edit your vbox file on /etc/sysconfig/
- 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
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"
Upgrading VirtualBox
- Remove installed VirtualBox.
yum remove VirtualBox-4.1
- Install the latest VirtualBox, as of this date it is VirtualBox 4.2.
yum install --enablerepo=virtualbox VirtualBox-4.2
- Create a virtualbox file on your /etc/default/. On Virtualbox 4.1, virtualbox file was originally /etc/vbox/vbox.cfg.
nano /etc/default/virtualbox
virtualbox should have this content.
VBOXWEB_USER='root' VBOXWEB_HOST=127.0.0.1 VBOXWEB_PORT=18083 VBOXWEB_LOGFILE=/var/log/vboxweb INSTALL_DIR=/usr/lib/virtualbox
- Install VirtualBox extension pack, you can find the extension packs here.
wget http://download.virtualbox.org/virtualbox/4.2.0/Oracle_VM_VirtualBox_Extension_Pack-4.2.0-80737.vbox-extpack vboxmanage extpack install Oracle_VM_VirtualBox_Extension_Pack-4.2.0-80737.vbox-extpack
- Test if your VirtualBox upgrade is successful by starting your existing virtual machine.
vboxheadless –s vmXP
OR/etc/init.d/vbox start
Upgrading phpVirtualBox
- Make a directory to save your existing phpVirtualBox folder.
mkdir –p /tmp/phpvirtualbox-4.1.22
- Change directory to your phpvbox ibay then copy all of your phpVirtualBox files.
cd /home/e-smith/files/ibays/phpvbox/html/ cp –R * /tmp/phpvirtualbox-4.1.22
- Download the latest phpVirtualBox to /tmp/ folder.
cd /tmp wget http://phpvirtualbox.googlecode.com/files/phpvirtualbox-4.2-0b.zip unzip phpvirtualbox-4.2-0b.zip cd phpvirtualbox-4.2-0b yes | cp -R * /home/e-smith/files/ibays/phpvbox/html/
- Rename config.php.example to config.php and edit the configuration file as per above.
mv config.php-example config.php
- Restart vboxwebservice
/etc/init.d/vboxweb-service restart
- Download the latest VBox Guest Additions and install to your Guest VM.
cd /opt/VMs/ wget http://download.virtualbox.org/virtualbox/4.2.0/VBoxGuestAdditions_4.2.0.iso
Troubleshooting
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;
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.
#var $enableVDE = true;