# FreeBSD 11.1 on SSD hard drive is not booting



## BackOrder (Sep 2, 2017)

Installing FreeBSD 11.1 on a normal SATA drive using MBR+UFS is working just fine. Now I upgraded to a Samsung SSD 850 Pro but it's not booting. I would preferably like to use MBR+ZFS but even MBR+UFS is reporting "Missing operating system".

How to fix this problem?


----------



## aa (Sep 2, 2017)

Have you set the active partition on the boot disk's MBR?


----------



## BackOrder (Sep 2, 2017)

It was already set (default install options) but I did unset and set again for the kicks. No difference.


----------



## aa (Sep 2, 2017)

It's either BIOS or MBR problem, I guess installer did put the right bootcode on MBR didn't it? I reckon there was an option to put bootmanager when installing FreeBSD.


----------



## BackOrder (Sep 2, 2017)

My BIOS setup works with the previous installation on a normal SATA disk (MBR+UFS). I did try every combination on the SSD drive MBR+UFS, ZFS (MBR, GPT, GPT + Active, etc.). Also tried BIOS vs UEFI but this computer doesn't like too much UEFI (unless it's a USB key).

Interestingly, had a OpenSUSE USB key laying around, it found the partition on the SSD drive and boot on it. FreeBSD is in working condition. So the installation is not damaged but the MBR is not doing its job.


----------



## aa (Sep 2, 2017)

Or maybe the bootcode was never been there.
I used to put the generic one with `FDISK /MBR`, from DOS, yes DOS


----------



## BackOrder (Sep 2, 2017)

Well, it ain't working either. I used *Paragon Hard Disk Manager* based on your suggestion and corrected MBR. It still complains about "Missing operating system" on boot. Best guess is that MBR is already working.

Booting on FreeBSD USB media and ran shell, gpart show won't show the zfs partition anymore (it was /dev/ada0s1 during installation).

Any idea?


----------



## BackOrder (Sep 2, 2017)

Installed Windows to see if it would work. Windows boots on SSD without problems.


----------



## aa (Sep 2, 2017)

I don't have clue a about how zfs partition laid-out, but for ufs partition to boot, you have to put freebsd's bootcode on it, file: /boot/boot. The second sector is where the freebsd's slice table reside, so you may not overwrite it either.

You have to get current slice table, merge it with /boot/boot and copy it back. So copy /boot/boot to bootcopy somewhere, get/put the current slice table to it, and save it back to partition, example format: ada0s1 (MBR) or ada1p2 (GPT):


```
cp /boot/boot /tmp/bootcopy
dd if=/dev/ada0s1 count=1 skip=1 of=/tmp/bootcopy seek=1 conv=notrunc
dd if=/tmp/bootcopy of=/dev/ada0s1
```
That's too much hassle for first install, useful only for existing system which you have to keep the existing data.


----------



## Minbari (Sep 2, 2017)

Maybe it's a Samsung SSD firmware problem. I don't own a Samsung SSDs so I can't test them, I have only Crucial/Micron SSDs.


----------



## k.jacker (Sep 2, 2017)

The fact you say it boots from a normal SATA drive but not from an SSD makes me think you not just used MBR boot code, but whole MBR partitioning scheme.
To my knowledge a SSD should be using GPT partitionioning scheme as it does not have heads/sectors the the MBR partitioning uses vs logical block access (LBA) in GPT.

It shouldn't be neccessary to manually configure anything by hand during the install.
Use GPT with MBR bootcode in the installer.


----------



## BackOrder (Sep 2, 2017)

aa said:


