Subject: Re: pmax miniroot bootblocks...
To: Jason Thorpe <thorpej@nas.nasa.gov>
From: Chris G Demetriou <Chris_G_Demetriou@UX2.SP.CS.CMU.EDU>
List: port-pmax
Date: 03/28/1996 13:05:30
>  > *However*, and this is the point, I can't find any way to write
>  > a bootblock (or disklabel) to those 16 sectors.  Is this deliberate
>  > or a bug?  If it's deliberate, why are things set up that way?
> 
> What I would to is dd the disklabel and bootblocks to a file (in 
> whichever order, and with proper spacing), have dd pad that out to 
> 512-bytes, then dd if=/dev/zero of=file skip=n where n the the number of 
> blocks that the other pieces took up...the disklabel should have 
> partition a at offset 0 ... then newfs the vnd, and it Should Work.
> 
> This would all be much easier if the vnd supported disklabels itself...

"no it wouldn't."


If you use disklabel with '-r', or another option that implies -r
(like -B), then rather than going through the kernel disklabel ioctls,
it writes it directly.  This is ... rather useful, especially for
exactly this situation.

Consider the NetBSD/i386 "distrib/i386/floppies/kc-common/Makefile.inc"
process to build a boot floppy:

all: ${CBIN}
        dd if=/dev/zero of=${IMAGE} bs=100k count=12
        vnconfig -v -c ${VND_DEV} ${IMAGE}
        disklabel -w -B -b ${MDEC}/fdboot -s ${MDEC}/bootfd ${VND} floppy5
        newfs -O -m 0 -o space -i 6144 -c 80 ${VND_RDEV} floppy5
        mount ${VND_DEV} ${MOUNT_POINT}
        mtree -def ${MTREE} -p ${MOUNT_POINT}/ -u
        TOPDIR=${TOP} CURDIR=${.CURDIR} OBJDIR=${.OBJDIR} \
            TARGDIR=${MOUNT_POINT} sh ${TOP}/runlist.sh ${LISTS}
        @echo ""
        @df -i ${MOUNT_POINT}
        @echo ""
        umount ${MOUNT_POINT}
        vnconfig -u ${VND_DEV}
        cat /*bin/* > /dev/null

That _DOES_ successfully write the disklabel (though disklabels on
floppies are unused), and the boot blocks to the 'vnd'-mapped image
of the floppy.  See the various relevant i386 floppy build makefiles
to see what the variables get set to.


Don't forget the 'cat' at the end, lest you have strange results...
'vnd' uses an ... evil hack to set up credentials for NFS: it reads
the first block of the file, via VOP_READ(), which gets it into the
buffer cache.  If it's never written (which it isn't) it'll not become
inconsistent, and all you have to do is flush it (which the cat does).
Otherwise, you may get ... strange contents, reading from the file.


cgd