Repairing boot

Warren Block wblock at
Thu Jul 10 15:26:00 UTC 2014

On Thu, 10 Jul 2014, Luciano Mannucci wrote:

> Hi gurus!
> I'm new to freebsd (I come from linux/solaris/hp-ux). I've messed up
> my startup after upgrading from 9.1 to 9.2 some time ago. Today I
> tried to repair my foxconn amd64 small box via the command
> # boot0cfg -B -s 2 /dev/ada0
> But if I try to boot I get
> F2 ?
> F6 PXE
> Boot: F1
> and it doesn't do anything. If I bootstrap starting from an USB key,
> escaping to boot prompt, issuing a set currdev=disk2p2 followed by
> boot-conf does the trick.
> what have I missed?

"p2" suggests the disk has a GPT partitioning scheme.  The old boot0 
multi-boot loader is not meant for GPT, only MBR.  Writing the normal 
GPT bootcode will fix that particular problem.

Use 'gpart show' to verify that the disk is using GPT and the partition 
number of the freebsd-boot partition.  For example:

% gpart show ada0
=>       34  500118125  ada0  GPT  (238G)
          34          6        - free -  (3.0K)
          40       1024     1  freebsd-boot  (512K)
        1064        984        - free -  (492K)
        2048    4194304     2  freebsd-ufs  (2.0G)
     4196352    4194304     3  freebsd-ufs  (2.0G)
     8390656  491727496     4  freebsd-ufs  (234G)
   500118152          7        - free -  (3.5K)

The first line shows that this disk uses GPT partitioning.

In the third column, "1" is the partition number of the freebsd-boot 
partition.  To write the GPT bootcode:

# gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 ada0

There might still be a problem booting if /etc/fstab refers to disks 
rather than labels and the disk numbers have changed.  If that happens, 
please show the output of 'gpart show' and the contents of /etc/fstab.

More information about the freebsd-questions mailing list