bug-grub
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: "partnew" Command Writes Wrong Ending Cylinder in MPT


From: sburtchin
Subject: Re: "partnew" Command Writes Wrong Ending Cylinder in MPT
Date: Mon, 20 Nov 2006 04:38:48 -0800 (PST)


adrian15 wrote:
> 
> Hi Sburtchin.
> 
> I have been looking at the partnew code and I am not very sure what it
> does :) .
> What is the algorigthm that partnew should do in your opinnion.
> 
> I mean given a partition type, its start and its length how do you
> calculate the ending cylinder field ?
> 
Most partitioning software uses the actual begin and ending cylinder when
they are between 0 and 1023, and 1023 when the actual begin and/or ending
cylinder is 1024 or greater.  The head and sector values are always the
actual values.  Though not always necessary, to avoid problems, partitions
should always begin and end at cylinder boundaries, except first partition
begins at LBA 63 to make room for MBR.

So for example (with BIOS reporting CHS 10587/240/63), a partition beginning
at cyl 745 and ending at cyl 9812 would have in the partition table begin
CHS 745/0/1 and end CHS 1023/239/63 (cylinders and heads start at 0 and
sectors start at 1).

For example: "partnew (hd0,0) 0x06 63 529137" should calculate begin/end CHS
as follows
(assuming heads=240 & sectors=63 & heads*sectors=15120):
BegLBA=63
BegCyl=Integer(BegLBA/15120) = 0
BegHd= Integer(BegLBA/63) - BegCyl*240= 1
BegSec=mod15120(BegLBA) - BegHd*63 +1 = 1
MBRBegCyl=Min(BegCyl,1023)=0

EndLBA= 63 + 529137 - 1 = 529199
EndCyl=Integer(EndLBA/15120) = 34
EndHd= Integer(EndLBA/63) - EndCyl*240= 239
EndSec=mod15120(EndLBA) - EndHd*63 +1 = 63
MBREndCyl=Min(EndCyl,1023)=34

NOTE: My "Integer() function means truncate the decimal.

For example: "partnew (hd0,3) 0xBF 148372560 40960080"
BegLBA=148372560
BegCyl=Integer(BegLBA/15120) = 9813
BegHd= Integer(BegLBA/63) - BegCyl*240= 0
BegSec=mod15120(BegLBA) - BegHd*63 +1 = 1
MBRBegCyl=Min(BegCyl,1023)=1023

EndLBA= 148372560 + 40960080 - 1 = 189332639
EndCyl=Integer(EndLBA/15120) = 12521
EndHd= Integer(EndLBA/63) - EndCyl*240= 239
EndSec=mod15120(EndLBA) - EndHd*63 +1 = 63
MBREndCyl=Min(EndCyl,1023)=1023



adrian15 wrote:
> 
> I am going to explain more or less how I understand that the end
> cylinder is calculated.
> 
> new_start + new_len - 1, &end_cl, &end_ch, &end_dh
> 
> lba_to_chs function modifies end_cl thanks to:
> bbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaahhhhhhhhhhhhhhhhhhhhhh
> 
> I am tired. Here is the important source code:
> Maybe you may find the error better than me as long as you have more
> knowledge than me on how this C/H/S stuff should work.
> 
> Maybe is it only a matter of switching on / off the lba addressing on
> the bios ? I do not know.
> 
I will have to brush up on my C.  Have'nt done that in a while.  I'll post
back if I find the bug.
-- 
View this message in context: 
http://www.nabble.com/%22partnew%22-Command-Writes-Wrong-Ending-Cylinder-in-MPT-tf2599372.html#a7441725
Sent from the Grub - Bugs mailing list archive at Nabble.com.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]