Change a VirtualBox dynamic disk size on MacOS

When creating a dynamic disk VirtualBox asks you to specify the maximum size. If the max dynamic disk size needs changing after its initial creation we cannot use the VirtualBox interface, instead we need the VBoxManage command line tool.

1. Shutdown the VM and quit VirtualBox
2. Open the Terminal app and use the following command to navigate to the VirtualBox app directory
cd /Applications/
3. Now in the proper directory, you’re ready to run the resize command with the following syntax:
VBoxManage modifyhd –resize [new size in MB] [/path/to/vdi]
VBoxManage modifyhd –resize 30000 ~/Documents/VM/Windows10.vdi
4. If desired, verify the change has taken place with the showhdinfo command:
5. Launch VirtualBox and boot renewly resized VM

Reclaiming space from VirtualBox on MacOS

Dynamic disks tend to be the preferred choice for virtual disk images as they only use the physic disk space they need. However while VirtualBox is a very good free virtual machine application, the dynamic disks are much better expanding than shrinking. While commercial tools such as VMWare and Parallels have a one click/automatic way to reclaim physical disk space, VirtualBox needs a little manual intervention.

The following steps will give you some physical disk space back, its a good idea to run these after a major service pack install or after removing a large application from your virtual machine. Steps 1-5 is recommend regardless of which VM application you are running as this frees space on the virtual machine.

1. Delete unwanted files
2. Run Windows Clean Up, use the advanced option to remove windows update files.
3. Empty Recycle Bin
4. Defrag
5. Clean garbage bits and bytes using SDelete by Windows Sysinternals, after installation open cmd and type

sdelete.exe C: -z

6. Shutdown Windows VM and close VirtualBox
7. Open Terminal app and enter

cd /Applications/

8. Then enter

VBoxManage modifyhd –compact “[/path/to/vdi]”

How to reset NVRAM on your Mac

Shut down your Mac, then turn it on and immediately hold down these four keys together:

Option, Command, P, and R.

Keep holding the keys for about 20 seconds, during which your Mac might appear to restart. (If you have a Mac that plays a startup sound when you turn it on, you can release the keys after the second startup sound.)

View hidden files and folders in OS X Finder

The following will display all hidden files and folders in Finder

  1. Open Terminal found in Finder > Applications > Utilities.
  2. In Terminal, paste the following: defaults write AppleShowAllFiles YES.
  3. Press return.
  4. Hold the ‘Option/alt’ key, then right click on the Finder icon in the dock and click Relaunch.

To reverse, repeat the above but substitute YES for NO at the end of the Terminal command.

OSX Instant Lock Screen

When leaving your Mac for a short time its a good idea to lock the machine.

To do this, first launch System Preferences and select Privacy and Security. Under the General tab select Require password immediately, close System Preferences. The following shortcuts will lock your machine.

Control+Shift+Eject is the keystroke for Macs with an Eject key, and for external keyboards.

Control+Shift+Power is the keystroke for Macs without the eject key, like the MacBook Air and MacBook Pro Retina.

Creating Symbolic Links OSX

The basic syntax for creating a symbolic link (or soft link) is as follows:

ln -s /path/to/original/ /path/to/link

For example, to create a symbolic link for the user Downloads folder which links it to a directory on a separate mounted drive, syntax may look like the following:

ln -s /Volumes/Storage/Downloads/ ~/Downloads/

That will link the active users ~/Downloads/ folder to a directory named “Downloads” on the mounted drive called “Storage”. If such a directory and drive existed, this would basically allow all files that would typically appear in the user downloads folder to go to the other mounted volume instead, essentially offloading the storage burden to that separate drive, while still preserving the appearance of a ~/Downloads/ folder for the user. As mentioned before, this behaves much like an alias.

Re-download OSX Lion

With the release of OSX Mountain Lion, Lion has been removed from the App Store. However if you’ve already purchased Lion it’s possible to download it again. Holding the option key while clicking Purchases in the App Store will make Lion reappear in the list.

How to check your Mac will run Mountain Lion

Apple have published details on which Macs can run Mountain Lion. However it is not always clear if your machine falls in to the specified categories. The following instructions allow you to run simple tests to check for comparability.

1. Open the About This Mac dialog from the main Apple menu and then click the More Info button to view the stats about your machine, including the model type. Also, look for Intel GMA 950 in the Graphics field. If present, then unfortunately your system is unable to run Mountain Lion.

2. The second way to confirm Mountain Lion compatibility is to click the System Report button and select the Software option. If the 64-bit Kernel and Extensions field reads “No,” your machine will not run Mountain Lion.

Finally, if you like the command line, run this command in Terminal:
ioreg -l -p IODeviceTree | grep firmware-abi

If the returned line says, “firmware-abi” =, you are out of luck – onlymachines will be Mountain Lion-ready.

Splitting DMG files into smaller segments

There are a number of tools which can split files, some free some not. However the versions I have tried seem rather hit or miss. Most people don’t relise that OSX can split DMG files without any 3rd party applications. You do however need to use Terminal (Applications > Utilities > Terminal) rather than an a pretty GUI.

The tool in question is called hdiutil, this allows you to attach, detach (eject), verify, mount, unmount and segment plus much more. Typing hdiutil help in to Terminal will display a help guide which is worth a look.

To segment a DMG file enter the following:

hdiutil segment -o mysplitimage -segmentSize 100M /Users/[your Mac username]/Desktop/myimage.dmg

This will create segments (mysplitimage.002.dmgpart, mysplitimage.003.dmgpart, etc.) in your Home folder of an image named myimage.dmg on your desktop.

-o specifies the name of the segments

100M specifies the segment size (K and KB can also be used)

It is also possible to specify the number of segments rather than size. Just replace -segmentSize with -segmentCount followed by the number.

It is not neccessary to rejoin the segments. Clicking the the first segment will mount the DMG in the same way as before the split.