10

It was long assumed by FS drivers that all diskette and harddisk units operate in blocks of size 512 Bytes. How did this happen to be the case, historically? Why not the "neater" 1 KiB, say?

6
  • 3
    There were 128 byte and 256 bytes sectors, as well. Newer harddisks have a sector size of 4096. It's a trade-off between total capacity, access and transfer times, and overhead through error correction and gaps. The more modern, the larger the sectors sizes that make sense. – dirkt Dec 15 '20 at 19:57
  • 4
    Storage efficiency almost certainly part of the reason. Files on disk effectively have their size rounded up to a multiple of the block size. A 512-byte block means on average 256 bytes are wasted for each file on the disk. Double the block size and you double the average wastage. – Richard Downer Dec 15 '20 at 20:01
  • 2
    @RichardDowner: On the flip side, every sector on a disk is required to have some form of header and be followed by a certain amount of unused space to allow for variations in rotational speed. On a floppy, the header and gap would take as much space as a few dozen bytes (using a smaller gap would reduce rotational-speed tolerance). If headers happen to take 36 bytes, then seventeen 256-byte sectors would take up slightly more area on disk than nine 512-byte sectors, despite holding 256 fewer bytes of useful data. – supercat Dec 15 '20 at 20:37
  • 1
    512 bytes is quite a recent innovation. It came in the first IBM PCs. Before then, 256 was usual. The doubling of sector size was annoying for database programs which assumed that 256 bytes was all you could reasonably read or write in a single lump. – Martin Kochanski Dec 16 '20 at 9:04
  • 2
    AS/400 has 520 bytes/sector (outdated) and 522 bytes/sector. I remember back in the day, there were some thrifty system integrators that would buy standard server SCSI HDDs and reformat them to 520 bytes/sector to try and use them in AS/400s, although there are some more things that are needed to make that work. (The manufacturer ID must be IBM, the disk must support a couple of non-standard SCSI commands, etc.) – Jörg W Mittag Dec 16 '20 at 13:08
8

Sectoring on disks predates floppies. It was in widespread use on hard disks by the time floppies came around. Also, I would note that everything from 1 byte/word granularity to track-sized sectors has been argued for (and sometimes used) over the years on both floppies and hard disks.

Still, why did it settle largely on 512? First, it's just as neat as 1024. It's the previous power of 2. And it was picked for the same reason why memory sizes are a power of two; it's a nice round number for a binary computer.

Beyond that, as to why 512 instead of 128, 256 or 1024 or whatever, my impression is that it was a question of trade-offs:

  • Space efficiency on disk. Small sectors waste space for headers and spacing. Large sectors waste space to store a few bytes in a whole sector. 512 bytes turns out to be a reasonable compromise for a couple hundred files on a half megabyte of media.

  • Use of memory vs. speed. 1 KB was a lot of memory on systems in the late 70s and into the 1980s. Open a few files, add a tiny bit of caching so the system doesn't crawl, and you're using all your RAM just for buffers. On the other hand, if the sector size is too small, there is increased overhead, more seeking on disk, and it gets too slow.

5
  • 3
    Some early floppy drives also had something of a lower limit on sector size. A "hard sectored" floppy had a separate hole through the disk for each sector in a ring outside the hub. Too many holes, and the disk's physical integrity is compromised. – Jerry Coffin Dec 15 '20 at 22:36
  • 1
    It's not as neat as 1024; 10 (in 2^10) is even, from binary perspective, and from a decimal/human perspective, about 1000 is neater than 500. – prosfilaes Dec 16 '20 at 6:18
  • 4
    2^8 (256) is even neater. After all, these were all systems with 8-bit bytes. But you'd need 9 bits to count all the bytes in a 512 byte sector. Really inconvenient. – MSalters Dec 17 '20 at 0:30
  • 1
    @MSalters The IBM PC was a 16 bit machine with 16 bit arithmetic, so no problem there. However, many of the 8-bit machines (CP/M, Apple II, etc.) did use 128 or 256 byte sectors, quite likely for that reason. – RETRAC Dec 17 '20 at 0:41
  • 2
    @RETRAC: Even with 16 bit arithmetic, it's still useful to have sector sizes that fit into a bye. E.g. a 1000 byte file (Hex 03E8) takes 03 full sectors and E8 bytes in the last sector, assuming 256 byte sectors. Getting the top byte is trivial in x86, as it still has the 8+8 register pairs AH/AL etc. x86 only got a barrel shifter in the 386. Then again, drives back then were really slow. – MSalters Dec 17 '20 at 1:05
2

512 byte sector became the de facto standard because they were the size of sector used by the IBM PC. Prior to the PC's dominance, other sector sizes were also common - notably, CP/M (which was the most popular microcomputer operating system prior to the release of the IBM PC) used 256 byte sectors.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.