Easily Shutdown a Windows Server 2008 Core VM in VirtualBox

I run Windows Server 2008 Core in a VirtualBox virtual machine as my Active Directory Domain Controller for a small BizTalk test environment and I’ve discovered that it doesn’t take kindly to being ‘saved’ – when the server is resumed my other servers seem to be unable to communicate with it and do AD type ‘stuff’.

Shutting the sever down seems the best way to go, but given that Server Core is the window-less version of the OS, the shutdown command needs to be issued from the command-prompt. Unfortunately, I’m lazy and can’t be bothered to log-in just to shutdown….

I’ve recently discovered that Server Core will shutdown cleanly when sent the VirtualBox shutdown signal, issued when closing the VM – to bring up the Close Virtual Machine dialog (shown below), simply close the Window the VM is running in, type [Host Key]+Q, or issue the Machine->Close menu-command:

VirtualBox - Send Shutdown Signal

Select the ‘Send the shutdown signal’ option and click Ok (the VM sometimes doesn’t respond to the first attempt, but the second attempt is usually recognised).

Windows Server 2008 Core will kindly oblige and shutdown cleanly.

Advertisements

VirtualBox 3.0: New Full-Screen Toolbar

Update: The full-screen toolbar can be moved to the top of the screen, which (IMHO) is a much more usable location. To move it to the top of the screen, open the Settings dialog for any VM, select General->Advanced and tick the Mini Toolbar: Show at Top of Screen.

It looks as though the VirtualBox Team have added a nice new feature in their 3.0 release – the full-screen toolbar!

When running a VM in full-screen mode, moving your mouse to the bottom of the screen displays the new toolbar, as shown below.

Sun VirtualBox 3.0 - Full-Screen Toolbar

All of the features available when running the VM in windowed mode are now available in full-screen mode, including: mounting devices, shared folders, shutdown options etc. The toolbar can also be pinned open if required.

For those Windows users reading this post, the toolbar behaves just like the Remote Desktop toolbar that is displayed at the top of the screen during a Terminal Services session.

This new feature is only available in the Sun VirtualBox 3.0 release and above. Download it now from VirtualBox.org.

Reblog this post [with Zemanta]

How-To: Clone or Copy a VirtualBox Virtual Disk

As a virtual machine environment user, I regularly create ‘base’ images of machines that I can reuse – a base Windows Server 2003 environment, or SQL Server 2005 environment for example. That way, when I need a new machine, I can simply create a copy of the virtual disk and add any additional software I need, saving myself valuable time creating new virtual environments.

With VMWare’s various offerings, copying a virtual disk is easy: copy the disk in Windows Explorer and add it to a newly created VM; VMWare will detect that the disk was a copy and create a new unique identifier (UUID) for the disk before adding it to the VM. Easy and painless. Not so with VirtualBox.

With VirtualBox, copying a virtual disk is a bit of a pain. If you copy the disk in Windows Explorer and try and use it in a new VM, VirtualBox will have a hissy fit and display the error shown below. A bit of a ‘wordy’ way to say that it already knows about this disk, don’t you think?

VirtualBox - Add Copied Virtual Disk - Duplicate UUID Error

The publicised way around this is to use the command-line VBoxManage CloneHd tool, however there is another – secret and undocumented – way to clone a disk: the setvdiuuid tool. Lets look at these two methods in detail.

Cloning a Virtual Disk – The ‘Supported’ Method

Cloning a disk is (IMHO) a clunky and Unix-y type way of creating a duplicate disk. We need to invoke the CloneHd command of the VBoxManage tool, supplying the disk to clone and the name of the new ‘cloned’ disk. In its simplest form, you would do something like this at the command-line:

VBoxManage clonehd "DiskToClone.vdi" "ClonedDisk.vdi"

The VBoxManage tool will chug away and clone the disk for you, creating a new UUID in the process:

virtualbox-clonehd-2

