# New install not bootable



## morsing (Nov 12, 2021)

Hi all,

I have decided to return to FreeBSD after leaving it at version 4.8. Installed v13 but have still not managed to get it to boot.

PC has two disks, one with Windows and one with the new FReeBSD installation. When I go into BIOS and boot directly from the FreeBSD disk, I get something like "F1  ?" and then F% (Windows disk?) and F6 etc...

If I do F1... My memory escapes me, I think it starts printing # every ten seconds or something? I need to check again.

Why does this not work? I tried re-installing saying "GPT/UEFI" instead of "GPT/BIOS" but it didn't help.

Does "F1" mean the first slice? Is that what's wrong? I booted in from the installer and typed "boot0cfg -B ada1" and it accepted it but it has not fixed it either.

Thanks for any advice.


----------



## SirDice (Nov 12, 2021)

boot0cfg(8) is the old boot manager. That's what's giving you the F1, F2 boot options. That only works for MBR though, it's not meant to be used with GPT.



morsing said:


> I tried re-installing saying "GPT/UEFI" instead of "GPT/BIOS" but it didn't help.


So, how does the system normally boot Windows? Through EUFI boot or CSM (aka classic BIOS boot)? If you choose the ZFS install you can pick EUFI+BIOS, that will create partitions for both ways (and you can easily switch between those boot options).


----------



## morsing (Nov 12, 2021)

Ok, thanks. I just found that by Googling, however, even when I do a fresh install it does the F1/F5 menu on boot. Why is the install failing to set this up correctly?

Thanks


----------



## SirDice (Nov 12, 2021)

Boot the install media and select "Shell" instead of install. Then have a look with `gpart show` and post that information here. Then we can have a look at what you actually have. The solution to fix this really depends on how the system is set up, so I can't just give you a couple command to fix it.


----------



## morsing (Nov 13, 2021)

Hi,

Screenshots below.


----------



## Alain De Vos (Nov 13, 2021)

You might try to use:








						EasyBCD
					

EasyBCD is a software utility for Windows that lets you control and configure the BCD/BOOTMGR bootloader for Windows Vista, Windows 7, Windows 8, and Windows 10 for dual-boots.




					neosmart.net
				



I don't know if refind is usable ?


----------



## morsing (Nov 13, 2021)

Alain De Vos said:


> You might try to use:
> 
> 
> 
> ...



Thanks, it certainly looked promising. It's probably not EasyBCD's fault, it adds the boot entry, but when I use it, the PC just resets and starts over. I tried setting it to boot both slice 1 and 3, not sure which is correct.


----------



## Alain De Vos (Nov 13, 2021)

PS: Linux grub can also be really good for booting freebsd. I personally use it in this way. 
So if you can dual boot boot windows/linux. A few lines  in linux grub config and you boot into freebsd.


----------



## grahamperrin@ (Nov 13, 2021)

From the presence of the EFI system partition on ada1, I assume that the computer is EFI boot capable, in which case (yes, Alain) rEFInd might help to begin booting FreeBSD.

Then efibootmgr(8) might be used.

No ESP partition on ada0, which holds the installation of Windows.

Maybe a stupid question: if Windows was installed whilst UEFI boot was *not* enabled, then will it lend itself to booting through a utility such as rEFInd?



morsing said:


> … slice 1 and 3, not sure which is correct.



Aim for the ESP at 1. 

The ESP should include what's required to (then) boot from the freebsd-zfs partition.



> … resets and starts …



Can you describe the reset; what exactly happens before the (re)start? 

Share a photograph, if you like.



> … EasyBCD… adds the boot entry, …



