An interesting IDE to SATA migration problem

February 16, 2006

A coworker here ran into a novel problem migrating a system from an IDE disk to a SATA disk: he ran out of partitions. He had 16 partitions on the IDE disk, and on Linux you can only have 15 partitions on a SATA drive. (Fortunately he found a partition he didn't really need.)

On the surface, this limitation is because SATA drives on Linux are considered to be SCSI disks, and all SCSI disks can only have 15 partitions. Of course, that just leads to the next question: why does SCSI have this limitation?

The simple answer is that there's a tradeoff between how many drives you can have and how many partitions each of them can have. Linux doesn't support very many IDE drives (or didn't initially), so it could afford to let each of them have lots of partitions. However, when SCSI was set up people expected to have lots of SCSI drives, so each of them could only have so many partitions.

(The tradeoff happens because Linux spent years using 16-bit device numbers, which are statically assigned to various things. So there were only so many to go around, period. Of course not all of the allocations are sensible, as you can see here.)

If you have a fully populated /dev, you can see the tradeoff in action; just do 'ls -l /dev/sd? /dev/hd?' and watch how the major and minor numbers jump around. SCSI squeezes 16 disks into one major number (8), while IDE has just two in its first major number (3); hdc and hdd actually hang out in major 22 instead. Since the kernel restricts IDE drives to 63 partitions, what takes up the other half of major 3's minor numbers is one of those small mysteries.

(I will hazard a guess that major numbers tended to be assigned in roughly the order Linux started acquiring support for the hardware, which may say interesting things about the popularity of secondary IDE controllers versus SCSI controllers in Linux's early days.)

Written on 16 February 2006.
« Fun with control characters and the web
Some regular expression performance surprises »

Page tools: View Source, Add Comment.
Search:
Login: Password:
Atom Syndication: Recent Comments.

Last modified: Thu Feb 16 03:00:22 2006
This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.