The cloned disk can now be used on a new VM without incurring the ‘I already know about this disk’ error.

Copying a Disk – The ‘Unsupported’ Method

The alternative to the CloneHd tool is an undocumented option available in VBoxManage – the setvdiuuid command. As the command help states: ‘This is a development tool and shall only be used to analyse problems. It is completely unsupported and will change in incompatible ways without warning’. Because of this, let me add a little disclaimer: I don’t accept any responsibility if you completely destroy your VM using this procedure. Having said that, it appears to work without issue, so I’m more than happy to use it myself – just make sure that you take a backup of you virtual disk before using it if necessary.

To use the tool, simply create a copy of the virtual disk’s VDI file in Windows Explorer; open the Windows command-line and issue the setvdiuuid command for the newly copied disk:

VBoxManage internalcommands setvdiuuid "CopiedDisk.vdi"

The tool will create a new UUID and assign it to the disk:

virtualbox-setvdiuuid

The new copied disk can now be used on a new VM without incurring the ‘I already know about this disk’ error.

Re-sizing a VirtualBox Virtual Disk Image File

Update 17th April 2009: This post has been updated to include the latest suggestions posted to the comments, including using the gparted Live CD instead of the Gentoo Linux System Rescue CD.

In my previous post I extolled the virtues of Sun’s desktop virtualisation software, VirtualBox. One thing niggled me though – I couldn’t easily expand a Virtual Disk Image (VDI) and was regularly reaching the space limits of the modest 20Gb disks I was creating; I needed an easy way of expanding disks before I could use it as my main virtualisation platform and felt comfortable in recommending it to my readers.

Given that there is very little information out there on how to perform this task – apart from a single obscure forum post – here is my attempt to walk you through the process of expanding a virtual disk image. This guide assumes that you are trying to expand a disk configured with Windows, however the procedure should be pretty much the same for a Linux/OpenSolaris etc. based disk.

Getting Started

  • Ensure that the Virtual Machine that uses the disk you want to re-size is shutdown.
  • Remove any snapshots you may have – VirtualBox can go a bit wonky when re-sizing a VDI with snapshots attached (thank to Darren for pointing this one out).
  • Take a backup of your VDI that you want to resize (by copying and pasting the .vdi file in Windows Explorer) – if we mess our resize up we can recover back to this backup.
  • While the VDI file is copying, download the latest stable release of the gparted Live CD ISO from Sourceforge (approx 95Mb).
  • While the ISO is downloading, create a new empty Virtual Disk in the VirtualBox console that is the size of the larger disk you need.
  • Attach the new disk to your virtual machine that needs its disk expanding as the slave disk.
  • Once the System Rescue CD download has completed, mount the ISO on the virtual machine CD drive.

Starting the Disk Image Utility

  • Boot the virtual machine from the mounted ISO – you may need to reconfigure your VM to ensure that you boot from the CD-ROM drive before the HDD, so change the VM settings as shown below or hit F12 at boot and change there (given that VirtualBox is currently under development, the screenshot below will always be out of date, but I’m sure you get the idea ;-):

virtualboxbootorder

  • During the boot process the gparted Live CD will prompt you to select the correct keymap – if you are using a QWERTY keyboard, simple select the ‘Don’t Touch Kepmap’ option; next, you will be prompted for the language settings to be used – select the appropriate language code, in my case ’02’ for British English; finally, you will be prompted for the X-Windows mode – select ‘0’ to automagically start gparted in an X-Windows session.
  • Once gparted starts, you will be presented with a graphical representation of your disks – left-click the left-to-right bar named /dev/sda1 (your primary hard disk that is to be expanded) and then click on the Copy icon.
  • Select the drop-down-box to the right of the tool-bar and select the second (currently empty) disk – /dev/sdb (possibly /dev/hdb in your environment), the graphical representation of your disks will change to show you the second slave disk which is currently empty. Click on the Paste icon.
  • gparted will will prompt you that all data on the new partition will be erased and if you’re happy, subsequently prompt you on how the disk should be formatted. For a Windows environment, select MSDOS (this will give you an NTFS partition, trust me!).
  • gparted will finally present you with a slider dialog indicating the desired size of the new disk. Drag the slider to the right to select the maximum size of the new partition on this new disk (I’d just drag it so the partition consumes the whole disk), as shown in the screenshot below:

