UFS problem booting from 2nd drive

k.jacker

Aspiring Daemon

Reaction score: 338
Messages: 583

Ok, it cannot find the UEFI booloader on the disk.


Do you have installed UEFI bootcode on both disks now?

It can sometimes be a little tricky to make it work. That's because allmost no manufacturer
respects the standards 100% and invent there own ideas of what's right

It looks like it still searches for a Master Boot Record entry before UEFI, but there is no MBR.
One of my four computers does this, too. Though it's against the standard and shouldn't be.

If you have an option or submenu called "CSM ..." disable every single option here.
 
OP
OP
CyberCr33p

CyberCr33p

Active Member

Reaction score: 14
Messages: 172

If I disable it or choose only UEFI and not Legacy it boots automatically on BIOS.

I think there is an error in my commands. I have to format the efi partition:

Code:
newfs_msdos /dev/ada0p1
I will give it a try.
 

k.jacker

Aspiring Daemon

Reaction score: 338
Messages: 583

True, the efi partition is fat filesystem.
You can check if it's ok by mounting it:

mount_msdosfs /dev/ada0p1 /mnt/
cd /mnt[FILE]/EFI/BOOT/[/FILE]
Here you should find the BOOTX64.EFI
 
OP
OP
CyberCr33p

CyberCr33p

Active Member

Reaction score: 14
Messages: 172

I can mount it before I write the bootcode.

If I run "gpart bootcode -p /mnt/boot/boot1.efi -i 1 ada0"

then I can't mount it. It says:

mount_msdosfs: /dev/ada0p1: Invalid argument
 
OP
OP
CyberCr33p

CyberCr33p

Active Member

Reaction score: 14
Messages: 172

Also man page doesn't say something about "gpart bootcode -p /mnt/boot/boot1.efi -i 1 ada0"
 

k.jacker

Aspiring Daemon

Reaction score: 338
Messages: 583

Strange things happen with your stuff.
Mine:
Code:
% mount_msdosfs /dev/ada0p1 /mnt/
% cd /mnt/EFI/BOOT
% ls  -l
total 129
128 -rwxr-xr-x  1 root  wheel   128K   12.04.2016 Di. W15 22:56h BOOTX64.EFI*
  1 -rwxr-xr-x  1 root  wheel    12B   12.04.2016 Di. W15 22:56h STARTUP.NSH*
Is that the boot1.efi from FreeBSD11.1 now?
Don't use that one from mfsBSD.
 

k.jacker

Aspiring Daemon

Reaction score: 338
Messages: 583

The result is the same.

I got the information about UEFI bootcode from here: uefi(8)

Regarding booting from UEFI there is a lot of information missing or outdated in The Handbook and manpages as well.

wblock@'s Wiki is from 05/2016 and it's true it didn't work with gpart bootcode that time. Since then things have got better and easier but documentation has not kept up.
 
OP
OP
CyberCr33p

CyberCr33p

Active Member

Reaction score: 14
Messages: 172

Yes if I run "gpart bootcode -p /mnt/boot/boot1.efi -i 1 ada0" it uses the FreeBSD 11.1 and not mfsbsd file because FreeBSD is mounted in /mnt

But after this command I can't mount_msdosfs /dev/ada0p1
 
OP
OP
CyberCr33p

CyberCr33p

Active Member

Reaction score: 14
Messages: 172

I boot on mfsbsd again and run these commands to show the error with mount. For this example I will use boot1.efi from the mfsbsd

Code:
gpart destroy -F ada0
ada0 destroyed
Code:
gpart create -s gpt ada0 
ada0 created
Code:
gpart add -b 40 -s 472 -t efi ada0 
ada0p1 added
Code:
 gpart show ada0
=>        40  7814037088  ada0  GPT  (3.6T)
          40         472     1  efi  (236K)
         512  7814036616        - free -  (3.6T)
Code:
gpart bootcode -p /boot/boot1.efi -i 1 ada0
partcode written to ada0p1
Code:
mount_msdosfs /dev/ada0p1 /mnt/
mount_msdosfs: /dev/ada0p1: Invalid argument
 
OP
OP
CyberCr33p

CyberCr33p

Active Member

Reaction score: 14
Messages: 172

The same:

Code:
[root@rescue ~]# gpart destroy -F ada0
ada0 destroyed
[root@rescue ~]# gpart create -s gpt ada0
ada0 created
[root@rescue ~]# gpart add -s 200M -t efi ada0
ada0p1 added
[root@rescue ~]# gpart show ada0
=>        40  7814037088  ada0  GPT  (3.6T)
          40      409600     1  efi  (200M)
      409640  7813627488        - free -  (3.6T)

[root@rescue ~]# gpart bootcode -p /boot/boot1.efi -i 1 ada0
partcode written to ada0p1
[root@rescue ~]# mount_msdosfs /dev/ada0p1 /mnt/
mount_msdosfs: /dev/ada0p1: Invalid argument
[root@rescue ~]#
 
OP
OP
CyberCr33p

CyberCr33p

Active Member

Reaction score: 14
Messages: 172

From the man page:

Code:
    /boot/boot1.efi
           First stage UEFI bootstrap
     /boot/boot1.efifat
           msdosfs(5) FAT file system image containing boot1.efi for
           use by bsdinstall(8)    and the    bootcode argument to gpart(8).
So I run:

