Solved [Solved] "missing boot loader" and boot0 issues

Today, when I started my PC with FreeBSD 9.2 I got this message: "missing boot loader". I'm a newbie to FreeBSD so until now I made a couple of installations of this SO and tried to configure SMB and DLNA (miniDLNA) services but I'm not much experienced, so maybe I'm asking something simple or stupid. In that case excuse me.

I have three disks: ada0 and ada2 are two disks with one partition each for store media and ada1 is the disk with FreeBSD installed, with swap, boot, / partitions. Only later I discovered that the problem may be caused by the "reset" of the BIOS caused by the discharge of the battery of the PC (and so the BIOS tried to boot from the wrong disk), but before thinking that, I thought that something in the MBR was gone wrong and so I tried to restore it (now the setup of the BIOS is correct).

I started a live CD in single user and with gpart show I could see that every disk/partition is still there and so I tried to reload the boot manager with boot0cfg -B ada1. This restored the boot manager and now, when I turn on the PC, I don't get the "missing boot loader" error, the boot loader runs and I got the list of choices like this:
Code:
F1  ?
F5  Drive 1

F6  PXE
Boot:  F1
Now, it seems it doesn't "understand" that there is FreeBSD installed on the HDD and if I hit F1 or if I don't do anything the result is the same: the system prompts a list of hash signs near F1, like
Code:
Boot:  F1 ######
if I hit F1 the system prompts a #, and also while the time passes by, the system prompts #. If I hit F5 it returns
Code:
Missing boot loader
, I guess because there is no CD.

I tried also the command fdisk -B ada1 confirming the change of boot code but denying the change of the partition table but the result is the same. I also tried to restore the boot loader launching sysinstall from a live CD, I entered in the menu Fdisk, I didn't make any change to the partition table and when I confirm the utility prompts me if I want to install an MBR, I select one and it returns me
Code:
chunk [....] [....] does not start on a track boundary
for each partition of the disk I selected (I put "[....]" instead of the chunks).

Now I'm scared to have lost all data stored (the PC was used also as SMB and DLNA server), and I have a couple of questions:
  1. Is it possible to launch the SO installed on the PC without the boot loader installed for verify that the SO is OK? For example starting it from a live CD?
  2. If not 1, is it possible to verify the data stored in the HDD without using the SO in it? (if 1 is possible I can verify the data easily)
  3. If the data stored are still there and the SO is OK, what could be wrong with the boot loader? How can i restore it?
Thanks in advance.
 
Re: "missing boot loader" and boot0 issues

If you've installed FreeBSD 9.2, did you use the installer or did you use the shell to create your partitions? Because I'm wondering if your disk has been partitioned with gpart, and if so, has it been partitioned using the GPT scheme?
Code:
gpart show
will give you this information, and you can use the CD installer to check that.

If you really installed your system with MBR partition, then I'm sorry but I don't have the skills for MBR.

If it is a GPT scheme, then I guess the boot0cfg command was inappropriate. You should have identified which of the partition on your disk is the boot partition, that should be referred as freebsd-boot on that one.

For example:
Code:
% gpart show
=>        34  3906963565  da0  GPT  (1.8T)
          34           6       - free -  (3.0K)
          40        1024    1  freebsd-boot  (512K)
        1064    33554432    2  freebsd-swap  (16G)
    33555496  3873408096    3  freebsd-zfs  (1.8T)
  3906963592           7       - free -  (3.5K)

There's an index right before the partition type, in the sample here it is 1. If I read you well, it should be 2 for you, but I think you'll have to check anyway. You can then try to restore the bootcode and if your disk is ada1:

For a UFS installation:
gpart set -a active -i 2 ada1
gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 2 ada1

For ZFS installation:
gpart set -a active -i 2 ada1
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 2 ada1

And then reboot and pray. With hopes I did not miss anything or that I didn't write anything wrong ... :)
 
Re: "missing boot loader" and boot0 issues

@yom is correct: boot0cfg() is for MBR, not GPT. It will install a multiboot loader in the GPT PMBR, which is not going to work.

The instructions are not quite right. Partitions should not be set active on GPT. Just reinstall the bootcode and PMBR on the drive. Typically, the freebsd-boot partition is the first one, but that's not required. So boot the installer disk, select Shell, and show the output of gpart show.
 
Last edited by a moderator:
Re: "missing boot loader" and boot0 issues

Ok, in fact it's a GPT scheme, here the result of gpart show:
Code:
=>              34   586070188   ada0     GPT    (279G)
                34   585105408       1   freebsd-ufs   (279G)
         585105442      964780             - free -  (471M)

=>              34  312581741   ada1     GPT    (149G)
                34         128       1   freebsd-boot   (64K)
               162   304086912       2   freebsd-ufs  (145G)
         304087074     8388608       3   freebsd-swap  (4.0G)
         312475682      106093            - free -  (51M)

=>              34   976773101   ada2     GPT    (465G)
                34   975175680       1   freebsd-ufs   (465G)
         975175714      1597421             - free -  (780M)

Sorry for the alignment, but I had to manually copy the prompt from the other PC :)
 
Re: "missing boot loader" and boot0 issues

gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 ada1

ada0 and ada2 are not bootable because they have no freebsd-boot partition.
 
Re: "missing boot loader" and boot0 issues

Perfect @wblock, works fine, thanks!

So, considering the command you suggested me, the GPT scheme needs both bootstrap code embedded in the partitioning scheme (-b option) and a bootstrap code located in a specific partition (-p option). Reading the gpart() reference i didn't understood this.

Thanks.
 
Last edited by a moderator:
Re: "missing boot loader" and boot0 issues

Muzz said:
Perfect @wblock, works fine, thanks!
So, considering the command you suggested me, GPT scheme needs both bootstrap code embedded in the partitioning scheme (-b option) and a bootstrap code located in a specific partition (-p option).
Reading the gpart reference i didn't understood this.

Thanks.

The embedded bootstrap code that is installed with -b /boot/pmbr is actually called MBR boot code, it is mandatory on BIOS systems for booting regardless of the actual partitioning scheme used but not needed anymore with UEFI.
 
Last edited by a moderator:
Back
Top