OS X Understanding & Enabling SSD Trim Support December 31st, 2011
Over the past few years, our understanding of SSD technology has advanced significantly. In theory, SSDs are a massive improvement over conventional spindle drives with no major weakness to speak of. No longer does your computer have to wait for a motor powered platter to rotate into the correct position every time you want to access a piece of data; it can now grab it instantly from a bank of memory cells inside the SSD. As well as this dramatic increase in performance gone is the noise, the heat, and importantly the power consumption, and in its place smooth, silent, virtually instant data transfer.
Well, that’s the theory anyhow.
The reality is that whilst a lot of the above is true, an SSD is not immune to problems like any other hard drive; one of the biggest of these problems is the way in which SSDs handle deleted data and the way this causes overall performance to tail off after continual use.
First, we need to understand the problem.
SSDs are split into multiple cells. Imagine for a moment a brand new SSD with a clean 20kb cell, the drive writes two 10kb files into this space at its full write speed, so far so good. Later, you delete one of these 10kb files as it is no longer required. The SSD will now simply mark the unwanted 10kb space as an area that is available to be rewritten, this is exactly the same behaviour you’d expect from a conventional spindle drive; the important point to note here is that neither the SSD nor the conventional spindle drive actually deletes the physical data. The difference comes when you need to right new data into the 10kb space.
The conventional spindle drive will simply write over the 10kb of space when the new data comes along however when the SSD comes to rewrite data to the 10kb of free space in the now dirty cell – in order retain the 10kb file still there – it must first read that data to its controller, wipe the whole 20kb cell clean and then rewrite the complete set of valid data, old and new, into the cell. Over time, this continual rewrite process has very little impact on the performance of a conventional spindle drive however the read-modify-write process employed by the SSD will drastically reduce performance on the SSD in comparison to writing data to new, clean cells. This behaviour is the main cause of SSD performance degradation over a period of time, especially for heavy users accessing data daily.
Ironically, for a device which can, at least in theory, address any given cell at the same speed, SSDs can also become subject to fragmentation as a side effect to dirty NAND. Having numerous cells filled with deleted data means the drive needs to perform more and more read-modify-write cycles when writing files to the drive which over time causes yet more performance degradation. A heavily fragmented SSD will also have no choice but to spread files over even more cells, forcing the drive to address all those cells too when reading data; this of course has the effect of reducing the overall read performance of the SSD as well as the write performance.
SSD manufacturers are aware of these issues of course and there is a fix by way of the TRIM command. TRIM reorganises written data on the SSD and scrubs deleted data as soon as it has been deleted (this is triggered by a delete command, clearing the recycle bin or, reformatting the drive). This means that when the drive needs to write data to that cell again, there is nothing but clean NAND waiting negating the need to perform the read-modify-write process, therefore ensuring the optimum write performance is maintained and does not degrade with use. However, in order for TRIM to work, support is required not only within the SSDs firmware but also the host OS. Windows 7 shipped with TRIM support out of the box and I can say from personal experience, it makes a huge difference. The problem with OS X is that TRIM support is very limited.
TRIM is officially supported in OS X 10.6.8 or greater, but is limited by the fact that it only supports Apple branded SSDs.
Take a look at About This Mac>More Info>Serial-ATA and you’ll notice unless you’re running an Apple SSD the TRIM support flag is set to ‘No’. It seems a deliberate oversight on Apple’s part, no doubt to try and convince you to buy their own branded drives (which by the way you should never do, they are way over-priced and old technology) but as always there is a way to enable TRIM for other manufacturers SSDs. To enable TRIM support, simply download an app called TRIM Enabler which works by loading a kernel extension from MacBook Pro 2011 models (with TRIM support) into your Mac OS X kernel, this forces TRIM to be enabled; all you have to do is download and mount the DMG file and click on Patch. Simples!
Caveat: This is completely unsupported software and is not endorsed by Apple. I am not responsible for any damage or data loss that may result from enabling TRIM. Always have a backup of your data and proceed carefully at your own risk. If you decide to download the above patch and enable TRIM, you do so of your own choice.
Notes: I have tested TRIM Enabler on my MacBook Pro (early 2011) i5 running OS X 10.6.8 Snow Leopard without issue. After a reboot, the TRIM support flag changes to ‘Yes’ and the system runs normally without any issues, it’s too early to tell if having TRIM enabled will keep my read/write speeds consistant but I will run some benchmarks and report back at a later date with a comparison.
I hope this may be of use to someone, please feel free to share your experiences in the comment box below.
Posted in Apple, Blah, Lion, Mac OS X, MacBook Pro i5, Snow Leopard, Technology Related | 1 Comment »
Changing Default Resolution In Mac OS X Virtual Machine October 15th, 2010
As an update to my previous post explaining how to install OS X within Windows 7 using VirtualBox, I have now found a simple way of changing the default screen resolution to match your individual needs; it’s actually quite simple:
- Start your OS X virtual machine
- Navigate through Go>Computer>Macintosh HD and then navigate to /Library/Preferences/SystemConfiguration
- Right click com.apple.Boot.plist and click Open With and then TextEdit
- Add the following code underneath <string></string>
<key>Graphics</key>
<string>1280x1024x32</string>
(change the above line to suit your needs) - Click File and then Save As..
- In the Save As box, overtype to ensure it says the following:
com.apple.Boot.plist
and change the location to your Desktop. Also, uncheck the checkbox next to If no extension is provided, use “.txt” - Click Save
- Close the TextEdit window
- Now, drag the file that you have just saved to your desktop into the SystemConfiguration folder that should still be open
- Click Authenticate
- Click Replace
- You will now need to enter your password, do this and the file will then be replaced
- Close the SystemConfiguration window
- In the VirtualBox console, click Machine and then Reset
When OS X restarts, you will now have your desired resolution!
Posted in Apple, Blah, Mac OS X, Technology Related, VirtualBox | 1 Comment »
Installing Mac OS X Snow Leopard In Windows 7 October 15th, 2010
Some time ago I wrote an article detailing how to install Ubuntu (or any other Linux distribution) on a Windows 7 machine using VirtualBox. Since writing the article, I have received numerous emails asking for a similar guide to enable people to install OS X in the same way, well I am always open to requests if there is sufficient demand; not only that but having a localised installation of OS X would be a useful tool for me also to test out various methods when writing other guides. So with need established, I set about experimenting with various different configurations to get a working installation of OS X within Windows.
Caveat: At this stage I would like to point out that whilst technically possible, under the Apple EULA it is not permitted to run an Apple desktop OS within a virtual environment; as such this guide is for informational purposes only. If you choose to follow this guide and install Mac OS X within a virtual environment, you do so at your own risk, I will not be held accountable for breaching the EULA. In this guide you will need an official Mac OS X installation disc (well, an .iso of the original disc) so in the spirit of the EULA and to make you think twice, I will not be sharing a file for download or publishing a download link; you’ll need to figure this out for yourselves. Personally I own an official retail Snow Leopard installation DVD which I used as a base for this guide.
The problem with OS X is that it has been designed to run with very specific hardware, unlike the Windows family of operating systems which are expected to run with almost every hardware combination imaginable. There are those that will tell you OS X is far more stable than any Windows installation; but the reality is that Apple products are designed to run on very specific hardware and as such, have been thoroughly tested. This is a luxury that Windows developers do not have, it’s nigh on impossible to test every combination of hardware components that the Windows platform is expected to work with; there are simply too many possible combinations.
Here lies the problem.
Even within a virtual environment, the hardware that is emulated is far more akin to working with Windows or Linux (still UNIX based but far more forgiving than OS X in its hardware compatibility requirements). All is not lost however; ever since being told that it was not possible there has been a group of talented developers who have gone about reverse engineering and hacking OS X to work with PC hardware. The result of this hard work is ‘Hackintosh’, or OS X that has been modified to run on a standard PC platform.
Prerequisites: Before starting the guide, please read this post in its entirety; it’s important to understand all of the steps before starting to ensure you do not run into any problems. You’ll also need to download and/or check the following:
- Download and install the latest version of VirtualBox if you do not already have it installed on your machine already; the latest version can be found here. If you are running an earlier version (or one of the Sun versions, VirtualBox is now branded Oracle) it would be wise to update
- You will need to dig out your original Snow Leopard installation DVD and create an .iso image of the disc locally on your machine.
- You’ll also need a special modified Bootloader to enable you to boot into the OS X installation; this can be downloaded from here.
- This stage is purely optional but I find it helps a great deal. Once VirtualBox has installed it will create the following folder c:Users$USERNAME.VirtualBox so, create a new folder called ‘Source ISO’ within it and copy both the Snow Leopard DVD image and the extracted images from the file you downloaded in step 3. It’s good to get into the habit of filing files in an organised manner, I’ll also be referring to this file location throughout the guide so if you choose not to create this folder, you will need to modify the guide accordingly
- Finally you need to ensure that your machine supports hardware virtualisation; most modern machines do. Curiously though (especially within laptops) some manufacturers decide to disable this feature by default within the BIOS. If you are in any way unsure, reboot into your BIOS to check this before continuing with the guide
At this stage I would normally continue straight into the guide, however owing to the vast number of possible hardware combinations available, I thought it would be beneficial to list the hardware capabilities of my machine – the machine I am using to test and produce this guide – to show you a known working configuration as a base line; it’s worth mentioning that this is not the latest and greatest hardware, but a good all round performer from a few years ago. The basic specification is as follows:
- Lenovo ThinkPad T61p
- Intel Core2Duo T7700 GHz (VT Enabled, 64-Bit Architecture)
- 3Gb RAM
- 256Mb NVidia Quadro FX570M discrete graphics
- Windows 7 32-Bit host operating system
Now, onto the guide itself, I have split the guide up into stages to make it more manageable. Simply follow each stage step by step and you will have a working installation of OS X at the end.
The first stage is to create the initial virtual machine configuration file:
- Open VirtualBox by clicking through Start>All Programs>Oracle VM VirtualBox>VirtualBox
- Create a new virtual machine by clicking on the New button at the top left of the screen
- You’ll be greeted with the Create New Virtual Machine wizard, click Next
- Name the virtual machine that you’re creating based on your own naming conventions, for simplicity I am going to choose the name Mac OS X; for operating system choose Max OS X in the drop down box and then Mac OS X Server in the Version drop down box. Then click Next
- You now need to configure the amount of memory that you are going to allocate to the new virtual machine, if your machine supports it (or, if you have at least 2Gb of RAM available on the host machine) slide the slider to the maximum available (1500Mb or 1.5Gb) and then click Next
- Next to configure the new virtual HDD, you can leave the default options checked and click Next. You’ll now be shown the Welcome to the Create New Virtual Disk Wizard, click Next once again
- Now you need to configure the type of virtual disk that you want to create, unless you have good reason to choose otherwise, I recommend that you leave the default option of Dynamically expanding storage selected and click Next; then, once again leave the default options selected (you should see the size pre-populated to 20Gb) and click Next followed by Finish to create the disk
- You should now see a summary screen, click Finish
The basic virtual machine will now be created, albeit without the actual installation of OS X – yet. The next stage is to make some configuration changes to the basic virtual machine before proceeding with the actual installation process in preparation for the install:
- Highlight the virtual machine that you have just created (in my case named Mac OS X) and click the Settings button
- Click Display and change the Video Memory option to its maximum and click the Enable 3D Acceleration box
- Click Storage and highlight Mac OX S.vdi then click the remove button (-), then click the Empty option and under CD/DVD Device, navigate to the .iso image that you saved in your .VirtualBoxSource ISO folder earlier (legacyempire_efi1085.iso) then click Select
- Click the add button (+) and choose Add SATA Controller then click the add button (+) next to the new controller, you should now see Mac OS X.vdi appear in the list of SATA devices; highlight this. Finally in the drop down box next to Hard Disk choose Mac OS X.vdi (Normal, 2 which should clear the exclamation mark
- Click System and then Processor and change the default option to 2, then click Motherboard and uncheck the Enable EFI (special OSes only) option. Next under Boot Order, uncheck Network and Floppy if selected and change the boot order so that CD/DVD-ROM is checked first, followed by Hard Disk. Click OK
- Click Start to power on the new virtual machine
- When the Empire EFI Bootloader screen appears right click on the CD/DVD icon in the bottom right of the screen and click Unmount CD/DVD Device. Right click the icon again and click More CD/DVD Images and navigate to the .iso image of your retail Snow Leopard installation disk in the Source ISO folder, then click Select
- Wait a few seconds then click inside the virtual window and hit the F5 key, you should notice the option on the screen now change to Mac OS X Install DVD, press the Enter key. After a few seconds, you’ll be asked to press the Enter key again
The actual installation of OS X will now begin:
- The first screen that you will see will ask you to choose the language that you wish to configure the OS with, select this and then click the Forward key (this is the round blue icon towards the bottom right of the screen with an arrow in)
- At the next screen, you’ll need to ensure that the virtual HDD is correctly setup and ready for use, click Utilities at the top of the screen followed by Disk Utility
- Highlight the virtual disk, in my case 21.47 GB VBOX HARDDI… and click Erase. Ensure the Format option is set to Mac OS Extended (Journaled) and name the disk Macintosh HD then click Erase. You’ll be asked to confirm your actions, click Erase once again. Once the utility has created your disk, click the Exit button (which is the small red circle in the top left of the screen)
- Click Continue and agree the terms of the EULA (Please read the caveat above)
- Click Macintosh HD as the installation location and then finally click Install to begin
- Once the installation has finished (this will take some time, certainly enough time for a coffee), you will get an error screen saying that the Install has failed but don’t panic, this is normal
- Click the ‘x’ in the top right corner to close the virtual machine and select Power off the machine followed by OK
- Highlight Mac OS X once again and click Settings
- Click Storage and then Snow Leopard 10.6.3.retai.iso; then next to CD/DVD Device change the location to point to legacyempire_efi1085.iso once again. Click OK
- Start the virtual machine by clicking the Start icon
- Once the Empire EFI boot screen loads, click inside the virtual window and press the right arrow key to highlight Macintosh HD and then press Enter
- OS X should now start to load
This initial load up may take a few minutes but you should shortly be greeted with the Welcome screen where you can set up the basic options including your Apple log in, needless to say you should change these following steps based on your own individual circumstances:
- On the Welcome screen, click United Kingdom and then click Continue
- Next you’ll be asked to choose a default keyboard layout, click British and then click Continue
- Presumably, as you are running this within a virtual machine you will not have another Mac that you wish to transfer information in from so at the next screen, choose Do not transfer my information now and then click Continue
- You’ll now be asked to enter your Apple ID, if you do not have one you can simply click Continue and will have the opportunity at a later time to set one up. If you use iTunes on your windows PC, the login you use for the iTunes Store will also double as your Apple ID so enter these details here and then click Continue (hint: at this stage your keyboard will still be in the default US configuration so to enter ‘@’, press shift+2)
- Next you will have the option of setting all of your personal information, if you entered an account in the above step this will already be partially populated, fill in the appropriate details and click Continue
- You will now need to enter you’re your chosen username for the installation, enter these details and click Continue and your new account will be created
- Now chose your time zone, this should already be selected to the correct option. Once you are satisfied click Continue
- Click Go
- The OS X desktop will now load up
In its current configuration, the Empire EFI .iso needs to be attached and connected during each boot of the virtual machine or else it will not load, so the next step is to address this and install the boot loader permanently onto the OS X local hard disc. Doing this will install the Chameleon boot loader and also, some other important drivers and fixes:
- Inside the virtual machine on the OS X desktop you should see the Legacy Empire EFI disc mounted, click this and in the folder that opens, open the Post-Installation folder
- Now, before doing anything else you should take a backup of what you have done so far; within VirtualBox this is known as a snapshot. Click Machine and then Take snapshot, choose a name and click OK; then back to OS X
- Double click the myHack installer package (for Star Wars fans, it’s the Storm trooper icon) and then Continue once the application installer opens
- Click Continue twice and then Agree
- Once again, highlight the Macintosh HD as the destination for the installer and then click Continue
- Click Install
- You’ll now be asked to enter your password, this is the one that you configured earlier when setting up your local account, enter the password and then click OK. The install will now take place although it does take a little while (fantastic, time for another coffee then), once finished click Close
- Click Machine and then Close and chose the Power off the machine option then click OK
- Now you can remove the attached Empire EFI .iso from the virtual machine as it is no longer required. Click Settings followed by Storage. Highlight legacyempire_efi1085.iso and next to CD/DVD Device select your host drive (in my case Host Drive ‘D’)
- Click OK
Finally, you need to install an appropriate sound driver that is compatible with box VirtualBox and Mac OS X as this will not have been configured during the installation:
- Start OS X once again by pressing the Start button and wait for the OS X desktop to appear
- Open Safari within Mac OS X and enter the following address into the browser window –http://forums.virtualbox.org/viewtopic.php?f=30&t=33358 then click on the VirtualBox ICH AC97 Audio Driver.zip link in the first post, this will then download automatically and the installer will open
- Click Continue
- Highlight Install for all users of this computer and click Continue followed by Install
- You’ll now be prompted for your password again, enter this and then click OK, then click Continue Installation
- The sounds driver files will now be installed, once this has taken place click Restart
You should now have a working OS X installation although here are a few final thoughts. Firstly speed; those who are used to running OS X natively will no doubt be the first to point out that running OS X in a virtual machine is not the user experience that you get when running it natively on dedicated Mac hardware, this is to be expected. Remember that not only is the hardware virtualised, but you are also sharing resources with the host machine which moves me nicely onto my next point. Whilst the virtual machine is running, the performance of your host machine will suffer. It’s still more than usable but during periods of heavy resource utilisation in the virtual machine, the resources will not be available to the host, obviously; remember you may be able to run 2 operating systems simultaneously but you only have one piece of hardware which needs to be shared.
My biggest criticism with OS X within VirtualBox is that the native shutdown and/or restart features do not work. That is to say that if you click shutdown from within the OS it won’t actually shut down. If you try doing this you may see errors such as CPU halted (for Shutdown) or MACH Reboot (for restart) and the OS will just stop. This isn’t a major issue however, as instead of either shutting down or restarting from within OS X you simply power off or reset from within the VirtualBox console; it’s just a little niggle that taints an otherwise good user experience.
The only thing I haven’t covered in this guide is changing the screen resolution; although I haven’t actually felt the need to do this yet. Whilst the default resolution is (by today’s standards) low, it still represents the resolution of an average laptop a few years ago so for testing purposes it’s fine for my purposes. However I’m sure that a lot of you would prefer the option to change this so over the next few days, I will find a way and publish a step by step walk-through. (Update: Change resolution here)
My only other thought is system updates. I am not sure if applying any of the system updates will revert any of the core files back to a state whereby they will not work with VirtualBox, often with hacking code this is the case. So feel free to do a system update if you feel the need however I would resist unless you really have to, remember I’m assuming that, like me, you will only be following this guide for information and/or testing purposes; it’s not intended to be used in a production environment. However, if you must make sure you take a snapshot (backup) first.
Enjoy!
** For convenience, you can also download a copy of this guide in .pdf format here **
Posted in Apple, Blah, Lenovo, Mac OS X, Technology Related, ThinkPad, VirtualBox | 5 Comments »
Windows 7: My Thoughts A Year In August 18th, 2010
It’s been over a year now since Windows 7 RTM came to market, a year which unusually for a newly released Microsoft OS has been in the main, trouble free. The transition for many business users from Windows XP to Windows 7 has been easier than with previous incarnations, certainly surprisingly simple considering there is a decade separating the two operating systems which let’s face it in the ever changing world of IT, is a huge gap.
Overall Windows 7 has been a massive boost for Microsoft generally with the latest figures telling us that more than 150 million licences have already been either installed or at least sold. So what does this tell us (apart from the size of Microsoft’s bank balance)? Well, importantly it means that Windows 7 has now effectively overtaken the installed user base of Windows Vista during its first year of sale which let’s face it is huge for Microsoft although for us; not at all surprising given that Vista is far from perfect (or even good actually).
I was an early adopter of Windows 7 and moved my primary machine to Windows 7 Ultimate prior to the official release (I was fortunate enough to be given an official copy by Microsoft prior to the public release date) and was genuinely surprised by the ease of installation compared to prior versions; things like driver installation and compatibility checks are now fully managed by the system. Owing to Vista being – well – actually quite rubbish, I didn’t transition via Vista and came from using Windows XP on my machines. Windows 7 is definitely the most stable and robust all round operating system I have used to date for my day to day use, both at home and work.
It’s not all great though, on my T61p battery life is not as good as it used to be and there are a few other areas which have been made unduly complicated compared to Windows XP. But of course Windows 7 is designed appeal to all, including consumers who demand the fluid, GUI improvements and work arounds which I would historically have done manually via the command line; that’s not to say that this can’t still be done, in fact with PowerShell this is even more powerful than ever. Let’s not forget that we are still in the infancy of the OS though, with SP1 under development and due to be released soon I am sure some of these annoyances will be addressed making the OS even better.
Of course in the meantime, now manufacturers have more experience of Windows 7 too, updating the BIOS to the latest version will undoubtedly help with any hardware issues such as the increased battery drain, and updating drivers will iron out any system glitches, although they are few and far between.
For sure though, Windows 7 is Microsoft’s most polished operating system to date (although I do still remember Windows 2000 fondly; it just worked!) and it’s safe to assume there will have been some questions raised in the Microsoft hierarchy as to why Vista wasn’t anywhere near as successful. I’m sure some eye brows were raised.
I look forward to testing Windows 8 at an early stage – I believe the public release date is tentatively set sometime during 2012 – when it becomes available on TechNet, it is most likely to follow in the ilk of Windows 7 and will be Microsoft’s most ambitious project to date, really making full use of cloud and mobile computing whilst fighting off the ever nearer threat from Apple, Linux and most recently Google.
Microsoft finally seems to be heading in the right direction again.
Posted in Blah, Microsoft, Technology Related, Windows 7 | No Comments »
HTC Desire: Creating Goldcard Using Mac Or Linux August 9th, 2010
I have been asked by a few people how to make a goldcard using a Mac, but as I do not have access to one at the moment I have not been able to produce a guide however thanks to Johnny and some research using Google you’ll be pleased to know that I have now produced a guide.
Caveat: I have not been able to test this myself as currently I do not have a Mac to test with; however I have read various comments confirming that this method works. Please post a comment to let me know how you get on.
PLEASE backup the entire contents of your microSD before proceeding, in one of the first steps you’ll need to reformat. I will not be accountable for anyone neglecting to do this and loosing data – you have been warned!
So, to create a goldcard using Mac OSX, simple do the following:
- Backup the data on your microSD
- Click Menu on your mobile
- Go to Settings and then SD & Phone Storage
- Click Unmount SD card
- Click Format SD card
We now need to know the microSD cards CID number, using this method; we can find it by going to the market and downloading ASTRO File Manager. Once you have downloaded and installed it, do the following:
- Open ASTRO File Manager
- Navigate to sys/class/mmc_host/mmc1/mmc1:82d1 (you’ll find that 82d1 will be different on your device)
- Long press on the CID file
- Select Open As and then Text
- Select File Editor
- You’ll be given a long number, make a note of this
Next we need this long number in order to create your goldcard image; this can be done by using a simple tool found on this page:
- Copy the number carefully into the data field and hit Submit
- Make a note of the new number
Next to create the actual goldcard image by going to this page:
- Enter the number from above into the SD Card Serial (CID) field
- Enter the other details and hit Generate Goldcard
- Check your email and save the attached goldcard image file to your user directory
Connect your Desire to your Mac and do the following:
- Pull down the notification bar and press Charge Only (if you have previously changed the default option this may be different, i.e. HTC Sync)
- Select the Disk Drive option and hit Done
- On your Mac, open Terminal which can be found by clicking through Applications>Utilities>Terminal (or your Linux Terminal)
- Type the following:
diskutil list - You should be able to see your microSD card; you can recognise it from its size and by the fact that its type is DOS_FAT_32. You need to make a note of the Identifier for example disk2s1
- Now you need to unmount the microSD, assuming your Identifier was disk2s1 (change the value ‘2’ based on the number you got after the word ‘disk’) enter the following:
diskutil unmountDisk /dev/disk2
Finally, to create your individual goldcard do the following:
- Open Terminal once again and type the following:
sudo dd bs=512 if=~/goldcard.img of=/dev/disk2
(remembering to change the ‘2’ if appropriate) - You’ll need to enter your password when prompted (or if using Linux, the password for root)
That’s it, goldcard created!
Posted in Android OS, Apple, Blah, Desire, Google, HTC, Linux, Linux Mint, Mac OS X, Technology Related, Ubuntu | 24 Comments »

