# A Mathematician's approach to Disk Partitioning

Gallia est omnis divisa in partes tres

"It's like this," said the Other Professor, hastily drawing a long line upon the black board, and marking the letters 'A,' 'B,' at the two ends, and 'C' in the middle: "let me explain it to you. If AB were to be divided into two parts at C--"

"It would be drownded," Bruno pronounced confidently.

Whenever a broad choice is barring my path, I stop and wonder "Is there a BEST POSSIBLE WAY?". No way to know beforehand, most times.

How do I partition the disk? fdisk's prompt staring at me,
an infinity of options lurking behind it. What am I to do?
I'll need a couple of partitions at least. No, make them
three. What about /var? That's three or four, then. Am I
going to need another one?

And time goes by...

... till I decide: I'll have more than three and four and whatever
comes to my mind. I'll have an infinite number of partitions !!!

What size will the be? Of all possible sizes, of course !!!

But how can an infinity of partitions fit a 100 euros hard disk? Think of Achilles vs Tortoise. Achilles has to move an infinity of smaller and smaller steps before overtaking the tortoise. All within the race distance.

Let's make a first partition, of size S. Make a second one of size S times a constant k, smaller than 1. Then make one of size S times k^2. Keep on adding partitions, each one smaller than the previous by this k factor. Go on till you fill-up the hard disk, which may as well be NEVER. That depends on the choice of the initial size and on the reduction constant, of course.

And if we do never fill the disk, we'd like to waste as little space as possible. Our planet is endangered enough without us throwing away hard-disk sectors.

So, ready with pencil and paper:

The first partition account for a size S.

The second one for k S.

The third one for size k^2 S.

Thus, at the i-th step we have S + ... + k^(i-1) S.

This amounts to S times 1 + k + ... + k^(i-1), which, as well-behaved as it
is, happens to equal the much more palatable expression ( 1 - k^i ) / ( 1 - k ).

The powers of k get smaller and smaller, just like Achilles's steps, because
we have taken care to choose a k smaller than one, so that each multiplication
by k is a reduction.

Thus, the expression gets nearer and nearer to 1 / ( 1-k ), without reaching it.
The total space taken by our infinity of partitions is S/(1-k). We want
it to equal the total space T on the hard-disk, so that nothing's lost.

We have three parameters (S, T and k) linked by the relation

- You have a disk of size T and want the biggest partition to be S, then the reduction factor k has to be 1 - S/T.
- You want the proportion of two consecutive partitions to be k and have a disk of size T, then start with a partition of dimension S = T(1-k).
- You need a big partition of size S and want to encompass all smaller sizes by steps of proportion k, then go buy a drive of size T = S / (1-k).

That's all there is to it.

As to the proportion, I could suggest a few:

1/2 is very appealing: the biggest partition takes exactly half of the space, the second one a quarter and so on. The gaps are a bit too wide to my taste and I'd rather prefer the size to half every two steps, so I usually choose sqrt(1/2) =~ 0.7071. The starting size is 0.2929 T, a little less than one third of the total space. Another interesting factor is the golden section (sqrt(5)-1)/2 =~ 0.6180, starting with a partition of size (3-sqrt(5))/2 S =~ .3820 S.

You can choose your favourite number, taking the inverse if it exceeds 1.

Numerologically fit ones include e/pi, 1/sqrt(pi), 1/sqrt(e), 1/sqrt(3).