disklabel/bsdlabel Question

Matthew Seaman m.seaman at infracaninophile.co.uk
Fri May 9 02:03:55 PDT 2003

On Thu, May 08, 2003 at 11:42:52AM +0930, Wilkinson,Alex wrote:

> If I want to change the block size and fragment size of a BSD partition will newfs use the
> changed values I make in the disklabel or do I still have to use newfs options to specify the
> fsize and bsize ?
> In other words, by changing the values of the disklabel, does this make the new values the defaultfor newfs ?

Good question.  It's not entirely clear from the newfs(8) and
disklabel(8) man pages exactly what happens.

Turning to the source code we see:

in /usr/src/sbin/newfs.c:

Variables declared and initialized to zero


    int     fsize = 0;              /* fragment size */
    int     bsize = 0;              /* block size */


Values set from command line args, if present:

                case 'b':
                        if ((bsize = atoi(optarg)) < MINBSIZE)
                                fatal("%s: bad block size", optarg);


                case 'f':
                        if ((fsize = atoi(optarg)) <= 0)
                                fatal("%s: bad fragment size", optarg);

Read disklabel structure into 'lp' structure, and setup 'pp' as
convenience pointer to the list of partitions from the disk label.

            if (mfs && disktype != NULL) {
                    lp = (struct disklabel *)getdiskbyname(disktype);
                    if (lp == NULL)
                            fatal("%s: unknown disk type", disktype);
                    pp = &lp->d_partitions[1];

(pp is later adjusted to point to the entry for partition in question)


If fsize and bsize have not yet been set to non-zero, use the value
from the partition entry in the disklabel, or failing that either
(fsize) the default value from the parameters at the top of the
disklabel or (bsize) calculate from the fsize value.

            if (fsize == 0) {
                    fsize = pp->p_fsize;
                    if (fsize <= 0)
                            fsize = MAX(DFL_FRAGSIZE, lp->d_secsize);
            if (bsize == 0) {
                    bsize = pp->p_frag * pp->p_fsize;
                    if (bsize <= 0)
                            bsize = MIN(DFL_BLKSIZE, 8 * fsize);


So, in short, the answer to your question is "yes".



Dr Matthew J Seaman MA, D.Phil.                       26 The Paddocks
                                                      Savill Way
PGP: http://www.infracaninophile.co.uk/pgpkey         Marlow
Tel: +44 1628 476614                                  Bucks., SL7 1TH UK
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20030509/a24ca776/attachment.bin

More information about the freebsd-questions mailing list