Topspin and VirtualBox

It is possible to run Topspin within VirtualBox quite easily. On my late 2013 MacBook Air I’ve installed version 4 into virtual Windows 8.1 and linux CentOs 7 and it works very nicely. In fact the CentOs version seems to do NUS processing very well; at near native speeds.

There is however some tips I’m going to pass on about management of the virtual hard disk of the Windows8.1 guest.

When I set the virtual machine up I choose to have a 128 GB dynamic disk thinking ‘that’ll be alright; probably the windows install won’t take up more than 20 GB’ And I was right; however in the years I’ve been using it; the size of the VDI file on my Mac grew to about 64GB.

My advice is; when you set up the virtual machine and install windows DON’T make the system partition fill the maximum size of the dynamically allocated space you made. Make a partition about 30 GB in size.

Here’s my little journey over the two days it took me to sort it out.

I went through update after update until there were no more updates. I hadn’t booted the virtual Windows machine for about 3 months; so this too some time.

After cleaning the temporary files (type ‘disk clean’ into the search box); going through all the options, including deleting windows update files, I got windows to report it was using about 23GB. However the size of the VDI file on my Mac remained the same.

This is a known feature of dynamic disks and the way files are deleted in the guest; deletion still leaves the information on the disk; it just removes the information on how to access it. So the VirtualBox manager has know way of knowing whats a ‘real’ file and a deleted one.

There is a command that will compact a VDI file; the algorithm it uses is (probably) :-

Scan to the last used cluster of the disk; if all the subsequent sectors have zero in them; compact the disk to the last used cluster.

The problem with Windows is that as you use it; it will scatter information across a lot of the disk. So even if you use a utility to set all unused clusters to zero (which will include previously deleted files), you still may not be able to shrink the VDI file as much as you might like.

See ‘Shrink VirtualBox VDi’ for instructions on the above. Note I found the sdelete command didn’t work the way I hoped… As it ran the size on the VDI file grew until it filled my mac. So I used the below method instead…

So, in the ‘good old days’ you could defragment your disk and compact the free space; leaving the end of your disk clear. However, with modern SSD disks; defragging is frowned upon and in fact you can’t really do it in Windows. You can ‘optimise’ but this doesn’t seem to consolidate free space.

I had to download the free version of Auslogics Disk Defrag Pro to do a basic defrag; the free version doesn’t consolidate free space however. Sigh. It did help; after running it, the last used cluster was around the 40GB mark. And by clicking on the cluster I could see it was unmovable and in C:\SystemVolumeInformation See the information in the link on how to remove this file.

I then ran the defrag pro tool again. Most of the unmovable file was now gone; however one cluster remained near the end of the disk, which looked to be used by the filesystem management itself…. So. Next bit of fiddling…

I then used the ‘Administrative Tools=>Computer Management=>Storage=>Disk Management to shrink the C: disk to about 3GB above its minimum (23GB) size. Hurrah! It worked!

I know had a disk that I knew only contained files within a 26GB boundary! So, shutdown the virtual computer, go to an OX X command line and type :-

VBoxManage modifymedium –compact /path/to/thedisk.vdi

Blast. The virtual disk size is *still* 60GB. At this point if it were a Linux guest I’d be screaming ‘FSCKing FSCK!!!!‘ I knew I had a 26GB C: disk and about 98GB on unallocated space on the Windows virtual machine. So what gives? Those deleted files must still have not had zeros written to them.

Next. Boot up Windows again; allocate the free space to a new disk; quick format it; delete the disk again; shutdown; vboxmanage… Blast it! Still 60GB!

Boot up windows; untick the ‘quickformat’ option on the disk creation/format; delete the disk when done; shutdown; vboxmanage… Hurray! Finally a VDI disk 26GB in size and now I have 36GB free on my Mac!

So. To recap.

  1. Make sure you’ve installed all the windows updates. You don’t want microsoft mucking it all up by writing stuff to your disk whilst fiddling about with it.
  2. Delete everything you can. Type ‘disk clean’ into the search box in windows; go through all the options.
  3. Defragment the drive as much as possible.
    1. Optional. Turn off the recovery options. Type ‘view advanced system settings’ into the search box, go to system protection and turn off the recovery options. Note you won’t be able to restore to an older (working) point if your windows installation goes wrong.
  4. Shrink the partition to a few GB larger than the reported used amount on the disk. Type ‘administrative tools’ into the search and choose computer management=>storage=>disk management and shrink volume.
  5. Format the remaining free space; making sure you’ve unchecked the quick format box. Delete the partition again.
  6. Use the VBoxManage modifymedium –compact /path/to/thedisk.vdi to shrink the VDI file.

If you need more space in Windows; you can use the management tools to gradually increase the size of the partition.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s