Resizing vmdk harddisks for VirtualBox

VirtualBox is a free tool, which allows you to run virtual machines on a host computer. Using VirtualBox you can install Linux, Windows and other operating systems to play and experiment with.

Start the process by closing virtualbox (I usually also dettach the virtual harddisk due to be resized).
Go on to a shell and find the directory where the virual machines are located.

If your initial harddisk was cloened from another virtualbox, you may get an error like this:

VBoxManage: error: Cannot register the hard disk 'disk01.vmdk' {eaed1256-a34f-4c2f-873b-62cc78c4be80} because a hard disk 'disk01.vmdk' with UUID {eeed1256-a32f-4c1f-813a-62dd78c4be80} already exists
VBoxManage: error: Details: code NS_ERROR_INVALID_ARG (0x80070057), component VirtualBox, interface IVirtualBox, callee nsISupports
VBoxManage: error: Context: "OpenMedium(Bstr(pszFilenameOrUuid).raw(), enmDevType, enmAccessMode, fForceNewUuidOnOpen, pMedium.asOutParam())" at line 178 of file VBoxManageDisk.cpp

To fix this issue pop into a terminal and enter this command:

vboxmanage internalcommands sethduuid ./disk01.vmdk

This command changes the HD uuid from the disk and ought to fix the issue.

Ready to resize

Next challenge is that the disk is in vmdk format, so to resize we need to convert the disk to VDI format, resize and convert back to vmdk format:

vboxmanage clonehd ./disk01.vmdk clone.vdi --format vdi
VBoxManage modifyhd ./clone.vdi --resize 30720
vboxmanage clonehd ./clone.vdi ./disk01.vmdk --format vmdk

The “virtual physical drive” is now resized, but the partion on the harddisk also need to be resized.

Boot up the virutal box (and make sure the disk is attached if you’ve dettached it during the conversion and resizing).

  • In Linux you can do this through using Gparted.
  • In Windows go to Computer Management (by right clicking “My Computer” and find “Storeage” -> “Disk Manangement”.

Change the partition on the drive need to be expaned and save the changes. The drive should now be resized and ready to be used.

ftp on OSX Lion

While it really isn’t secure at any measure, ftp is a very useful way of moving files around. Apple’s OSX have a build-in basic ftp server, but in Lion (version 10.7) the user interface seems to have disappeared from the User interface. The servers is still available under the hood if you need it.

To enable the ftp-server (the availability) enter this command in a terminal window:

sudo launchctl load -w /System/Library/LaunchDaemons/ftp.plist

From then on use this command to enable the ftp-server:

sudo launchctl start com.apple.ftpd

and youse this command to stop the ftp-server:

sudo launchctl stop com.apple.ftpd

To remove (the availability) of the ftp-server issue this command:

sudo launchctl unload /System/Library/LaunchDaemons/ftp.plist
  • If you need the ftp-server from time to time, you should probably not remove it, but just stop it, when it’s not being used.
  • If you often need an ftp-server you should probably look at a more full-featured ftp-server (such as pure ftpd).