Skip to contentSkip to conversation

Determining maximum partition size on a hard disk

DISCUSSION Nick DeClario 3 participants 4 messages Aug 21, 2001 – Aug 28, 2001

lore
Share & tools
lore
#0 lore raw

I am trying to calculate the maximum size a partition can be on a hard drive and I ran into some problems I don't fully understand.

First I found that the maximum size of the drive Linux reports is not the maximum size I get when I calculate it from the drives geometry. Secondly, the total drive space reported by linux is not the amount available for the maximum partition.

For example, I have a 4.3Gb disk. The drives geometry is 525 cylinders, 255 heads and 63 sectors (525 * 255 * 63 * 512 = 4318272000 or 4.318Gb).

This is an IDE disk so I found in /proc/ide/hdx/capacity a block size 8439184, which when divided by 2048 is 4120.7, ~200Mb less than what I calculated as the disk size.

Finally, using a program such as fdisk or sfdisk I create a partition manually to be the maximum amount allowed, which turns out to be 4217041 blocks, or, when divided by 1024 is 4118.2.

I assume that the difference between the maximum size that linux reports and the maximum partition size is due to linux leaving room for a MBR and such. If so how do I go about calculating this? Also why does the size of the drive I calculate out by using the drives geometry differ so much from the amount Linux reports? I thought maybe Linux set 1MB=1000k but that doesn't seem to case.

Any information or a push in the right direction would be appreciated, thanks!

Regards,
-Nick DeClario

#1 lore raw
Quoted 8 lines · Nick DeClario

I am trying to calculate the maximum size a partition can be on a hard drive and I ran into some problems I don't fully understand.

First I found that the maximum size of the drive Linux reports is not the maximum size I get when I calculate it from the drives geometry. Secondly, the total drive space reported by linux is not the amount available for the maximum partition.

Quoted 7 lines

For example, I have a 4.3Gb disk. The drives geometry is 525 cylinders, 255 heads and 63 sectors (525 * 255 * 63 * 512 = 4318272000 or 4.318Gb).

This is an IDE disk so I found in /proc/ide/hdx/capacity a block size 8439184, which when divided by 2048 is 4120.7, ~200Mb less than what I calculated as the disk size.

I don't know why you would want to divide by 2048. Multiply by 512 and find 512*8439184 = 4320862208 bytes. Since that is more than you thought you had, be happy.

Quoted 2 lines

I assume that the difference between the maximum size that linux reports and the maximum partition size is due to linux leaving room for a MBR

No. There are rounding differences. The disk capacity is not an integral number of cylinders and you lose if you insist on alignment.

Find a lot of details in the Large Disk Howto.

Quoted 1 line

I thought maybe Linux set 1MB=1000k but that doesn't seem to case.

Well, 1 M = 1000 k by definition of the SI system of units. This has nothing to do with Linux.
But if you are confused about units, just compute in bytes.

#2 lore raw
Quoted 6 lines · Guest section DW
Quoted 1 line · Nick DeClario

I thought maybe Linux set 1MB=1000k but that doesn't seem to case.

Well, 1 M = 1000 k by definition of the SI system of units. This has nothing to do with Linux.
But if you are confused about units, just compute in bytes.

While it is true that M = 10^6 and k = 10^3, surely that doesn't apply to byte quantities?!? At least I have always interpreted 1 Megabyte = 1024 kilobytes = 1024*1024 bytes, and I think the poster meant the same when writing 1MB = 1000k...

If we are nitpicking, he probably should have written 1MiB = 1000kiB. [Feel free to correct me if I am wrong, but IIRC, Mi and ki are the abbreviations for 2^10 multiples rather than 10^3...]

Anton

Signature · 5 lines
  "Nothing succeeds like success." - Alexandre Dumas
-- 
Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @)
Linux NTFS Maintainer / WWW: http://linux-ntfs.sf.net/
ICQ: 8561279 / WWW: http://www-stu.christs.cam.ac.uk/~aia21/
#3 lore raw

units - was: Re: Determining maximum partition size...

In reply to Nick DeClario
Quoted 8 lines · Anton Altaparmakov
Quoted 4 lines
Quoted 1 line

I thought maybe Linux set 1MB=1000k but that doesn't seem to case.

Well, 1 M = 1000 k by definition of the SI system of units. This has nothing to do with Linux.

While it is true that M = 10^6 and k = 10^3, surely that doesn't apply to byte quantities?!? At least I have always interpreted 1 Megabyte = 1024 kilobytes = 1024*1024 bytes

Ah, an old discussion - I imagine it must have occurred here a few times.
Anyway: k is the prefix for 1000, M is the prefix for 1000000. Always.

But there is a natural sloppiness, where people round numbers when either the precise size is unimportant, or is clear from the context. If xyzzies come in boxes of 27 and I say that I bought a hundred xyzzies then that probably means that in fact I bought 108.

Thus, our old PDP8 with 4k of memory had 4096 12-bit words, that is, 6 KiB in modern terminology.

You see two very different situations here: "precise size is unimportant" and "precise size is clear from the context". When someone says that she bought a 10 GB disk I will assume that the precise size is somewhere between 9.5 and 10.5 GB. This is the "rounded" case.
When someone says that she bought a 32 MB SIMM I will assume that this was 32 MiB, that is, 2^25 bytes, since, unlike disks, memory modules tend to come in power-of-two units. This is the "clear from the context" case.

Andries