SUMMARY:Hard disk partition formula

From: Systems Administrator (sysadmin@astrosun.tn.cornell.edu)
Date: Mon Sep 30 1996 - 08:35:21 CDT


Thanks to all for the many responses! I haven't had a chance to get
thru all of them yet, but with no further delay:

My original question:
-----------------------------------------------------------------------
I know this is probablly not the best case to ask this question but I'm
not sure where else to go.

What is the formula to figure out how to set up a partition. I might
know I want a 30 MB partition but all format wants to know is how many
blocks in a partition and what is the starting block. How do I fugure
that out. I had the formula of (MB x 2) / number of data sectors /
Number of heads. Somehow this didn't seem to work right.
-----------------------------------------------------------------------
Thanks to:
-----------------------------------------------------------------------
amy.hollander@amp.com (Amy Hollander)
better to build using cylinder/sector/head boundaries
not megs
-----------------------------------------------------------------------
Edward Grimm <edgrimm@neptune.mtc.ti.com>
How is it in error? Uh, that's sectors/track, not # of data sectors.
Other than that...
-----------------------------------------------------------------------
jem@electriciti.com

Since disks have a variety of head sizes, data sectors, etc., I use the
format -> newfs -> format -> ... method.

If I would like a 30m partition, these are the steps I take:

1) I take an educated guess on the number of cylinders and set
      them for the desired partition.
2) I save the partition and exit all the way out of format.
3) I run the desired newfs command (with all of the appropriate
      options) _with_ the -N option, which means it does not
      actually perform the newfs.
4) This spits out the size of the partition. I now have a
      formula to solve to determine the size of each cylinder.
      For example, if I guessed 30 cylinders, and the size of
      the partition is 15m, I know that I will need approximately
      60 cylinders to get the desired size partition.
5) So, now I go back to step 1 and continue through step 4
      until I get as close as I want.

I am sure that there is a more scientific formula to get an accurate
size the first time. I just use this method, because it works just
fine.
-----------------------------------------------------------------------
Christopher E. Olaes" <colaes@hercules.nhlbi.nih.gov>
The formula is:

>From the Solaris 1.1.1 System Installation
To convert megabytes to blocks, multiply the number of megabytes by
2048.
(one megabyte equals 1048576 bytes. This, divided by 512 bytes, equals
2048.)
-----------------------------------------------------------------------
Dan Pritts <danno@us.itd.umich.edu>
ook at partition C (partition 2 on solaris, probably). that tells you
teh # of blocks and cylinders of the entire disk.

take that information, along with your knowledge of the capacity of
the disk, and do the math.

suggest you work in cylinders not blocks for partition length
  specify this as something like this:

 starting block: 0
 length: 30/0/0

for 30 cylinders. if you just say "30" you'll get blocks.

