Here is my write-up, hopefully it helps out. If you can make this into a script, that would be awesome <hint hint>
I finally got this to work with ClearOS 6.2 and VirtualBox 4.1 running Windows 7 64 bit as the guest OS. Had a few challenges (including the kernel-devel and kernel-headers). I did not install the web interface for virtualbox, I found I did not need it for my particular install. There are probably some things that can be done easier, please comment when you see them. Thank you everyone for your posts, they helped to find answers to the issues. If you try this out, please remember post your findings as well, it may help the next person...
I will mention one big lesson I learned the hard way, DO NOT do a “yum update” before you register your ClearOS system. It trips something that AUTO-UPGRADES you to the professional version and ELIMINATES THE OPTION OF COMMUNITY VERSION. I had to reload from scratch to register it properly as a community version. The good news is, because of this lesson, I was able to verify that the steps worked for me on the second time too!
Here are the steps. I did everything using: SSH, Firefox and rdesktop on an Ubuntu box.
First, REGISTER YOUR SYSTEM, then get to the command line.
The following steps will update your system using yum, add a virtualbox repository from oracle to your system and install all the other misc stuff you'll need.
##update the system. If you haven't registered your system, do it before doing this update if you want to run the community version (last reminder, I promise).
We need to change directories to where the repository files are stored . We are going to download a new repository here so yum will “automagically” find it the next time you update.
Install wget so you can download the file for the new repository
yum install wget -y
Download the repository file from virtualbox.
Change driectories back to the root directory so nothing else gets downloaded here by accident.
Now that you have a new repository, it will need to be checked and updated.
Get some dependencies
yum groupinstall "Development Tools" -y
yum install php-soap gcc dkms kernel-devel -y
This command came from Tim in another thread but seems to help virtualbox compile correctly because it uses the v6 kernel-headers as opposed the the el6 kernel-headers in the standard repository. See the thread for details... www.clearfoundation.com/component/option.../func,view/id,40819/
yum --enablerepo=clearos-dev install kernel-devel-`uname -r` kernel-headers-`uname -r`
Create a vbox system user with a home directory
/usr/sbin/useradd -r -m vbox
Create group and add vbox to it
/usr/sbin/usermod -a -G vboxusers vbox
Install VirtualBox 4.1 using yum virtualbox.org repository
yum install VirtualBox-4.1.x86_64 -y
Now, this is the part that I forgot about BOTH times. I got errors with virtualbox, as noted in the posts previous to this one. Even though the command to install dkms is listed above (and I thought that it did install), virtualbox has issues with it. To fix it, I enabled the “clearos-epel” repository using the web GUI under “System” tab, “Software Repository”. With the new repo, you;ll need another update:
Now you will need to install dkms (again?)
yum install dkms -y
Recompile virtualbox drivers with the new dkms. The recompile didn't have any errors this time.
Also, in 4.1, there is an expansion pack that adds functionality into the machine like RDP. You will neeed to download it from virtualbox.org and install it. Go to the website www.virtualbox.org/wiki/Downloads
look up the extension pack and update the address below to match your version. Here is the link for the one I used:
Use vboxmanage to install it.
VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-4.1.16-78094.vbox-extpack
So now I had it set up, I needed a machine. Here goes....
First of all, create a new system user called vbox and a group for them.
/usr/sbin/useradd -r -m vbox
/usr/sbin/usermod -a -G vboxusers vbox
I needed a Windows 7 iso file to load this thing so I converted the installation CD to an iso. Put the CD into your ClearOS machine. Don't worry, it doesn't really catch on fire when the “essence of pure evil” touches your machine. It may smolder though.. Anyway, here's the command to convert the CD to an ISO:
dd if=/dev/cdrom of=/home/vbox/windows7.iso
Change directories to where it was created and then change the ownership to vbox to avoid “issues”
chown vbox:vbox /home/vbox/windows7.iso
You now need to change your user to vbox instead of root, so the rest of these commands are as the user vbox.
virtualbox creates it's working directory with a space in the name. Spaces can cause you some headaches if they are not escaped. Make a new working directory and and configure virtualbox to use it as the working directory to store virtual machines.
VBoxManage setproperty machinefolder /home/vbox/vms/
Create and register your new virtual machine. The new machine will be stored in the directory you just created.
VBoxManage createvm --name "Windows7" –register
This one modifies the new vm and creates a lot of hardware. I set it with 2 gig of ram (2048) since it's not going to be really used heavily, just occasionally for remote access for a Windows user.
First issue I had was it would not run saying something about not 64 bit. AMD FX 4-core “Unlocked” processor and seems to meet all the specs. Wound up being the “ioacpi” setting, it needed to be turned on.
I also had some issues with Windows finding the nic driver at first too so I changed the nictype. There are a few different ones, this one seemed to work so...
I tried using both bridged and nat connections. Ultimately, I didn't need a bridged network on this device so nat worked fine.
Here is the initial command with all the stuff that made mine work:
VBoxManage modifyvm "Windows7" --memory 2048 --cpus 1 --ioacpi on --acpi on --boot1 dvd --nic1 nat --nictype1 82545EM --ostype "Windows7_64"
This will create a 40 gig drive for your machine. If you want bigger, just change the 40960 to something higher. (multiples of 1024)
VBoxManage createhd --filename "HDD-Windows7.vdi" --size 40960 --remember
Now add a controller fot the hard drive
VBoxManage storagectl "Windows7" --name "storage-ctrl" --add sata
Attach the new hard drive to the machine
VBoxManage storageattach "Windows7" --storagectl "storage-ctrl" --port 0 --device 0 --type hdd --medium /home/vbox/vms/Windows7/HDD-Windows7.vdi
This changed the RPD port to 3389.
VBoxManage modifyvm "Windows7" --vrde on --vrdeport 3389
Add the iso file to the machine as it's CDROM
[codeVBoxManage storageattach "Windows7" --storagectl "storage-ctrl" --port 1 --device 0 --type dvddrive --medium /home/vbox/]windows7.iso[/code]
This starts up the machine. Once it's started, use remote desktop or rdesktop to connect by pluggin in your clearos ip followed by the port. Example on Ubuntu: rdesktop 192.168.1.1:3389 and now install Windows 7 from the CD you attached using your RDP session.
VBoxHeadless --startvm "Windows7" -vrde on -vrdeproperty TCP/Ports=3389 &
FINALLY, setup autostart. You will want to be root on this one. Type exit if you are still using the vbox user and you should be root again. You will need to add in the following line to the end of /etc/rc.d/rc.local. I used nano: Copy and paste the following at the bottom:
/bin/su -l vbox -c '/usr/bin/VBoxHeadless --startvm Windows7 2>&1 &'
Press CTRL + o to save and CTRL + x to exit when you are done.
If all went well, when you restart your ClearOS system, the virtual machine will startup automagically as well. If the virtual machine is running whenyou want ot reboot, it is probably a good idea to log into it and shut it down before initiating a reboot. I have “LogMeIn” installed in the Windows 7 machine and it comes on-line a few minutes after the server boots up. At this point, the RDP session is pretty much just to check progress if it fails to show “on line” in LogMeIn.
That's about it. If you find a better way, please post it. Thanks again for all the other posts that got it working.