happy laptop

Virtual Machine to run on boot up and revert to snapshot

I had an interesting answer to an annoying task this week at work. We had a business need to train lots of different clients at different times and locations on our web application but with a need for a none technical person to restart the web application back to zero at the start of the each training session.


At least five trainers needing the web application offline each on a training laptop
Needing to update the master web application regular from a central location
Trainers are not technical so a simple solution needed
Clients still need to connect to the web application via a local network


Web application to be built into a vanilla virtual machine that can be loaded onto all the training laptops and to keep a central version that can be easily updated
The training laptops to be installed with ubuntu with vbox to run the virtual machine
The training laptops to have a fixed IP on eth0 and the virtual machine to have a fixed IP on eth0 on the same range using a bridged adapter.
Use a small nano router connected to the training laptop on the same IP range so all training, client machines and virtual machines can communicate

So the above solution would be great but the two things missing from this solution is how the trainer is going to have to start the virtual machine and at the moment no way to roll back the virtual machine easily

Solution 2

On the central server make a snapshot in virtual box and test that this can be rolled back. With this working then the next stage is to have the training machine to automatically roll back to that snapshot once the training session has finished

Script time

The ideal way to do this is on power up of the laptop which will call a script to load up the virtual machine but from a snapshot image. We would need to run virtual box in headless mode to give the training laptop a seamless desktop and approach.

Final outcome

Trainer boots up laptop with router attached to make a small local network
Script gets called to load up the training virtual machine in a vanilla mode by restoring a snapshot image
Trainer is then able to load up the virtual machine via ip on his machine or on any clients machines connected to the local network
At the end of the training session the trainer just powers off the laptop then when he/she powers it back up he/she is able to start the training session from a vanilla state



The script is shown below is actually been written as a service so we can use an upstart approach

You will need to change the VM and SNAP variables to match your environment as these are for the virtual machine name and the snapshot name.


 Set-up Instructions

Just in case your not sure how to set up the VM and script – here are some basic instructions I’ve written for work

# Simple instructions on how to install the VM and set the script up

Install Ubuntu,
Install virtualbox via Ubuntu Software Centre,
Open Terminal
Copy Realtime VM to main disk: [this will take a long time, be patient] 
Assume direct control of that folder:

Edit networking file (this is needed for our web application):

Add the following to the end of the file (only needed for my environment):

Save Changes [Ctrl+X, Shift+Y, Enter]

Open Startup Applications, add new:

Restart machine
Now you should be able to go to firefox and load up your web application via its fixed IP

Comments (2)

Leave a Comment

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>