Code:
gpart bootcode -p /boot/boot1.efifat -i 1 ada0
and now I can mount it:

Code:
[root@rescue ~]# ls -la /mnt
total 18
drwxr-xr-x   1 root  wheel  16384 Jan  1  1980 .
drwxrwxr-x  20 root  wheel    512 Sep  8 12:48 ..
drwxr-xr-x   1 root  wheel    512 Apr 12  2016 EFI
 

k.jacker

Aspiring Daemon

Reaction score: 338
Messages: 583

ok.
That's what I used to to dd that in times of FreeBSD 10.3 and I thought about recommending it...
Funny and confusing as well...

:beer:
 
OP
OP
CyberCr33p

CyberCr33p

Active Member

Reaction score: 14
Messages: 172

OK I was able to boot from first disk after using boot1.efifat instead of boot1.efi . I also had to disable CSM in bios. Now I will try to write efi in second disk and boot from it.
 

k.jacker

Aspiring Daemon

Reaction score: 338
Messages: 583

Sounds good.
Yes, boot1.efifat includes the fat filesystem, but it used to work for me with just boot1.efi as long as the first partition was 'efi' type allready. I thought about making an updated wiki or participate in FreeBSD Documentation Project and it's good to know about such differences. Thanks for your effort as well!
 
OP
OP
CyberCr33p

CyberCr33p

Active Member

Reaction score: 14
Messages: 172

Now I have another problem. Disabling CSM in BIOS doesn't allow my any more to do Network boot (so I can't use mfsbsd). I try to change BIOS settings to see if there is a solution for this.
 

k.jacker

Aspiring Daemon

Reaction score: 338
Messages: 583

That I didn't know, sorry.
Never before used network-boot.
Aren't there any CSM options that allow you leave PXE boot in legacy mode and disable legacy only for the rest?

If you don't have that available that's really a problem.
Do you rely on network-boot just for the install now?
 
OP
OP
CyberCr33p

CyberCr33p

Active Member

Reaction score: 14
Messages: 172

I rely in network-boot if something goes wrong with the server so I don't have to wait for datacenter to connect KVM.

There are 3 options in BIOS regarding CSM:

Launch CSM: 1. Enabled (default) / 2. Disabled
Boot option filter: 1. UEFI and Legacy (default) / 2. UEFI / 3. Legacy
Launch PXE OpROM Policy: 1. Do not launch / 2. UEFI only / 3. Legacy only (default)

If I choose Boot option filter with "2. UEFI" then I can boot with UEFI but not PXE.
 

k.jacker

Aspiring Daemon

Reaction score: 338
Messages: 583

Hmm, sad. That was, what I was hoping would work :(

Back to the Boot Options #1 - #4
Did you have the option to choose a specific UEFI disk or just the generic [UEFI OS]?

If you could set #1 to something like [UEFI SATA0] and #2 to [UEFI SATA1] you hopefully could leave CSM enabled and still boot in UEFI mode.

Yes, UEFI can give you a lot of grey hair on many computers, I've been there, too.
 
OP
OP
CyberCr33p

CyberCr33p

Active Member

Reaction score: 14
Messages: 172

If I use a FreeBSD 10.3 image (the one that I use before I upgrade this image to Freebsd 11.1) then it boots from both disks. So I don't think it's BIOS related the problem. Something must be changed between FreeBSD 10.3 and 11.1.

I see that gpart changed in FreeBSD 11.0. Maybe related to this?
 
OP
OP
CyberCr33p

CyberCr33p

Active Member

Reaction score: 14
Messages: 172

Also if I do:

Code:
gpart backup ada0 | gpart restore -F ada1
gpart bootcode -b /mnt/boot/pmbr -p /mnt/boot/gptboot -i 1 ada1

during the mfsbsd 11.1
(datacenter upgrade it from 11.0 after my request) then it can boot from the 2nd disk.

If I boot to the FreeBSD 11.1 and:

1. destroy the gmirror
2. destroy ada1 and then create the partitions and write the bootcode:

Code:
gpart backup ada0 | gpart restore -F ada1
gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 ada1
3. and then recreate the gmirror

then it doesn't boot from 2nd disk.

As I said in my previous post this happens only if I use FreeBSD 11.1 to install bootcode. If I use FreeBSD 10.3 everything is fine.

Now I try to create a FreeBSD 11-STABLE image to see what happens.
 

k.jacker

Aspiring Daemon

Reaction score: 338
Messages: 583

Hei,
according to it's manpage, gmirror stores metadata in the last sector of the disc, so the MBR should be fine and not be damaged.

Though, it could explain the errors from your very first post.
gptboot: invalid primary GPT header
gptboot: invalid backup GPT header
gptboot: unable to load GPT
Sure, secondary GPT table and gmirror metadata should normally not interfere each other, but who knows.

Just to make sure you could try to clear out old remains of metadata with gmirror clear -v ada1 .

I don't claim that to be a solution but metadata remains can cause problems.

Hard to figure out what going on, there seems not to be a logic to it.

Let's see what happens with your FreeBSD 11-STABLE image.
 
OP
OP
CyberCr33p

CyberCr33p

Active Member

Reaction score: 14
Messages: 172

I just upgrade my image to 11-STABLE but still the same issue.

I also create MBR instead of GTP and mirror the disks instead of partitions. It boot without issue from second disk. But the problem is that MBR only supports 2TB disk and I have 2x4TB.
 
Top