Tuesday, December 13, 2011

Manually merging shapshots in differencing VHDs using Diskpart

Yesterday I had to move a stopped VM off a Hyper-V server that had run out of disk space. The server had 2 ongoing snapshots dating back to 2009. The snapshots had to be merged before I could restart the server and it wasn't immediately obvious how to do it.

Eventually I rediscovered DiskPart which is a frontend to the Logical Disk Manager in Windows. I'd used this before for special partition trickery on USB keys: in 7 and 2008 Server this includes vdisk (VHD) functionality as well.

To merge the snapshots first I Selected the last snapshot in the chain, then told DiskPart to merge with the parent. Differencing VHDs store a relative and an absolute path to their parent, so the disk structure needs to be approximately the same:

DISKPART> select vdisk file=d:\vm\SERVERNAME\Snapshots\3209A29B-8693-45CC-A9E4-444A9CE3B245\\3209A29B-8693-45CC-A9E4-444A9CE3B245.avhd
DISKPART> merge vdisk depth=2

I used depth=2 because there were two snapshots in my chain. It took a while for the merge to complete during which the file size on the parent VHD was incrementing, and then a little longer for the disk management service to release its lock on the files, but after that I was able to delete the snapshot files and boot the VHDs in a new VM on the new server.

Monday, July 25, 2011

Updating BIOS from USB using a multi image set

I just had to update an IBM ServeRAID bios using the boot floppy set as there was no .iso provided. There were 4 floppy images.

First I had to merge the 4 images into one, but they would never fit on a single floppy image. So I made a custom image using this method:

1. Open Image 1 in WinImage
2. Image -> Change Format
3. select Custom Format
4. Total number of sectors: 11520

This gave me an image with 6mb of space. Then I was able to extract the other three images and Inject their contents into the root directory of the first.

To boot the new image, I extracted memdisk from the syslinux distribution onto my usb key. I then booted from grub2 using the following:

grub2> linux16 /boot/memdisk
grub2> initrd16 /iso/ibm-firmware.ima
grub2> boot

The firmware upgrade then went without a hitch.

Monday, June 13, 2011

BackTrack USB guide updated

Backtrack 5 still (inexplicably) doesn't posess the iso-scan magic necessary to make a multi boot usb key.

I've updated my guide here.

Tuesday, May 10, 2011

Simple rate limit on Juniper SRX

Here's how to apply a simple rate limit to an interface on JunOS 10.2 (SRX):

root@labsrx# show interfaces ge-0/0/1
unit 0 {
    family inet {
        filter {
            input download-limit;
            output upload-limit;
        dhcp {
            client-identifier ascii labsrx;

root@labsrx# show firewall
policer rate-limit {
    if-exceeding {
        bandwidth-limit 10m;
        burst-size-limit 1m;
    then discard;
filter upload-limit {
    term limit-up {
        from {
            source-address {
        then policer rate-limit;

    term accept_all {
        then accept;
filter download-limit {
    term limit-down {
        from {
            destination-address {
        then policer rate-limit;

    term accept_all {
        then accept;

Sunday, January 23, 2011

Android: Rebind camera button to a menu with Tasker

I got an HTC Desire Z last month and I'm loving it. It's replacing my computer more and more. You can read my page of notes I've collected on it here.

I've got Cyanogenmod running and my one complaint is that the camera button only launches the Camera app and there is no way to rebind it.

Or is there? I have the excellent Tasker app and figured out how to get it to pop a menu when the button is pressed! Here's how:

1. Create a new Profile in Tasker (mine is called Camera)
2. Select Event: Hardware: Camera Button as first context and tick Stop Event. This will stop the system
from launching the Camera app at the same time.
3. Create a new task and under its properties, change the task type from Execute to Menu.
4. Add new actions for each app you want to launch (I have camera, barcode scanner and torch)
5. Apply and enable the profile.

That's it! Enjoy :)

Wednesday, January 12, 2011

Exchange 2k10 SP1 DAG Reseed

Recently I had an issue where my DAG got out of sync. First the CQL was up past 9800 and increasing.
I misguidedly deleted the log files and the CQL shot up to 187k! But at least it was going down.

After a day, the CQL had only dropped to 175k so I knew I had to reseed. Fortunately the datacenter is only a brisk walk away.

I set up Windows Server Backup to take a full snapshot of the good exchange server. This ran overnight and in the morning I brought the disk in. I removed my failed database copy and renamed its folders on the database disk. Then I mounted the VHD off the usb disk from the other server, copied the database and log directories, and remounted the database copy using this command:

Add-MailboxDatabaseCopy -Identity "Primary Mailbox Store" -MailboxServer SVR15 -SeedingPostpone

At this point I got the error: 

Registry key has subkeys and recursive removes are not supported by this method.

The fix for this was to get the GUID by:

get-mailboxdatabase "primary mailbox store" |fl name,GUID

I navigated to HKLM\Software\Microsoft\ExchangeServer\v14\Replay\State and deleted the guid's key, then retried the add-mailboxdatabasecopy command above.
It worked, but didnt show up in the System Manager immediately. I waited a bit, restarted the System Manager and my repaired database copy was there with a CQL of 967 and going down fast! Job done, beer time.