How so? Does it write something to a partition? (I'm not familiar with this utility.)


----------



## grahamperrin@ (Nov 13, 2021)

Also, please, a photograph of the results of these two commands:

`gpart show ada1`

`fstyp /dev/ada1p1`


----------



## morsing (Nov 13, 2021)

Alain De Vos said:


> PS: Linux grub can also be really good for booting freebsd. I personally use it in this way.
> So if you can dual boot boot windows/linux. A few lines  in linux grub config and you boot into freebsd.



I don't think I can do that without having Linux installed?

Also, the boot loader is no longer the problem, the FreeBSD install resets the PC when I try to boot.


----------



## morsing (Nov 13, 2021)

grahamperrin said:


> From the presence of the EFI system partition on ada1, I assume that the computer is EFI boot capable, in which case (yes, Alain) rEFInd might help to begin booting FreeBSD.
> 
> Then efibootmgr(8) might be used.


From the FreeBSD installer shell?



grahamperrin said:


> No ESP partition on ada0, which holds the installation of Windows.
> 
> Maybe a stupid question: if Windows was installed whilst UEFI boot was *not* enabled, then will it lend itself to booting through a utility such as rEFInd?



I don't know. It a long time ago I installed the Windows disk, I do remember having a bit of a situation which may have been EFI.




grahamperrin said:


> Aim for the ESP at 1.
> 
> The ESP should include what's required to (then) boot from the freebsd-zfs partition.
> 
> ...



Not much to see. I click on "FreeBSD" and the screen goes black, then BIOS starts over.



grahamperrin said:


> How so? Does it write something to a partition? (I'm not familiar with this utility.)



I don't know but I assume it puts stuff in the EFI partition. Seems like a cool and extremely comprehensive tool.

At the moment, the EFI boot menu (Windows) does have the FreeBSD partitions. I'm thinking if I point it to the EFI partition (1) on ADA1, it will just loop. I tried partition 3, but that's where it resets.

When I installed FreeBSD, it asked me if I wanted GPT/BIOS or GPT/UEFI, and recommended GPT/BIOS. Why did it recommend that?


----------



## grahamperrin@ (Nov 13, 2021)

morsing said:


> … Why did it recommend that?



A person might want, or need, to use non-UEFI boot in a UEFI-capable environment; or the person might intend to move the disk from a UEFI-capable computer to one that's not so capable.



morsing said:


> … From the FreeBSD installer shell? …



If it's not a minimal installer, then yes, I assume that efibootmgr will be available.



morsing said:


> … the EFI boot menu (Windows) …



Despite working with hundreds of installations of Windows, I might never have seen this.



morsing said:


> … if I point it to the EFI partition (1) on ADA1, it will just loop. …



Please do try.


----------



## morsing (Nov 14, 2021)

Ok, I have video'd the boot process, tried 1st slice the first time, 2nd slice the second time:



			http://www.morsing.cc/Videos/Booting.mp4
		


Apologies for the awful quality, I have recently switched to an Android phone.

At the first F-menu, I don't touch any keys, it eventually just boots. The second time round I eventually hit F1.

Thanks


----------



## grahamperrin@ (Nov 15, 2021)

I guess, if `volume 2` = `ada1` then the presentation of _anything_ on the device as Windows 10 is either: 

a *mis*representation; or
a sign that the content of the EFI system partition has been spoilt.


----------



## morsing (Nov 15, 2021)

grahamperrin said:


> I guess, if `volume 2` = `ada1` then the presentation of _anything_ on the device as Windows 10 is either:
> 
> a *mis*representation; or
> a sign that the content of the EFI system partition has been spoilt.



Hi,

It can't really be a mis-representation as it works.

If only I could get FreeBSD to boot without EFI...


----------



## Vull (Nov 15, 2021)

morsing said:


> Hi,
> 
> It can't really be a mis-representation as it works.
> 
> If only I could get FreeBSD to boot without EFI...


To boot a zfs system without EFI, I belileve you need a freebsd-boot partition. For example, on my cheap HP laptop:
	
	



```
demo@fzfs:~ $ gpart show
=>      40  61079472  mmcsd0  GPT  (29G)
        40    532480       1  efi  (260M)
    532520      1024       2  freebsd-boot  (512K)
    533544       984          - free -  (492K)
    534528   4194304       3  freebsd-swap  (2.0G)
   4728832  27262976       4  freebsd-zfs  (13G)
  31991808  29085696       5  linux-data  (14G)
  61077504      2008          - free -  (1.0M)
```

A freebsd-boot partition should have been automatically created by the 13.0-RELEASE installer if you selected Auto ZFS. I'm curious as to why your gpart output doesn't show one.

On disk 0 (/dev/ada0), you have 2 NTFS partitions and no EFI partition, which suggests you have a Windows system which has been using BIOS booting all along, and therefore, you are not using EFI boot. The EFI partition on disk 1 (/dev/ada1) was probably created by the 13.0-RELEASE installer, but it should have no effect on a BIOS boot system.

My surmise is that the reason your FreeBSD system isn't booting is because it lacks a freebsd-boot partition for some unknown reason. I don't know why you don't have a freebsd-boot partition. Maybe the Windows system on disk 0 ate it? I just don't know.

If this is a fresh install your easiest option might be to simply re-install FreeBSD.


----------



## morsing (Nov 15, 2021)

Vull said:


> To boot a zfs system without EFI, I belileve you need a freebsd-boot partition. For example, on my cheap HP laptop:
> 
> 
> 
> ...



Thanks,

I have re-installed several times, but I will try again, with your added information.


----------



## Vull (Nov 15, 2021)

morsing said:


> Thanks,
> 
> I have re-installed several times, but I will try again, with your added information.


I can't remember for sure, but I think there might be a "guided" option for an automatic zfs install, which would let you inspect the partition layout before committing it to disk. To make sure it's creating the freebsd-boot partition.


----------



## _martin (Nov 15, 2021)

What is da0 on your computer ? Is it a USB stick you're booting from? Could that legacy code be leftover on that disk from previous installation?
If you can reinstall it from scratch, which I'm assuming you can, do it again. As this is PC it doesn't hurt to detach the Windows disk, just in case.
Boot the FreeBSD installation media, go to the shell and do this:

1) verify you are working on a free disk (ada1 in your output). If you've detached Windows disk it's even better, there's no other disk there. You can use:
`camcontrol devlist
gpart show`

2) erase all partitions on that disk. WARNING: pay attention to what you're doing.
You can use `gpart destroy -F adaX` where adaX is your disk. For a good measure do some initial dd-ing on it too: `dd if=/dev/zero of=/dev/adaX bs=512 count=10240`

