Posts tagged virtual machines

VBoxTool – An Incredibly Useful Script

Bash scripting is straight forward. There are logical and object oriented constructs like programs, and you are basically manipulating data contained in files, and using standard output to determine various tasks to be done. VBoxTool does what VBoxManage lacks. I wonder how corporations start virtual machines on boot, and manage their machines once the system is running. They clearly write their own scripts. VBoxTool is a publicly published script that does just this. I would like to extend appreciation to Mark Baaijens for the script; it is extremely useful! It completely manages my system from automating the boot process when I need to reboot the host, saving the machines when the need to be shut down, and backing them up at regular intervals with cron jobs.

http://sourceforge.net/projects/vboxtool/develop

Automatic Actions – Run or Walk Those Cron Jobs

You’d be surprised what you can accomplish when you aren’t even close to your computer. Using Rsync you can completely backup your /home directory. I back it all up, except one directory, which I handle differently.

rsync --exclude="~/.VirtualBox" /home /media/backup

I mount a usb hard drive to /media/backup. Make sure you set proper permissions:

sudo chown user:user /media/backup

Now you can rsync your home directory without the need for a sudo.

Rsync only updates files that have timestamps that are newer than the previously transferred. This makes it fast; real fast!. I backup my machine using an rsync command once a day. Open crontab:

sudo crontab -e

Add a line:

0 0 * * * rsync --exclude="~/.VirtualBox" /home /media/backup

The above will run the command every day at 12 AM. Your /home directory with be synchronized with /media/backup/home.

Then comes your virtual machines. Use Vboxtool!!!! Check out this post for more info about the tool.

Set /media/backup as the backup directory in /etc/vboxtool/vboxtool.conf. Then add the following line as a cron job.

0 1 * * * vboxtool backup WebServer

Replace WebServer with the name of your virtual machine. This cron job will run every day at 1 am.

Extended VirtualBox Management – VBoxTool

VBoxManage, the command line tool of VirtualBox, does its job. It also has its limitations. You can starts, pause, and save virtual machines, but there is no integrated way to automate various processes. To have a virtual machine boot with the host, in headless mode, you would have to create a custom init.d boot script. A great script package, call VBoxTool, coordinates the process into a terminal app. The terminal app refereneces two configuration files in your /etc directory, and utilizes an init script to boot virtual machines. VBoxTool is at sourceforge:

http://vboxtool.sourceforge.net/

Configure the machines you want to boot in:

/etc/vboxtool/machines.conf

Any machine listed in machines.conf will boot with the host. You can view running machines with:

vboxtool showrun

Then you can also view all available machines with:

vboxtool show

Maybe this wrapper script will be integrated into VBoxManage directly; it is clear the features are useful especially for system administrators.

VirtualBox Bridge and Tap no Longer Needed – Built in

With recent version of VirtualBox you no longer need to create a bridge and tap to enable host networking. In the settings panel of the virtual machine, select the network tab, and make sure that its set on bridged adapter. VirtualBox automatically creates a virtual ethernet adapter, and bridges it to the network of the host machine.

Bridging to the host network is necessary for the virtual machine to get an ip address from the router. Such a configuration is needed to communicate with the machine from the outside world. Because of this feature virtual machines can server website, and other services. I use my virtual machine to host this website, a visual ftp server, a wiki, and an EyesOS server.

There are other ways to forward individual ports from the host system to the guest, but then the ports on the host machine will not be accessible on the host; they will virtually represent the guest OS thus hindering connectivity with the host machine. There may be instances where this is what is wanted and more information, including instruction, can be found on this previous post.

The following is a screenshot of the network tab in VirtualBox. It had a bridge adapter option that will autobridge the connection to an existing ethernet adapter. Bare in mind that this is the screen from a Linux install of VirtualBox and it might be different in Windows. I remember in Windows you might have the option to create a virtual ethernet adapter, and then you can bridge the connection all in VirtualBox. Nothing needs to be done manually anymore, and everything can be done from within the VirtualBox configuration panels.

Screenshot-Windows XP - Settings

Here is a screen from Windows Vista. Go to the network tab of the virtual machine settings:

Network settings

Then select the attach to drop down menu:

Attach

Then change the attach to, drop down menu, to bridged adapter:

Bridged adapter