What is the difference between 'physical' and 'logical' size?

I just found out about the mdls command on OS X which prints out the metadata associated with a given file. This command tells me both a 'physical size' ("kMDItemPhysicalSize") and 'logical size' ("kMDItemLogicalSize"). For example, the current text file I'm looking at has:

  • physical size: 1152
  • logical size: 4096

If I do a ls -l, it's size is given as 1152. If I open up the 'get info' panel, it says "1,152 bytes (4 KB on disk)". So whatever 'logical size is', it apparently equates to size "on disk".


Disks are divided into sectors, which are 512 bytes* on your typical hard drive or SSD.

Filesystems are responsible for taking requests for files based on name (something you understand) and translating into block read/write requests (something the disk understands). For this to work, a map of which sectors belong to which file is needed. There's many ways to do this and thus, there are many filesystems in existence. Windows uses NTFS and FAT32, for example, and Linux has numerous ones including ext2, ext3, etc. Not sure about Mac filesystems but it's the same principle.

Some filesystems will have a level above sectors this called clusters which are sets of sectors - because a map of every single sector on large disks might take up too much space. On NTFS, for example, you can specify the cluster size ("allocation unit" is another name for it), and 4096 bytes (8 sectors) is one of them you can pick.

So, given all that, the "minimum" you can really read or write to a disk will be the sector size or cluster size. So while you may write 4097 bytes to a disk, the filesystem has to give that file two clusters, so it takes 8192 bytes away from your free space. Thus, you have the logical size (size it consumes on the disk) and the physical size (the real size of the file).


*On some newer "Advanced Format" disks it's internally 4Kbytes, but still looks like 512 byte sectors to the OS for compatibility. SSDs are wildly different on the inside but again still look like 512 byte sectors to the OS.