Xaprb

Stay curious!

Archive for the ‘VirtualBox’ tag

Making auto-resetting VirtualBox machines

with one comment

I don’t know if I’ve said this before, but I absolutely love VirtualBox. It makes it so easy to run Windows in the cases where I have to for a client’s silly Windows-only VPN software or something like that. Windows runs better inside VirtualBox than it does on bare hardware.

One of the tricks I use constantly is to set up a bunch of VirtualBox instances with a common (shared) base disk image. You can do this by creating a machine, installing your operating system on it, then throwing away the machine and keeping the resulting disk image. You can then keep this image registered inside VirtualBox, but detached from any actual machines. Then set it immutable so it never changes again:

VBoxManage modifyhd HardDisks/Windows_XP.vdi --type immutable

Substitute the name of your actual disk image file. Now you have a freshly installed Windows image on that file, which can serve as the base for lots and lots of machines. I have one set up with Service Pack 3, all the usual annoyances disabled, etc etc.

Now here comes the magic: you can create special-purpose machines that always revert to the fresh image when you boot them up. Let’s say I want an image with an annoying VPN installed. I will create a new machine, call it Windows_XP_VPN, and select the Windows_XP.vdi file as its disk image. After selecting this disk image, I juts go through all the rest of the settings, finish the wizard, and I have my machine. I boot it up, make some changes, and when I shut it down, all the changes it’s made are stored in a differencing disk image file. It doesn’t touch the base image file; any modifications are made to a copy-on-write image file.

The special characteristic of this differencing image file is that it resets on boot. If I shut down the machine and look at the image files, I’ll see one that’s oh, maybe a couple hundred megabytes. I can have lots of these images sharing the same base image file that usually ends up being multiple gigabytes, so sharing the base image file is a great way to save on disk space. But what happens when I restart this machine, is that the differencing file gets emptied first. If I boot up, save a file on the desktop, and restart, the file is gone. I’m back to the fresh image.

So this isn’t the full solution, actually, because the nasty VPN software I installed isn’t there after restart. I want it to persist. How can I do this? It’s actually pretty simple. I’ll just set the differencing image not to reset at boot:

VBoxManage modifyhd Machines/Windows_XP_VPN/Snapshots/[image file name] --autoreset false

Now this machine will store its state across reboots. However, I actually like Windows machines to reset at boot. If I don’t have them doing that, they eventually fill up with garbage. I want a clean image, with the VPN installed, and every time I start the machine I want that minty-fresh just-installed nasty VPN feeling. How can I do this? It turns out this is also not hard. Instead of turning off autoreset on the image, I just take a snapshot after shutting down. Only the most recent state (which is stored in a differencing image file) will be configured as auto-reset. Snapshots are stored in a snapshot image file that doesn’t get reset. Whatever changes I made before I took a snapshot, are persisted across reboots.

To illustrate this, let’s say I start a fresh machine from my base disk image. Then I install VPN on that, and shut down. If I reboot now, I lose my VPN. But if I take a snapshot, and call it “VPN installed” or something like that, when I restart my VPN is still there. Now I’ll make a folder and put it on the desktop, and reboot again. Presto — the folder is gone, but the VPN is still there.

It’s magic, and it’s the nicest thing ever, especially for Windows. No worries about viruses, no problems installing some junk spyware that some customer thinks is a good screen-sharing tool, whatever. I can trash the machine, shut it down, and when I reboot it, it’s spiffy clean.

And this brings me back to my original point: I love VirtualBox.

Written by Baron Schwartz

August 31st, 2011 at 9:21 am

Posted in Desktop

Tagged with ,

Recap of Southeast Linux Fest 2009

with 2 comments

Last weekend, my brother and I attended SELF 2009. A few thoughts on it:

The mixture of sessions was interesting. There were some really good ones. I think the best session I attended was an OpenSolaris/NetBeans/Glassfish/Virtualbox/ZFS session, given by a Sun employee. He was an excellent presenter, and really showed off the strengths of the technologies in a nice way. He started up enough VMs to make his OpenSolaris laptop chew into swap, and I thought it was fun to see how it dealt with that. I’ve heard Solaris and OpenSolaris do a lot better at avoiding and managing swapping than GNU/Linux, but I couldn’t make any opinion from watching. I did think it was odd to have this session at a “Linux” (yes, they left off the GNU) conference. But I thought the session was a good addition to the conference. In other sessions, and in the hallways and expo, there was a lot more slant towards open-source software and gadgetry in general than there was towards GNU/Linux. The sessions that were about Linux or GNU/Linux were top-heavy towards topics like educational initiatives.

The Free Software Foundation had a booth in the expo hall. It was funny that they didn’t boycott the event, because I know RMS won’t speak at so-called “Linux User Groups” and insists they be called “GNU/Linux User Groups.” I guess the FSF is not unified behind that banner. Regardless, I used the opportunity to renew my membership perpetually. I’m so lazy that I need something like this to stay involved!

The expo hall was dominated by Red Hat, Fedora, and SUSE; PostgreSQL was there, but not MySQL. There was a good variety and number of vendors. It was great to see the healthy support of the event, which was free, by the way.

Clemson, SC is not easy to get to, and while the Clemson campus was attractive and functioned fine, it’s nothing you can’t find elsewhere. I ended up driving over 9 hours to get to it. I’d have preferred the technology triangle, which if nothing else is close to major airports, bus and train stops, and Red Hat.

Richard Hipp talked about the great fsync() bug, a similar talk to the one he gave at the first OpenSQL Camp. Someone asked about Tokyo Cabinet and he responded that he hasn’t found any fsync() calls in its source code. *cough* Something worth thinking about for on-disk usage (I haven’t looked at its source much myself). TC can also be used in-memory-only, and a while back I suggested that usage of it for Drizzle to replace the Memory engine; I don’t know what became of that.

Written by Baron Schwartz

June 21st, 2009 at 9:48 am

How to set up host interface networking for VirtualBox on Ubuntu

with 12 comments

VirtualBox is really nice, but if you’re like me, maybe you found the networking confusing. There are three ways to do it, as explained by the manual, and the best way is with host interfaces, which don’t have limitations like the inability to ping and so on. I found what I think is a pretty good way to set up host interface networking.

Read the rest of this entry »

Written by Baron Schwartz

November 5th, 2008 at 11:26 pm