Shrinking VirtualBox Disk Images

On my MacBook Pro with minimal disk size (250GB) I had to install VirtualBox in order to run any kind of Windows, for emergency cases. I was able to install Windows Server 2008 in a 20GB dynamically expanding virtual disk image (VDI).

A couple of months back I also made a clone of my HP NX9010 hard disk, a Seagate Momentus 80GB drive using the dd utility and attach it to the same virtual machine. I don’t have a lot of time at hand so this will enable me to selectively back up the files on that drive, when I have some free time. I use that old laptop to play videos for my child.

After some time, the Windows Server 2008 VDI grew up to 11GB and the Momentus VDI stayed at 74GB because dd was copying it bit by bit. I needed to free up more space. My target was the Momentus VDI because it’s huge and I have already deleted (backed up) a lot of files in it.

As their name suggest, they are dynamically expanding so they will not shrink themselves. In VMware, you can easily stumble upon the “shrink” button in the tool. In VirtualBox, we need to use the command line utility VBoxManage.

It’s as simple as:

VBoxManage modifyhd Seagate\ Momentus\ 80GB.vdi --compact

*VBoxManage is run on the host machine, while the virtual machine is powered off (not suspended).

Running it without any preparation work will shrink the VDI a bit, too insignificant to even notice.

And so I used SDelete to zero all the unused space on the VDI, and ran VBoxManage again. SDelete needs to be run inside the virtual machine while it’s running.

sdelete -c d:

I managed to get the 74GB VDI to shrink to 23GB. Now that’s a significant reduction in size.

Still, I was greedy. I wanted to know whether fragmentation has any effect on the shrink-ability of the VDI. So I went into the virtual machine, ran defrag, ran sdelete, then I executed VBoxManage to compact the VDI.

Below was my final result. From 74GB to 5.1GB I was fully satisfied. I was also able to shrink the 11GB VDI that contains the OS to 9.7GB.

If you have questions/suggestions/feedback, please leave a comment.

Selangor No Plastic Bag Every Saturday

Since January 2010, the state of Selangor where I live imposed a new campaign where no plastic bags will be provided in retail transactions. Note that it’s a campaign and not a law.

While I am in agreement that we need to do something about the pollution and improving the environment, I think this campaign hasn’t been properly thought of.

Retailers everywhere are now taking this campaign into their own benefit. They will save a significant amount of cost in plastic bags. How can we be sure that the money will indeed go to the Corporate Social Responsibility program? A lot of retailers don’t even include the purchase of plastic bags into the receipt. How do they keep track?

Note that Malaysia is a developing country, with undeveloped minds. Some retailers are blindly following this campaign without any use of the brain.

The latest complaint I have is at Papier Love, a local craft retailer at The Curve Damansara. They sell fragile paper products, and they refused to provide any plastic cover. They don’t sell them either. If you know arts and crafts well enough you will know that scrapbook papers are thin and very fragile you can’t even put them in plastic bags. They must be inserted into special plastic cover or sleeves to protect them from being crumpled. In this case the salesgirl cum the cashier didn’t use her brain well and it caused dissatisfaction.

We will never step our foot into that shop again and we will make sure friends won’t too. The brainless girl also looked down at customers when she was repeatedly saying that the piece of paper costs RM8 per piece as if it’s too expensive. My poor wife who is also a craft enthusiast didn’t say anything but that’s the power of assumption from someone who is not good enough to work in retail. We spend an approximate cost of RM1,000 per year for craft products and they will not get any part of that.

For the record, our favorite arts and craft stores are Art Friend in The Gardens Mid Valley and Craft Haven in One Utama Damansara. The staff are always helpful and friendly with a smile (and lots of details). I am not into art and I know nothing but they have never once alienated me and I always feel welcome when I enter their stores.

Another brainless no plastic bag event is at Famous Amos in Amcorp Mall. I was struggling with holding my child (who wanted the cookies in the first place) and when I asked for a plastic bag, the Bangladeshi refused to give me one. That’s one inconsiderate staff there.

What about IKEA?

Hey, IKEA has been imposing no plastic bag so much earlier than the campaign. Nobody really made a fuss about it because IKEA has though of it well enough. They provide good parking with spacious loading area, and the enormous shopping carts can be pushed to the loading area. Plus, their products are big and you can actually hold them without the need of bags. Some products can’t even be put in plastic bags because they are huge.

So, IKEA’s fine.

All images are copyright of the Government of Selangor. If you want them removed, email me.