If you can find the graphical openwindows formatter program in
solaris (presumign you're running same) it will convert megabytes
for you. Heck, solaris format command may do that too.
-----------------------------------------------------------------------
James.E.Coby.Jr@cdc.com (James Coby)
Try 30m this will put it in megabytes. I personally
use the "c" for cylinders.

Enter partition size[216270b, 267c, 105.60mb]:
-----------------------------------------------------------------------
Torsten Metzner <tom@plato.uni-paderborn.de>
|I know this is probablly not the best case to ask this question but I'm
|not sure where else to go.

Hello Vic,
that's true because it's really easy to get this information by
"playing" with format.
If you don't use the label command in the partition menu the
partition table isn't written to the disk, so you can "play" with it.

|
|What is the formula to figure out how to set up a partition. I might
|know I want a 30 MB partition but all format wants to know is how many
|blocks in a partition and what is the starting block.

2 blocks are 1 KB. {;-) Easy isn't it ?
Here is an example to make you familiar with it.

partition> print
Current partition table (original sd0):
        partition a - starting cyl 0, # blocks 140800 (200/0/0)
        partition b - starting cyl 200, # blocks 563200 (800/0/0)
        partition c - starting cyl 0, # blocks 1013760 (1440/0/0)
        partition d - starting cyl 0, # blocks 0 (0/0/0)
        partition e - starting cyl 0, # blocks 0 (0/0/0)
        partition f - starting cyl 0, # blocks 0 (0/0/0)
        partition g - starting cyl 1000, # blocks 309760 (440/0/0)
        partition h - starting cyl 0, # blocks 0 (0/0/0)

You can see, that the root partition is 140800 blocks = ~70MB
To get this partition table, the size and the starting cylinders are
the following:

partition starting cyl size in blocks size in cyl
    a 0 140800 200/0/0
    b 200 563200 800/0/0
    g 1000=200+800 309760 440/0/0
    
    
Partition c is the whole disk, don't change this.

    c 0 1013760=140800+563200+309760
1440=200+800+440

A last remark: If you give the size in blocks, it's easy to define the
size
( Remember 2 blocks = 1KB ). But the system can only use whole cylinders
for a partition. So if you use a block size which uses only a part
of a cylinder, the rest of this cylinder is lost ( Remember you have to
give the starting cylinder ).

An example for this ( Remember if I don't use the label command my
partition
table isn't changed, so I can try this on a working machine {;-) )

partition> d
 
        partition d - starting cyl 0, # blocks 0 (0/0/0)
 
Enter new starting cyl [0]: 600
Enter new # blocks [0, 0/0/0]: 100000
partition> print
Current partition table (unnamed):
        partition a - starting cyl 0, # blocks 140800 (200/0/0)
        partition b - starting cyl 200, # blocks 563200 (800/0/0)
        partition c - starting cyl 0, # blocks 1013760 (1440/0/0)
        partition d - starting cyl 600, # blocks 100000 (142/0/32)
        partition e - starting cyl 0, # blocks 0 (0/0/0)
        partition f - starting cyl 0, # blocks 0 (0/0/0)
        partition g - starting cyl 1000, # blocks 309760 (440/0/0)
        partition h - starting cyl 0, # blocks 0 (0/0/0)

I have choosen a ~50MB partition and I can see that
100000 blocks = 142/0/32, so I would redefine the size in the following
way:

partition> d
 
        partition d - starting cyl 600, # blocks 100000 (142/0/32)
 
Enter new starting cyl [600]: 600
Enter new # blocks [100000, 142/0/32]: 142/0/0
partition> print
Current partition table (unnamed):
        partition a - starting cyl 0, # blocks 140800 (200/0/0)
        partition b - starting cyl 200, # blocks 563200 (800/0/0)
        partition c - starting cyl 0, # blocks 1013760 (1440/0/0)
        partition d - starting cyl 600, # blocks 99968 (142/0/0)
        partition e - starting cyl 0, # blocks 0 (0/0/0)
        partition f - starting cyl 0, # blocks 0 (0/0/0)
        partition g - starting cyl 1000, # blocks 309760 (440/0/0)
        partition h - starting cyl 0, # blocks 0 (0/0/0)
 
The above is only an example to demonstrate how you should define
the partition size. Remember if I now label the disk I have
destroyed the swap partition or more in detail I have overlapping
partitions:
   b cyl 200 - 999
   d cyl 600 - 741
Ah yes you didn't mentioned if you are using Solaris or SunOS, but in
principle
it's the same. I think you are using SunOS, because in Solaris you can
choose the size in MB {;-) My example is from our last SunOS machine.
-----------------------------------------------------------------------
Robert.Gillespie@waii.com (Robert.Gillespie@waii.com)

Size in Bytes of ONE CYLINDER == No. HEADS x No. SECTORS/TRACK x 512

Guess at Number of cylinders to give Size of partition

Take size of partition X .83 (ish) to give final capacity
(Assuming loss during newfs & 10% optimization)

EXAMPLE

dkinfo sd2
sd2: SCSI CCS controller at addr f0800000, unit # 16
3604 cylinders 16 heads 180 sectors/track
a: No such device or address
b: No such device or address
c: 10379520 sectors (3604 cyls)
   starting cylinder 0
d: No such device or address
e: No such device or address
f: 1992960 sectors (692 cyls)
   starting cylinder 0
g: 4193280 sectors (1456 cyls)
   starting cylinder 692
h: 4193280 sectors (1456 cyls)
   starting cylinder 2148

GIVES:-
No. HEADS = 16
No. SECTORS/TRACK = 180

SO:-
16 x 180 x 512 = 1474560 bytes per cylinder

FOR partition a above:-
1474560 x 692 = 1020395520

opal# newfs /dev/rsd2f
/dev/rsd2f: 1992960 sectors in 692 cylinders of 16 tracks, 180
sectors
        1020.4MB in 44 cyl groups (16 c/g, 23.59MB/g, 10816 i/g)
super-block backups (for fsck -b #) at:
 32, 46304, 92576, 138848, 185120, 231392, 277664, 323936, 370208,
.
.
.

To get FINAL capacity as seen by user:-

1020395520 x .83 = 846928282

Filesystem kbytes used avail capacity Mounted on
/dev/sd2f 936271 9 842635 0% /home

The .83 ish is good enough for most calulations AND easy to remember !!!
------------------------------------------------------------------------
Martin Espinoza <drink@sei.com>
Get the number of cylinders (ncyl)
Divide the number of megabytes by the number of cylinders.
So if your drive was 2gb and you had 1000 cylinders,
each cylinder would be 2mb.

Remember that by default a filesystem eats up 10% of the
disk for optimizing and leaving some free space so that
it doesn't overrun. You can change that with the -m flag
of newfs.
-----------------------------------------------------------------------
bleary@state.ma.us
f you haven't changed anything yet ...

format, select disk, partition, print -
Look at the entry for partition C (Sun OS) or 2 (Solaris). By default
this partition maps the entire disk. It is a good idea to keep it.
This
is what everyone expects.

For Sun OS: the '# blocks" entry gives the total number of 512 byte
blocks
(1/2 KB) followed by "(N/0/0)" where N is the number of cylinders.
ex. partition c - starting cyl 0, # blocks 2090340 (1659/0/0)
Describes a disk of 1,045,170KB = 1,020MB = (2090340/2) and 1659
cylinders.
Given the above, a cylinder = 630KB = ((2090340/2)/1659). And to
construct a
partition of 30MB would take 48.7 cylinders ((30x1024)/630). So the
size
entry for format would be 49/0/0 (49 cylinders).

For Solaris: the 'size' entry gives the MB on the disk followed by
"(N/0/0)"
where N is the number of cylinders.
ex. 2 backup wm 0 - 3114 1009.94MB (3115/0/0)
2068360
Describes a disk of 1009.94MB and 3115 cylinders. Given the above a
cylinder = 0.3242MB (1009.94/3115). And to construct a partition of
30MB
would take 92.5 cylinders ((30x1024)/0.3242). So the size entry for
format
would be 93/0/0 (93 cylinders).

I use cylinders, not blocks, because my experience has been that fs
wastes
disk if it is not aligned on cylinders.
-----------------------------------------------------------------------
neputi@atlas.ast.lmco.com
I use the following..

# heads x # sectors x 512 = bytes per cylinder

Also I round up to the nearest even number cylinder when doing the
partition.
-----------------------------------------------------------------------
jasonn@nabaus.com.au (Jason Noorman)
f you have a look in the admin guides supplied by sun you will see that
once you have put in the starting block, you would then put in the size
instead of saying how many cynlinders you would say "30m" meaning 30Mb.
for the next partition have do a "p" then have alook at how many blocks
were allocated by the previous partition and start from there.
-----------------------------------------------------------------------
u00y0123@hsc.hac.com
ry this:

30 MB/512 bytes-per-block = about 58594 blocks.

then,

total "c" partition of drive / total cyl of drive = x1 blocks per
cylinder

so,

58594 blocks / x1 = # of cylinders reqd.

if,

"# of cylinders reqd." is for instance, 87.455 then you must use 88
cylinders.
-----------------------------------------------------------------------
tbush@svcs.mmc.com
To start you need to convert megabytes to blocks. Multiply the number of
megabytes by 2048. (One megabyte equals 1048576 bytes. This, divided by
512
bytes, equals 2048.) A partition of exactly 30MB contains 61,440 blocks.
(30 x 2048 = 61,440)

Determining a starting block should actually be stated as determining
the
starting cylinder. When using the partition function within the format
command
you define a starting cylinder and then provide the size in 512-byte
blocks.
When this is initially done the partition will contain the exact amount
defined
however, the space it occupies on the disk will not fill an exact number
of
cylinders. Although it's not necessary it is highly recommended and
desirable.
So, the next step would be to resize the partition to fill out the last
cylinder
it occupies.

        For each partition:

        1. Determine starting cylinder
        2. Provide size in 512-byte blocks
        3. Resize the partition to fill out the last cylinder it
occupies.

Take a look at a new partion table for a 1.05GB disk:

Current partition table (original sd0):

        partition a - starting cyl 0, # blocks 0 (0/0/0)
        partition b - starting cyl 0, # blocks 0 (0/0/0)
        partition c - starting cyl 0, # blocks 2052288 (2036/0/0)
        partition d - starting cyl 0, # blocks 0 (0/0/0)
        partition e - starting cyl 0, # blocks 0 (0/0/0)
        partition f - starting cyl 0, # blocks 0 (0/0/0)
        partition g - starting cyl 0, # blocks 0 (0/0/0)
        partition h - starting cyl 0, # blocks 0 (0/0/0)

Partition "c" represents the entire disk and you do not want to modify
that
partition. For example purposes lets say you want to define the
following
partitions:

        a = 50MB (50 x 2048 = 102400)
        b = 120MB (120 x 2048 = 245760)
        g = 620MB (620 x 2048 = 1269760)
        h = 215MB (215 x 2048 = 440320)

Using the partition function within the format command, when you select
a
partition to define, you will be prompted to enter a starting cylinder
(cyl).
Next you will be prompted to enter # of blocks. After this, you want to
select
the same partition again. When prompted to enter a starting cylinder
press
return. Then when prompted to enter # of blocks, enter the partition
size in
cylinders/tracks/blocks but round up to the next whole cylinder from
what you
see displayed.

        "An important note to remember - Since you will be rounding up
        the values for cylinders occupied, the last partition will be
        slightly less than orginally planned and the others, except "c",
        will be slightly larger."

        For example:

          Partition "a" the starting cylinder will be 0.
          # of blocks will be 102400

          Enter "a" at the partition> prompt
          Enter new starting cyl [0]: <Return>
          Enter new # blocks [0, 0/0/0] 102400 <Return>
          Enter "a" at the partition> prompt
          Enter new starting cyl [0]: <Return>
          Enter new # blocks [102400, 101/6/8] 102/0/0 <Return>

The "a" partition now occupies 102 cylinders. For simplicity consider
"102" a
sum of total occupied cylinders. For partition "b" use this value as the
starting cylinder.

        For example:

          Partition "b" the starting cylinder will be 102.
          # of blocks will be 245760

          Enter "b" at the partition> prompt
          Enter new starting cyl [0]: 102 <Return>
          Enter new # blocks [0, 0/0/0] 245760 <Return>
          Enter "b" at the partition> prompt
          Enter new starting cyl [102]: <Return>
          Enter new # blocks [245760, 243/9/12] 244/0/0 <Return>

Ok, you have partitions "a" & "b" defined. Now for "g". Determine the
sum of
total occupied cylinders by adding the values given for "cylinders"
(remember
- cylinders/tracks/blocks) "a" (102) and "b" (244). 102 + 244 = 346.

        For example:

          Partition "g" the starting cylinder will be 346.
          # of blocks will be 1269760

          Enter "g" at the partition> prompt
          Enter new starting cyl [0]: 346 <Return>
          Enter new # blocks [0, 0/0/0] 1269760 <Return>
          Enter "g" at the partition> prompt
          Enter new starting cyl [346]: <Return>
          Enter new # blocks [1269760, 1260/4/9] 1261/0/0 <Return>

This last partition ("h") is next. Determine the sum of total occupied
cylinders by adding the values given for "cylinders" "a" (102), "b"
(244), and
"g" (1261). 102 + 244 + 1261 = 1607. 1607 is the starting cylinder.
Since 1607
also equals the total occupied cylinders, you can subtract this value
from the
total number of cylinders listed for partition "c" (remember "c" is the
entire
disk). If you don't recall that value just enter "print" at the
"partion>"
prompt. In this case the total number of cylinder is equal to 2036.
So 2036 - 1607 = 429. 429 is the total number of cylinders left. This
time
when you enter the "new # of blocks", enter it in the form of
cylinders/tracks/blocks (429/0/0). You will not need to round up for
this one
because the value you will give uses all remaining cylinders.
        
        For example:

          Partition "h" the starting cylinder will be 1607.
          # of blocks will be 429/0/0

          Enter "h" at the partition> prompt
          Enter new starting cyl [0]: 1607 <Return>
          Enter new # blocks [0, 0/0/0] 429/0/0 <Return>

Enter "print" at the partition> prompt for a printout of the partition
table. You can check yourself by adding the # blocks for each partition
except
"c". That sum should equal the value shown as # blocks for partition
"c".
You can also add the cylinders for each partition except "c". That sum
should
equal the cylinder value shown for partition "c".

Current partition table (original sd0):
        partition a - starting cyl 0, # blocks 102816 (102/0/0)
        partition b - starting cyl 102, # blocks 245952 (244/0/0)
        partition c - starting cyl 0, # blocks 2052288 (2036/0/0)
        partition d - starting cyl 0, # blocks 0 (0/0/0)
        partition e - starting cyl 0, # blocks 0 (0/0/0)
        partition f - starting cyl 0, # blocks 0 (0/0/0)
        partition g - starting cyl 346, # blocks 1271088 (1261/0/0)
        partition h - starting cyl 1607, # blocks 432432 (429/0/0)

Remember a previous statement?

        "An important note to remember - Since you will be rounding up
        the values for cylinders occupied, the last partition will be
        slightly less than orginally planned and the others, except "c",
        will be slightly larger."

Notice that the # blocks for each partition differ slightly than what
was
previously figured. Remember that you wanted 620MB for partition "g" and
215 for partition "h". What did you wind up with? Take the value shown
for
# blocks and divide by 2048 to see actual space allocated.

        Planned:
          g = 620MB (620 x 2048 = 1269760)
          h = 215MB (215 x 2048 = 440320)
        Actually Allocated:
          g = 620.6MB (1271088 / 2048 = 620.6)
          h = 211.1MB (432432 / 2048 = 211.1)

Finally, you need to label the disk by entering "label" at the
partition>
prompt. Exit format and your done.
-----------------------------------------------------------------------
dhaut@level1.com (Dave Haut)
There is 512 bytes per block or sector. If you look at the format
command for a disk:

aquaman# format
Searching for disks...done
 

AVAILABLE DISK SELECTIONS:
       0. c0t0d0 <SUN2.1G cyl 2733 alt 2 hd 19 sec 80>
          /sbus@1f,0/espdma@e,8400000/esp@e,8800000/sd@0,0

In this example, there are 80 sectors per track ( sec 80 ), 19 trks per
cylinder ( hd 19 ) and 2733 cylinders total on the disk, so for a
30 meg partition for this particular disk, the number of cylinders would
be:

30,000,000 bytes/(512 bytes/sec)/(80 sec/trk)/(19 trks/cyl) = ~39
cylinders.

Use cylinders instead of blocks when specifying a partition size with
format.
You can do this by entering the number FOLLOWED BY A SLASH (/)
WITH NO SPACE ( Ex. 39/ ).

As far as how to determine what starting cylinder to use, just remember
that
cylinder 0 is the first cylinder, so in this case if it was the "a"
partition
that I was creating, the starting cylinder would be 0. For the next
partition
that I wanted to create, the starting cylinder would be 39 and NOT 40 (
0+39 )
-----------------------------------------------------------------------
bismark@alta.jpl.nasa.gov (Bismark Espinoza)
The notation is (cylinder/head/sector).
The rough formula is 2xnumber of blocks*512 bytes.
-----------------------------------------------------------------------
manderso@neon.mitretek.org (Mark S. Anderson)
A disk block is 512 bytes. A megabyte is 1024*1024, or 512*2048,
bytes. Therefore 2048 disk blocks equals 1 MB. Thus 30MB = 30*2048
blocks.
-----------------------------------------------------------------------

-- 
***************************************************************
                        Systems Administrator
                       -----------------------
                       Space Sciences Building 
Vic Germani              Cornell University
(607)-255-3434           402 Space Sciences 
                   sysadmin@astrosun.tn.cornell.edu
***************************************************************



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:11:11 CDT