exFAT vs APFS for external SSD
Recently I bought a SanDisk Extreme SSD with 2 TB and as a macOS user, I was curious to see what kind of drive format was used by default on this drive and as soon as I connected it, I figured out it was exFAT.
For those who don’t know, exFAT is an extension of FAT32 file system, which was created by Microsoft in 1996 to replace the FAT16 used in MS-DOS. The FAT32 is one of the most compatible file systems that exist and is supported in Windows, macOS and Linux. On the other hand it doesn’t support files bigger than 4 GB which makes it unusable these days. The exFAT overcomes this limitation and is almost as compatible as FAT32.
After considering all the pros and cons, I decided to give it a go and started to rsync all my data to the new SanDisk SSD. The data on the original APFS volume was occupying 1,11 TB of space but on the SanDisk SSD was occupying 200 GB more:
Puzzled, I started to google an explanation for this difference and found on superuser.com that this is a problem caused by internal fragmentation. Because exFAT uses a cluster size of 128 KB for volumes greater than 32 GB, a file which size is not multiple of the cluster size will result in wasted space on the storage device, so called slack space.
After this finding, I decided to sacrifice the compatibility of exFAT and get a more optimised filesystem like APFS. But before proceeding with that I decided to test the SSD performance with exFAT:
Code language: Shell Session (shell)user@user-laptop:/Volumes/Mobile $ dd if=/dev/zero bs=2048k of=tstfile count=1024 2>&1 | grep sec | awk '{print $1 / 1024 / 1024 / $5, "MB/sec" }' 472.005 MB/sec
Just as reference, the computer internal SSD reaches a speed of approximately 1500 MB/sec. The external SSD is 3 times slower, but still much better than any external hard disk drive (HDD).
After formating the drive as APFS, I rsynced the same files as before, but now they occupy the expected size of 1.1 TB:
In terms of speed, however, there is not a noticeable difference between exFAT and APFS:
Code language: Shell Session (shell)user@user-laptop:/Volumes/Mobile $ dd if=/dev/zero bs=2048k of=tstfile count=1024 2>&1 | grep sec | awk '{print $1 / 1024 / 1024 / $5, "MB/sec" }' 461.88 MB/sec
This is not an exhaustive comparison between these two filesystems. Also, other options could be used to replace exFAT like NTFS or HFS.