On Wed, 29 Oct 2014, Joel Sing wrote:
> On Tue, 28 Oct 2014, Patrik Lundin wrote:
[snip]
> > Since I am not able to boot on the device i have to run installboot as
> > the last step in the installer. For this i need to add -r /mnt (of
> > course the following is also copied by hand):
> >
> > ===
> > # installbook -v -r /mnt sd0
> > Using /mnt as root
> > installing bootstrap on /dev/rsd0c
> > using first-stage /mnt/usr/mdec/biosboot, second-stage /mnt/usr/mdec/boot
> > sd0: softraid volume with 2 disk(s)
> > sd0: installing boot loader on softraid volume
> > /mnt/usr/mdec/boot is 5 blocks x 16384 bytes
> > wd0a: installing boot blocks on /dev/rwd0c, part offset 4225175
> > master boot record (MBR) at sector 0
> >        partition 3: type 0xA6 offset 64 size 62910476
> > /mnt/usr/mdec/biosboot will be written at sector 64
> > wd0d: installing boot blocks on /dev/rwd0c, part offset 4209110
> > master boot record (MBR) at sector 0
> >         partition 3: type 0xA6 offset 64 size 62910476
> > /mnt/usr/mdec/biosboot will be written at sector 64
> > ===
>
> A CRYPTO key disk is slightly special in that it has softraid metadata but
> is not technically part of the same volume (well, it is in some ways but it
> is not in others). The problem in question occurs since installboot(8)
> installs the first stage boot loader on each chunk that is a member of the
> volume - in this case it installs first stage boot loader twice (once for
> wd0a and again for wd0d). The second stage boot loader is installed in the
> softraid metadata area for the sd0 volume, however in the case of a CRYPTO
> key disk its metadata area does not end up with a copy of the boot of the
> second stage loader (unlike, say a RAID 1 chunk). If the first stage boot
> blocks are installed in the CRYPTO volume then the key disk, the boot
> loader (in the PBR of wd0) will end up pointing at a boot storage area (of
> the key disk) that does not contain the second stage boot loader. The fix
> is to probably avoid installing the boot loader on the key disk.

You could try this (only compile tested) diff:

Index: i386_softraid.c
===================================================================
RCS file: /cvs/src/usr.sbin/installboot/i386_softraid.c,v
retrieving revision 1.2
diff -u -p -r1.2 i386_softraid.c
--- i386_softraid.c     9 Jun 2014 13:13:48 -0000       1.2
+++ i386_softraid.c     28 Oct 2014 14:21:27 -0000
@@ -42,6 +42,7 @@ void  sr_install_bootldr(int, char *);
 void
 sr_install_bootblk(int devfd, int vol, int disk)
 {
+       struct bioc_vol bv;
        struct bioc_disk bd;
        struct disklabel dl;
        struct partition *pp;
@@ -56,6 +57,15 @@ sr_install_bootblk(int devfd, int vol, i
        bd.bd_diskid = disk;
        if (ioctl(devfd, BIOCDISK, &bd) == -1)
                err(1, "BIOCDISK");
+
+       /* Skip CRYPTO key disks. */
+       /* XXX - pass volume in rather than volume ID. */
+       memset(&bv, 0, sizeof(bv));
+       bv.bv_volid = vol;
+       if (ioctl(devfd, BIOCVOL, &bv) == -1)
+               err(1, "BIOCVOL");
+       if (bv.bv_level == 'C' && bd.bd_size == 0)
+               return;
 
        /* Check disk status. */
        if (bd.bd_status != BIOC_SDONLINE && bd.bd_status != BIOC_SDREBUILD) {

-- 

    "Action without study is fatal. Study without action is futile."
        -- Mary Ritter Beard

Reply via email to