First of all, this thread is going to be long...But in the end it will look something like this:
This thread is aim to achieve the following:
- Auto start VirtualBox on user login.
- Auto start rdesktop when Virtual Machine is booted
- Auto place rdesktop into workspace 2
- Resize rdesktop to fit workspace 2
- Replace Virtual Machine (XP Pro) shell into something lighter
- Make things pretty
- Resolve clipboard bug with fullscreen rdesktop
- Auto shutdown Virtual Machine on shutdown.
I have tried many methods before and I found this configuration to be the best and most productive, better than seamlessrdp and virtualbox built in seamless. Here are the problems I have had in the past with other methods:
2X Application Server:
- Not very stable when moving windows.
- Caused virtual machine to hang on a few occasions.
- Higher CPU usage.
seamlessrdp:
- Not stable when you have too many windows open.
- Slower, need to script auto login, logoff then launch the seamlessrdp script.
- Causes higher CPU usage, my laptop heats up more.
VirtualBox seamless:
- Too many windows gives problems
- Apps opened are not on the gnome taskbar like seamlessrdp
- Again, causes higher CPU usage, my laptop heats up more.
Regular rdesktop works the best because CPU usage is lower and it is more stable.
Okie! So let's get started:
What you need:
- VirtualBox Installed and running.
- Virtual Machines Installed Running mine is named XP (I Googled [TinyXP Rev09 - eXPerience] because it runs faster)
- Remote Assistance Enable (Remote Desktop Enabled).
- Compiz Installed and Running
- Advanced Desktop Settings Installed (sudo apt-get install compizconfig-settings-manager).
Step 1
Here is the script to start your virtual machine and rdesktop. Copy and paste into a new text file and name it launchXP.sh
The script requires nmap, install it with the following and make the launchXP.sh executable.Code:#!/bin/bash # launchXP.sh by waspbloke September 2008 # # requires nmap (sudo apt-get install nmap) # # create your own custom app launchers by calling this script with different app arguments # ORIGINAL SCRIPT FROM: http://ubuntuforums.org/showthread.php?t=904379&highlight=bash+ping # change these vars to reflect your own setup PathHere="/home/yourhomedir" GuestIP="10.0.1.2" #The external ip of the Virtual Machine # check if VM is already running # if VM not running start the VM and wait while it boots if [ $(VBoxManage -nologo list runningvms | wc -l) = 0 ]; then VBoxHeadless -startvm XP & echo "Please wait, starting VM XP..." sleep 55 fi # check if VM's RDP port is ready to connect echo "VM started, scanning RDP port 3389..." until [ "$RDPstate" = "open" ] do # scan port 3389 and send output to file nmap -p 3389 $GuestIP > $PathHere/NMAPout # set RDPstate var if NMAP scan is successful RDPstate=$(awk '/(3389)/ && /(open)/ {print "open"}' $PathHere/NMAPout) if [ ! $RDPstate ]; then RDPstate="closed"; fi echo "...RDP port is currently $RDPstate..." sleep 5 done # now we can fire up rdesktop echo "Launching rdesktop session..." #You can launch in seamlessrdp mode if you want to... rdesktop localhost:3389 -z -x l & # clean up before exit rm $PathHere/NMAPout exit 0
Step 2Code:sudo apt-get install nmap sudo chmod +x /home/yourhomedir/launchXP.sh
For auto shutdown Virtual Machine on reboot/shutdown, download vboxcontrol, follow the instructions here
Note:
I did not let vboxcontrol autostart my Virtual Machines, because it screws up my PluseAudio for some reason. So I modified the script with "sudo gedit /etc/init.d/vboxcontrol" see the bold text:
Code:#! /bin/sh ### BEGIN INIT INFO # Provides: virtualbox_vms # Required-Start: $local_fs $syslog $remote_fs # Required-Stop: $local_fs $syslog $remote_fs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Control VirtualBox Virtual Machine instances ### END INIT INFO # # Version 2008051100 by Jochem Kossen <jochem.kossen@gmail.com> # http://farfewertoes.com # # Released in the public domain # # This file came with a README file containing the instructions on how # to use this script. # . /lib/lsb/init-functions # Are we running from init? run_by_init() { ([ "$previous" ] && [ "$runlevel" ]) || [ "$runlevel" = S ] } ################################################################################ # INITIAL CONFIGURATION VBOXDIR="/etc/virtualbox" VM_USER="root" USE_NAT="yes" export PATH="${PATH:+$PATH:}/bin:/usr/bin:/usr/sbin:/sbin" if [ -f $VBOXDIR/config ]; then . $VBOXDIR/config else echo "ERROR: $VBOXDIR/config does not exist. Exiting." exit 1 fi SU="su $VM_USER -c" VBOXMANAGE="VBoxManage -nologo" #VBOXMANAGE="VBoxVRDP -s" ################################################################################ # FUNCTIONS # Determine if USE_NAT is set to "yes" use_nat() { if [ "$USE_NAT" = "yes" ]; then return `true` else return `false` fi } # Bring up the bridge interface enable_bridge() { # If NAT is enabled, don't do anything use_nat && return # Load the tun module if [ ! -e /dev/net/tun ]; then modprobe tun fi brctl addbr br0 || /bin/true # Disable $HOST_IF; host will use br0 instead ifdown $HOST_IF ifconfig $HOST_IF 0.0.0.0 promisc brctl addif br0 $HOST_IF # Bring up br0 ifup br0 # Answer ARP requests for $HOST_IP (which now come on br0) with the MAC # address of $HOST_IF arp -Ds $HOST_IP $HOST_IF pub } # Bring down the bridge interface disable_bridge() { # If NAT is enabled, don't do anything use_nat && return ifdown br0 brctl delbr br0 ifup $HOST_IF } # Activate tap interfaces enable_taps() { # If NAT is enabled, don't do anything use_nat && return for TAP in $TAPS; do # Check if $TAP is configured already ifconfig $TAP > /dev/null 2>&1 if [ $? != 0 ]; then tunctl -t $TAP -u $VM_USER brctl addif br0 $TAP # Disable tap interfaces for host; guest will activate them for themselves ifconfig $TAP 0.0.0.0 promisc # Enable proxy_arp so that ARP requests can be answered correctly # by the host echo 1 > /proc/sys/net/ipv4/conf/$TAP/proxy_arp # Add a route for the tap device route add -host $HOST_IP dev $TAP else log_failure_msg "Interface $TAP already configured" fi done } # Disable/deconfigure tap interfaces disable_taps() { # If NAT is enabled, don't do anything use_nat && return for TAP in $TAPS; do route del -host $HOST_IP dev $TAP brctl delif br0 $TAP tunctl -d $TAP done } # Check for running machines every few seconds; return when all machines are # down wait_for_closing_machines() { RUNNING_MACHINES=`$SU "$VBOXMANAGE list runningvms" | wc -l` if [ $RUNNING_MACHINES != 0 ]; then sleep 5 wait_for_closing_machines fi } ################################################################################ # RUN case "$1" in start) if [ -f /etc/virtualbox/machines_enabled ]; then if [ ! `use_nat` ]; then enable_bridge enable_taps chown root.vboxusers /dev/net/tun chmod 0660 /dev/net/tun # else fi # Configure Networking... # chown root.vboxusers /dev/net/tun tunctl -t tap1 -u edmondt ifconfig tap1 10.0.1.1 cat /etc/virtualbox/machines_enabled | while read VM; do log_action_msg "Starting VM: $VM ..." # $SU "$VBOXMANAGE startvm \"$VM\" -type vrdp" done fi ;; stop) # NOTE: this stops all running VM's. Not just the ones listed in the # config $SU "$VBOXMANAGE list runningvms" | while read VM; do log_action_msg "Shutting down VM: $VM ..." $SU "$VBOXMANAGE controlvm \"$VM\" acpipowerbutton" # $SU "$VBOXMANAGE controlvm \"$VM\" savestate" done wait_for_closing_machines if [ ! `use_nat` ]; then disable_taps disable_bridge fi ;; bridge-up) enable_bridge ;; bridge-down) disable_bridge ;; taps-up) enable_taps ;; taps-down) disable_taps ;; start-vm) log_action_msg "Starting VM: $2 ..." $SU "$VBOXMANAGE startvm \"$2\" -type vrdp" ;; stop-vm) log_action_msg "Stopping VM: $2 ..." $SU "$VBOXMANAGE controlvm \"$2\" acpipowerbutton" ;; poweroff-vm) log_action_msg "Powering off VM: $2 ..." $SU "$VBOXMANAGE controlvm \"$2\" poweroff" ;; status) log_action_msg "The following virtual machines are currently running:" $SU "$VBOXMANAGE list runningvms" | while read VM; do echo -n "$VM (" echo -n `$SU "VBoxManage showvminfo $VM|grep Name:|sed -e 's/^Name:\s*//g'"` echo ')' done ;; *) log_failure_msg "Usage: $0 {start|stop|status|start-vm <VM name>|stop-vm <VM name>|poweroff-vm <VM name>|bridge-up|bridge-down|taps-up|taps-down}" exit 3 esac exit 0
Step 3
On System > Preference > Session, under Start Up Programs Add...
Name: Start VirtualBox
Command: sh /home/yourhomedir/launchXP.sh
Comment: Start virtualbox and rdesktop
Step 4
Now your VM should autostart and rdesktop should auto load, it look a little ugly, but we will change that...
Open Terminal and launch
Disable window borders for rdesktop and shadows:Code:ccsm &
Goto: Window Decoration
Decoration windows: any & !(class=rdesktop)
Shadow windows: & !(type=Dock) & !(class=rdesktop)
Goto: Window Rules
- Enable Window Rules.
Skip taskbar: title=rdesktop - localhost
Skip pager: title=rdesktop - localhost
Fullscreen: title=rdesktop - localhost
No ARGB visuals: title=rdesktop - localhost
Non movable windows: title=rdesktop - localhost
Non minimizable windows: title=rdesktop - localhost
Non maximizable windows: title=rdesktop - localhost
Non closable windows: title=rdesktop - localhost
Goto: Place Windows
- Enable Place Windows.
Under Fixed Window Placement, Add Viewport positioned windows:
Viewport positioned windows: (class=rdesktop) & title=rdesktop - localhost
X Viewport Positions: 1
Y Viewport Positions: 0
This is optional, it is more productive for me when I enable Edge Flip Pointer, when my mouse is over the edge of the screen, it switches to Viewport 1 (Where rdesktop is running).
Under Rotate Cube, check Edge Flip Pointer
Try to run the script, *fingers crossed* once windows is running, we would still need to resize the Virtual Machine Resolution:
My hp tx1000 runs at 1280x800, I would just need to make my VM a little bit shorter to fit the top and bottom gnome bars:
Resize your VM to your situation, since some people only have the bottom barsCode:VBoxManage controlvm "XP" setvideomodehint 1280 760 32
That should be about it, I will keep updating this thread for instructions as to how to change the default shell on windows... I hope this is helpful
*Update*
2008.11.07 - I Upgraded to 8.10 and made some changes (see post 11)
2010.03.01 - Changed the port number from 4000 to 3389 (Thanks "Ng Oon-Ee"). Looking at updating this HOWTO...
Bookmarks