> ```
> cp /boot/boot /tmp/bootcopy
> dd if=/dev/ada0s1 count=1 skip=1 of=/tmp/bootcopy seek=1 conv=notrunc
> dd if=/tmp/bootcopy of=/dev/ada0s1
> ...



Agreed, it's much hassle but it would be a one time thing anyway. So I tried what you just said and the last dd gives me a "operation not permitted". A *sysctl kern.geom.debugflags=0x10* did not help either.



Minbari said:


> Maybe it's a Samsung SSD firmware problem. I don't own a Samsung SSDs so I can't test them, I have only Crucial/Micron SSDs.



How would it be a firmware problem? Windows and Linux are both fine with it.


----------



## BackOrder (Sep 2, 2017)

k.jacker said:


> The fact you say it boots from a normal SATA drive but not from an SSD makes me think you not just used MBR boot code, but whole MBR partitioning scheme.
> To my knowledge a SSD should be using GPT partitionioning scheme as it does not have heads/sectors the the MBR partitioning uses vs logical block access (LBA) in GPT.
> 
> It shouldn't be neccessary to manually configure anything by hand during the install.



It makes sense. Windows is also using GPT. The default ZFS installation is GPT (BIOS+UEFI) which should be absolutely working right out-of-the-box. Unfortunately, it won't list the SSD drive in the BIOS when using this configuration. And yet OpenSUSE USB media will successfully boot FreeBSD.

It comes to a point that perhaps installing grub2 to help boot on FreeBSD would be an option. A weird one though.


----------



## k.jacker (Sep 2, 2017)

If the SSD does not show up as a bootable device in BIOS with MBR bootcode, than your BIOS is most likeley not set to boot in legacy mode.

When you bootet FreeBSD from your SATA harddrive and the beasty boot screen showed up in big font (80x25) than your where booting in legacy mode (MBR bootcode), was it in small fonts than you booted in UEFI mode (EFI bootcode).
Try playing with legacy and UEFI settings in your BIOS to understand what's going on.


----------



## BackOrder (Sep 2, 2017)

k.jacker said:


> If the SSD does not show up as a bootable device in BIOS with MBR bootcode, than your BIOS is most likeley not set to boot in legacy mode.
> 
> When you bootet FreeBSD from your SATA harddrive and the beasty boot screen showed up in big font (80x25) than your where booting in legacy mode (MBR bootcode), was it in small fonts than you booted in UEFI mode (EFI bootcode).
> Try playing with legacy and UEFI settings in your BIOS to understand what's going on.



Let me clarify: it does show up when installed as MBR but will boot with "Missing operating system". It will NOT show up when installed as GPT (BIOS+UEFI).

Legacy mode is enabled. I tried both with and without.

There is no UEFI settings in BIOS anymore. Asus got rid of them in a BIOS update (for whatever reason). UEFI does work on USB sticks though.


----------



## k.jacker (Sep 2, 2017)

Could you please post the output from `gpart show ada0` assuming /dev/ada0 is your SSD.

I have never used BIOS+UEFI from the installer but it look like your mobo searches for UEFI bootcode first. So even if you have MBR bootcode as well, that is ignored.

Do you have small fonts in the beasty boot screen when you boot from your harddisk with that same bootcode?


----------



## BackOrder (Sep 2, 2017)

k.jacker said:


> Could you please post the output from `gpart show ada0` assuming /dev/ada0 is your SSD.
> 
> I have never used BIOS+UEFI from the installer but it look like your mobo searches for UEFI bootcode first. So even if you have MBR bootcode as well, that is ignored.
> 
> Do you have small fonts in the beasty boot screen when you boot from your harddisk with that same bootcode?



Thanks for helping me on this one. It's weird because Windows, OpenSUSE and Ubuntu are all fine with the new hard drive. FYI, FreeBSD 12 current isn't doing any better than 11.1.

The following is automatically created by the installer. GPT (BIOS only) + ZFS.


```
40 500118112 ada0 GPT (238G)
       40      1024 1 freebsd-boot (512K)
     1064       984  - free - (492K)
     2048   4194304 2 freebsd-swap (2.0G)
  4196352 495921152 3 freebsd-zfs (36G)