3) type `exit` and return to the installer. Use GPT layout, EFI.

Maybe small refresher wouldn't hurt:  FreeBSD (at least on i386/x86_64) supports two layouts to boot from: MBR or GPT.  MBR disk can be divided into 4 primary partitions only. As a workaround one of this partitions can be pseudo partition that defines other partitions in the boundary of its size. In DOS/Windows this was a logical partition. FreeBSD used different terminology: these MBR partitions are called slices. Slice can be divided further into partitions ( hence the names ada0s1a, ada0s1b, ..).  Note MBR means two things in our context: either the partition layout or the actual code/record on the disk. This too can be confusing sometimes.
GPT solved this problem, you can (practically) define as much partitions as you want without a need to do this magic above. You need GPT layout for UEFI.

BIOS is responsible for finding the disk and booting from it. Your BIOS is UEFI capable with legacy support. So you can boot either legacy (CSM, compatibility support mode) or native UEFI.
As your HW supports GPT and UEFI I strongly advise you to use it.

Disk layout defines what bootloader choices you have. With MBR disk layout you need to use MBR boot code with all its legacy stuff (as SirDice mentioned above - boot0cfg).
With GPT you have two options -- do the legacy boot with MBR (note: here mbr doesn't mean disk layout but rather the boot itself) or do the UEFI boot. Actually you can have both prepared on a GPT disk and choose either option depending on BIOS. GPT uses pmbr in its bootcode. P stands for protective -- it protects itself from the legacy tools that don't understand GPT layout by defining fake MBR partition. In UEFI boot code from this section is not used.
One note, I can't confirm 100% though, I think even UEFI requires to have magic 0xaa55 in the end of MBR marking it as bootable disk.

For example my disk da0:

```
# gpart show
=>       40  104857520  da0  GPT  (50G)                    ; GPT disk
         40     532480    1  efi  (260M)                   ; EFI partition , UEFI boot looks for this
     532520       1024    2  freebsd-boot  (512K)          ; legacy code ; pmbr loads code from here and continues
     533544        984       - free -  (492K)
     534528    4194304    3  freebsd-swap  (2.0G)          ; swap
    4728832  100126720    4  freebsd-zfs  (48G)            ; zfs pool
  104855552       2008       - free -  (1.0M)
```

Bootcode that is used on partition 2 (freebsd-boot) depends on what / is on. This is why you need to specify partition code in legacy boot by, in this case,  `gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 2 da0`.

EDIT: I fixed few typos + I had time to look at UEFI standard: yes, signature 0xaa55 is mandatory in pmbr.


----------



## astyle (Nov 15, 2021)

In the past, the strategy I'd employ in such situations is to first have a working Windows install, then use a 3rd party partition manager (GParted or EasyBCD (recommended by Alain De Vos in post #6)) to prepare space for FreeBSD, and after that, the FreeBSD installer should be able to find the prepared partition and install to it. 

Sometimes, I did find it easier to just do a clean reinstall of both OS'es than to hunt around for details to make the bootloader happy. Either approach has its merits and pitfalls, it's just a matter of deciding what you're willing to spend time on


----------



## morsing (Nov 15, 2021)

Thanks _martin for that comprehensive explanation, it works now. Wiping the disk completely made the installer setup the disk correctly.

Thanks everyone.


----------

