Re: [opensuse] fdisk calculations
- From: David Haller <opensuse@xxxxxxxxxx>
- Date: Tue, 17 Mar 2009 04:42:46 +0100
Hello,
On Mon, 16 Mar 2009, Greg Freemyer wrote:
On Mon, Mar 16, 2009 at 4:11 AM, jdd <jdd@xxxxxxxxx> wrote:
I'm revising the partition HOWTO, using openSUSE 11.1 as example.
I try to understand fdisk output. namely this one from an USB key:
..........................
Disk /dev/sdb: 2012 MB, 2012217344 bytes
47 heads, 46 sectors/track, 1817 cylinders
Units = cylinders of 2162 * 512 = 1106944 bytes
Disk identifier: 0x04030201
Device Boot Start End Blocks Id System
/dev/sdb1 1 1818 1964932 6 FAT16
.......................
I can't understand the underlying calculus. How is the byte number found?
47 heads * 46 s/t = 2162, ok
2162 * 512 = 1106944, ok
but
1817 cyl * 1106944 bytes = 2011317248, not 2012217344 as shown
any idea?
Cylinders of 2162 sectors don't map to exactly 2012217344 Bytes.
$ echo 'sz=2012217344;cyl=(2162*512);c=sz/cyl;u=c*cyl;
print c," Cyls = ", u, " Bytes\n",\
sz-u, " Bytes ~= ", (sz-u)/512, " unused Sectors\n";\
print 2012217344 - 2011317248, " Bytes\n";' | bc
1817 Cyls = 2011317248 Bytes
900096 Bytes ~= 1758 unused Sectors
900096 Bytes
You're missing exactly the bytes that don't match to the geometry.
You could use a different geometry to minimize the unused portion of
the disk. BTW: 47 heads / 46 sectors is a very weird geometry.
fdisk will tell you this when you "verify" the partitioning.
You could try the other "standard" geometry of * Cyls/16 Heads/63
Sectors. That leaves only 928 unused Sectors (~464 KB).
I would simply have th how-to say something like:
==
The Cylinder / Head / Sector concept is an anachronism from the 1980's
and early 1990's. The CHS concept can only describe disks with a max
capacity of approximately 4 GB. (ie. (2^16-1)*(2^8 -1)*(2^5-1)*512
bytes).
Correct is: ( 2^10 * 2 ^ 8 * 2 ^ 6 ) - 1 sectors. The 2 highest bits
of the sector-byte are used as the highest bits of the cylinder. Thus
yielding a max of 16777215 sectors = 8589934080 B = 8191 MB that are
theoretically adressable via CHS. IIRC though, the highest values
were/are used as a "this is a dummy value", thus it's only 1022 * 254
* 63 sectors ~= 7985 MB.
(You need to verify the number of bits available per field, I'm
working from memory.)
Once you've reconstructed an MBR from scratch, using pencil, paper, a
calculator for hex->bin->dec conversions and DOS debug.com, you won't
forget that fast ;)
Thus the vast majority of currently shipping disks simply use the
maximum allowed value for the number of cylinders, heads, and sectors
in an effort to allow low-level legacy code to access as much of the
disk drive as possible.
A C/H/S of 1023/255/63 marks the CHS-Entry as a "dummy"-Entry,
i.e. only the LBA should be used (which only addresses up to 127 GB,
as only 28 bits are used). The LBA-48 extension (from Maxtor,
specified since ATA-6 IIRC) fixes that for now, addressing up to 128
petabytes.
Boot loaders were some of the last generally used programs to only
support disk access via CHS. For this reason even into the early 21st
century the boot partition had to be in this early portion of the
disk.
Or inside the first 127 GB, more recently, when LBA-48 support is
missing.
[..]
Hope that makes sense
dito,
-dnh
PS@jdd: which howto? URL?
--
"Human beings make life so interesting. Do you know, that in a universe
so full of wonders, they have managed to invent boredom." -- Death
--
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx
- Follow-Ups:
- Re: [opensuse] fdisk calculations
- From: Dave Plater
- Re: [opensuse] fdisk calculations
- References:
- [opensuse] fdisk calculations
- From: jdd
- Re: [opensuse] fdisk calculations
- From: Greg Freemyer
- [opensuse] fdisk calculations
- Prev by Date: Re: [opensuse] fdisk calculations
- Next by Date: Re: [opensuse] OpenSUSE mailing list netiquette improvements.
- Previous by thread: Re: [opensuse] fdisk calculations
- Next by thread: Re: [opensuse] fdisk calculations
- Index(es):
Relevant Pages
|