500117504       648 - free - (324K)
```

Not sure what you mean about the fonts. I use an external monitor and it shows in 80x25.


----------



## aa (Sep 2, 2017)

The bootcode /boot/boot is for *MBR/UFS *only.
As the name implied, for GPT/UFS use /boot/gptboot, for GPT/ZFS use /boot/gptzfsboot.
But it should have been taken care by the installer, I guess, I never used the installer anymore, just prepare the partitions (disklabeling/gparting), then extract all the tgz/txz.


----------



## k.jacker (Sep 2, 2017)

Hei BackOrder,

SIDEINFO: what I ment about the font is, that it's a good indicator what your motherboard is actually doing.
If you got those 80x25 oldschool fontsize when booting, you're in BIOS mode.
If the font is tiny like on linux when you boot, than you are booting in UEFI mode.


Ok, your mobo is booting in BIOS mode and there is only BIOS bootcode on your SSD.
Maybe it has been installed bootcode for UFS, but you need that for ZFS /boot/gptzfsboot like aa allready said, worth a try.

TRY INSTALLING THE RIGHT BOOTCODE:
Boot into the FreeBSD installer and exit to shell...
`gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada0`

If you still can't boot, switch to UEFI bootcode as you seem to have a modern motherboard.
Again, boot into  the FreeBSD installer and drop to shell...
`gpart modify -t efi -i 1 ada0`
`gpart bootcode -p /boot/boot1.efi -i 1 ada0`

Try to boot...


----------



## BackOrder (Sep 2, 2017)

k.jacker I tried what you suggested but without success.

FreeBSD 11.1 has nicer fonts (and 800x600 resolution) than 9.3/10.3. Trying to install FreeBSD 9.3 was a bit of a reveal because MBR+ZFS did boot but prompted mountroot to manually specify the root mount point because it's not finding ZFS. Now following instructions at http://daemon-notes.com/articles/system/install-zfs/gpart did help to boot on MBR (installing simple MBR and the first dd on ada0s1) on FreeBSD 11.1. However, the second dd on ada0s1a isn't working and gpart show (and ls /dev/ada0*) both tells me there is no ada0s1a.

In all consideration, it seems that FreeBSD does not see the ZFS partition and thus cannot boot on it.

What do you think?


----------



## k.jacker (Sep 2, 2017)

Sad to hear.
I wouldn't recommend MBR partitioning with a ZFS slice inside. It's possible but makes absolutely no sense.
You should stick with GPT on your ssd and rather make a fresh install using UFS.

If you feel you really want to use zfs, save 200GB empty space on your ssd and when you manage to boot from UFS, that you manually create a _freebsd-zfs_ slice there and create a pool on it for your data.


....just noticed that there is indeed something weird with your ssd from your 'gpart show' output.
Size is 238G, but boot, swap and zfs together are only around 38G. Almost 200G missing, and they are not free even 

Maybe it's not a problem in your mobo's BIOS but really with your sdd. Can you remember if you got the full capacity when you installed Windows or Linux on it?


----------



## BackOrder (Sep 2, 2017)

It's time to cut my losses at this point. FreeBSD on this drive ain't gonna happen.

I might have made a typo in the gpart show report. ZFS probably used 236G (first digit was missing), makes more sense now? The drive was fine on Windows and Linux.

Thank you all for your help.


----------



## k.jacker (Sep 2, 2017)

Yes, then it was typo. Makes sense with 236G.

I am also out of ideas, sorry


----------



## k.jacker (Sep 3, 2017)

Me again, one last thing.

If you still have that FreeBSD install that refuses to boot in UEFI mode, disable CSM completely in your mobo's BIOS.


I just did what I told you and installed FreeBSD on an external hdd and then switched from BIOS booting to UEFI booting by making the boot partition the _EFI_ type from previous _freebsd-boot_ and installed EFI bootcode to it.
I have 4 UEFI aware computers. Three of them boot from the new EFI partition right away if I tell them to do so.
But one off them still reads from master-boot-record even if I explicitly tell him to boot an UEFI OS in the BIOS's boot menu.

Since there's still MBR bootcode in sector 0 but the corresponding _freebsd-boot_ isn't there anymore I get the same 'missing operating system'.
It just won't search for the EFI partition before I turn off CSM completely in the BIOS.
Then it will boot from that disk in UEFI mode.

This is on an Asrock Z97 motherboard.


----------



## markb (Sep 3, 2017)

I too am having same problem.  BUT - I CAN boot BSD by selecting which OS to boot on startup by hitting F12 during boot. I TOO am using Samsung NVMe SSD and COULD boot (via Mint's Grub2) when I was using SATA drives.
Color me stumped.


----------

