Installing bootcode

Not sure how it happened, but after an upgrade from 10.1 to get 10.4, the server boots to an OK prompt and I have to do the following to boot:

Code:
set currdev=disk0s1a

I understand I need to install the bootcode to fix, what command would I use? Here is the disk info:

Code:
root@www:~ # gpart show
=>       34  419430333  ada0  GPT  (200G)
         34  417333246     1  freebsd-ufs  (199G)
  417333280    2097087        - free -  (1.0G)

=>      63  41942977  ada1  MBR  (20G)
        63  41929587     1  freebsd  [active]  (20G)
  41929650     13390        - free -  (6.5M)

=>       0  41929587  ada1s1  BSD  (20G)
         0   1024000       1  freebsd-ufs  (500M)
   1024000    524288       2  freebsd-swap  (256M)
   1548288  20480000       4  freebsd-ufs  (9.8G)
  22028288  19901299       5  freebsd-ufs  (9.5G)
root@www:~ # cat /etc/fstab
# Device                Mountpoint      FStype  Options         Dump    Pass
/dev/ada1s1b            none            swap    sw              0       0
/dev/ada1s1a            /               ufs     rw              1       1
/dev/ada1s1d            /usr            ufs     rw              2       2
/dev/ada1s1e            /var            ufs     rw              2       2
/dev/ada0p1             /www            ufs     rw              0       0
/dev/acd0               /cdrom          cd9660  ro,noauto       0       0
 
Not sure how it happened, but after an upgrade from 10.1 to get 10.4, the server boots to an OK prompt and I have to do the following to boot:

Code:
set currdev=disk0s1a

I understand I need to install the bootcode to fix, what command would I use? Here is the disk info:

Code:
root@www:~ # gpart show
=>       34  419430333  ada0  GPT  (200G)
         34  417333246     1  freebsd-ufs  (199G)
  417333280    2097087        - free -  (1.0G)

=>      63  41942977  ada1  MBR  (20G)
        63  41929587     1  freebsd  [active]  (20G)
  41929650     13390        - free -  (6.5M)

=>       0  41929587  ada1s1  BSD  (20G)
         0   1024000       1  freebsd-ufs  (500M)
   1024000    524288       2  freebsd-swap  (256M)
   1548288  20480000       4  freebsd-ufs  (9.8G)
  22028288  19901299       5  freebsd-ufs  (9.5G)
root@www:~ # cat /etc/fstab
# Device                Mountpoint      FStype  Options         Dump    Pass
/dev/ada1s1b            none            swap    sw              0       0
/dev/ada1s1a            /               ufs     rw              1       1
/dev/ada1s1d            /usr            ufs     rw              2       2
/dev/ada1s1e            /var            ufs     rw              2       2
/dev/ada0p1             /www            ufs     rw              0       0
/dev/acd0               /cdrom          cd9660  ro,noauto       0       0

You might merely need to install the bootcode, which would be something like this: gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 ada0.

gpart():
Code:
   GPT
     In    this example, we will format ada0 with the GPT scheme and create boot,
     swap and root partitions.    First, we need to create the partition table:

       /sbin/gpart create -s GPT ada0

     Next, we install a    protective MBR with the    first-stage bootstrap code.
     The protective MBR    lists a    single,    bootable partition spanning the    entire
     disk, thus    allowing non-GPT-aware BIOSes to boot from the disk and    pre-
     venting tools which do not    understand the GPT scheme from considering the
     disk to be    unformatted.

       /sbin/gpart bootcode    -b /boot/pmbr ada0

     We    then create a dedicated    freebsd-boot partition to hold the second-
     stage boot    loader,    which will load    the FreeBSD kernel and modules from a
     UFS or ZFS    filesystem.  This partition must be larger than    the bootstrap
     code (either /boot/gptboot    for UFS    or /boot/gptzfsboot for    ZFS), but
     smaller than 545 kB since the first-stage loader will load    the entire
     partition into memory during boot,    regardless of how much data it actu-
     ally contains.  We    create a 472-block (236    kB) boot partition at offset
     40, which is the size of the partition table (34 blocks or    17 kB) rounded
     up    to the nearest 4 kB boundary.

       /sbin/gpart add -b 40 -s 472    -t freebsd-boot    ada0
       /sbin/gpart bootcode    -p /boot/gptboot -i 1 ada0
 
Ok, makes sense and ada0 is GPT, but I get an error when trying to do so:

Code:
root@www:~ # gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 ada0
gpart: /dev/ada0p1: Operation not permitted
 
It looks like you're booting from ada1, not ada0. Why the odd order?

Don't write the gptboot(8) to anywhere, you don't have the necessary freebsd-boot partition for it. Which leads me to believe you're actually booting from ada1 using a 'traditional' MBR boot.
 
This is a VM, it put the secondary disk first when we migrated from another host. I should remove and put back in the order to make the system partitions disk first ada0 and then use the fdisk below to reinstall the boot code?

Code:
fdisk -B -b /boot/boot0 ada0

Or does this really matter and I should be able to install to ada1 as is?
 
You can try both, it won't hurt to have a boot record on both disks. It's also possible it picks up the boot record from ada0 and then continues to boot from ada1. But it's a confusing set up, so if you can swap them it would be better in the long-run as there's less confusion about which drive is used to boot from. Note however if you do swap them you'd need to adjust fstab too.
 
Back
Top