selectsizeofnewpartitiongparted

  • Click the Apply icon, you’ll be presented with something along the lines of the screenshot below as the contents of the source disk are copied to the new, larger, disk:

  • Once the copy has completed (approx. 35 mins to create a 30Gb disk from an original 20Gb disk), you will need to mark the new disk as bootable (if this is to be a bootable partition – if not, simply skip the next step).
  • To mark the partition as bootable, right-click the graphical representation of the new disk and left-click Manage Flags. In the dialog that appears, select Boot and click Ok to close. gparted will apply the necessary flag and re-scan your disks.
  • Close gparted and click the Exit icon to shutdown the system.

Completing the Re-Sizing

  • Once the virtual machine has powered off, re-configure the hard disks to use the newly created/copied disk as the primary and remove the old primary disk from the system; finally, unmount the System Rescue ISO from the CD-ROM.
  • Power on your new VM and you should be presented with the the usual Windows boot sequence; if you are just presented with a black screen with a flashing cursor at the top left-hand corner of the screen, there isn’t a boot sector on the disk, so restart gparted and add the boot flag as directed above.
  • Hopefully, your virtual machine will start without issue. Windows may perform a check of the disk during boot. Once logged-in, open Windows Explorer and confirm that the newly created drive is the new larger size.

The procedure described above has been tested on Windows Server 2003 and works without issue (although the first time around I forgot to apply the boot flags…), so it should work seamlessly on Windows XP, Vista and Windows Server 2008.

I appreciate that this procedure does involve running a flavour of Linux to acheive the desired results, however its very straightforward and shouldn’t be off putting to a Linux novice.

Reblog this post [with Zemanta]

Sun’s VirtualBox Rocks – Beats VMWare and VirtualPC anyday

Sun xVM VirtualBoxI’m an avid user of virtual machines, primarily for development work on the desktop, but also in the Enterprise. For desktop virtualisation I’ve tried them all – Microsoft’s Virtual PC, VMWare Server and I’m now hooked on VirtualBox, Sun’s open-source offering to the gods of virtualisation. The performance is excellent, it ‘feels’ like a stable product and is actively maintained with regular releases.

For me, Virtual PC never felt stable enough and when running several VM’s at once to test clustered BizTalk installations – I could never get the desired performance. I moved to VMWare’s free VMWare Server which felt a lot more stable and ran quickly, but thrashed I/O. After reading Tim Anderson’s glowing blog post on VirtualBox a good few months ago, I decided to take the plunge and have never looked back.

Restoring a VM from a saved state and saving itself is blisteringly quick – much quicker than either VMWare or Virtual PC; the VM’s themselves are rock solid, even after being started and stopped several times during a working week and don’t cause the same I/O problems previously experienced. The admin ‘console’ is based on the Trolltech Qt tool set and although slightly different to VirtualPC and VMWare products it is intuitive annd easy to use. More importantly, VirtualBox can read VMWare disk images (and with some work, VirtualPC images), so no need to re-create all of those environments!

VirtualBox was originally developed by Innotek GmbH, but was acquired by Sun earlier in the year to form the desktop element of the company’s xVM virtualisation strategy. There doesn’t appear to be a development roadmap available on the website, but they have an excellent release cycle with regular bug and stability fixes. All in all, an excellent product that gets the seal of approval from this blogger.

If you’re interested in trying out VirtualBox, head on over to the downloads page and grab a copy of their latest release. Let me know how you get on!

Additional VirtualBox Reading on this Blog

You may be interested in reading some of my other VirtualBox related posts: