Mac OS X 10.7 Lion introduced File Fault 2, a whole-partition encryption scheme. Depending on your disk and CPU, encryption may causes a significant performance hit.
Here’s how to compare the speed of disk access once you have enabled encryption with the speed without encryption.
Note
We will use dd, a tool well known to any command line geek as potentially extremely dangerous.
Make sure to identify the disks you are operating on properly and especially to ensure that you have exactly one parameter of and that it looks like this: of=/dev/null.
Be sure to have a full, complete, and working backup of your entire disk, not just the most important documents. A typo can and will destroy all your data in a split second.
In the following, ensure to disconnect any and all disks except your main OS X Lion system disk. Then reboot.
With that out of the way, let’s get to work.
First, verify that your physical hard drive is disk0 and the decrypted volume is disk1:
Run diskutil list:
1 2 3 4 5 6 7 8 9 10 | |
As you can see, there are two disks, disk0 and disk1. In my case, disk1 is called “macosx” and it is my Lion system disk. However, it is not a physical disk but rather the decrypted volume hosted in the physical Apple_CoreStorage partition of disk0, referred to as disk0s2.
To verify that disk1 is in fact mounted as the root file system, run diskutil mount:
1 2 3 4 5 | |
Further, to see that disk1 is indeed a core storage logical volume, run diskutil cs info disk1:
1 2 3 4 5 6 7 8 9 10 11 12 13 | |
Now let us run some read tests on the physical disk, identified as /dev/rdisk0. Note that writing just a few bytes to this device may render your entire disk un-decryptable.
First, become root, then run the following command: time dd if=/dev/rdisk0 of=/dev/null bs=4k count=262144. This reads 1GiB from the raw disk and discards it (of=/dev/null), using a block size of 4kiB.
(If you don’t know how to become root, this hint is not for you.)
1 2 3 4 5 | |
As you can see, dd reports “10711067 bytes/sec”. Obviously, the disk is limited by the number of I/O operations it can perform per second. Let’s compare this with 64kiB blocks by running time dd if=/dev/rdisk0 of=/dev/null bs=64k count=32768:
1 2 3 4 5 | |
Now we pretty much observe the raw read rate, reported by dd “61715298 bytes/sec”.
For comparison, run the same tests on disk1, the decrypted system disk.
Run the following command: time dd if=/dev/rdisk1 of=/dev/null bs=4k count=262144, now reading 1GiB of data from the decrypted disk in 4kiB blocks:
1 2 3 4 5 | |
Then, again for 64kiB block size: time dd if=/dev/rdisk1 of=/dev/null bs=64k count=32768
1 2 3 4 5 | |