UFS problem booting from 2nd drive

k.jacker

Aspiring Daemon

Reaction score: 434
Messages: 738

Interesting.
With MBR layout working, it then could be a disk controller issue

Again speculation, but are the disk controllers set to AHCI in the BIOS?
 
OP
OP
CyberCr33p

CyberCr33p

Active Member

Reaction score: 20
Messages: 242

Yes are set to AHCI.

I have more information.

After booting the server to FreeBSD 11.1 and before creating the gmirror I do:

Code:
gpart backup ada0 | gpart restore -F ada1
and then write the bootcode it doesn't boot from 2nd disk.

If instead of above command I do:

Code:
gpart create -s gpt ada1
gpart add -a 4k -t freebsd-boot -s 512k ada1
gpart add -a 4k -s 4G -t freebsd-ufs ada1
gpart add -a 4k -s 16G -t freebsd-swap ada1
gpart add -a 4k -s 16G -t freebsd-ufs ada1
gpart add -a 4k -s 64G -t freebsd-ufs ada1
gpart add -a 4k -s 32G -t freebsd-ufs ada1
gpart add -a 4k -s 1024G -t freebsd-ufs ada1
gpart add -a 4k -t freebsd-ufs ada1
and then write the bootcode it does work.

Any idea why if I use "gpart backup ada0 | gpart restore -F ada1" instead of manual creation of partitions it makes bootcode to not work?

Also why "gpart backup ada0 | gpart restore -F ada1" worked with FreeBSD 10.3 but not 11.1 ?
[FONT=Consolas][/FONT]
 

k.jacker

Aspiring Daemon

Reaction score: 434
Messages: 738

I don't know if gpart restore only writes a primary partition table to the disk, but it could be an explanation.

Since FreeBSD 10.3, when i started to learn and experiment with bootcode and UEFI, I worked a lot with dd to copy and write partition information and bootcode
from one disk to another. That worked, but gpart would often throw errors, complaining about GPT missmatches or something like that.
I really can't remember if this affectet the abililty to boot, but even if the output from gpart show looked allright on the 'cloned' disk,
it was neccessary to make the secondary partition table match the primary, by running gpart recover ... before everything worked ok.

I guess what you experience must be of that sort also. Be it the primary and secondary GPT table noch matching 100% or a slight mismatch in the Master Bot Record after gpart restore

That could explain why you now made it work by adding -a 4k.

What I noticed changed between FreeBSD 10.3 and 11.1 is when I installed FreeBSD 11.1 to a root-on-ZFS and another to a SDD, both where 4k aligned, where on 10.3 that still had to be done manually.
 
OP
OP
CyberCr33p

CyberCr33p

Active Member

Reaction score: 20
Messages: 242

Thanks to k.jacker the solution for everyone with the same issue:

Code:
gpart backup ada0 | gpart restore -F ada1
dd if=/dev/ada0 of=/dev/ada1 bs=512 count=40       <---- copy the MBR from ada0 to ada1
gpart recover ada1
gpart -p /boot/gptboot -i 1 ada1
I think there is a bug with the "gpart backup ada0 | gpart restore ada1" command (after FreeBSD 10.3) so I will create a PR.
 

sdf

Active Member

Reaction score: 3
Messages: 170

I'm faced with the exact same problem.

Test Results
Code:
MBR + UFS --- OK
GPT + UFS --- NO
GPT + ZFS --- OK
 
OP
OP
CyberCr33p

CyberCr33p

Active Member

Reaction score: 20
Messages: 242

The problem is related to:

Code:
gpart backup ada1 | gpart restore -F ada0
If I remove and recreate the freebsd-boot partition then it works:

Code:
gpart delete -i 1 ada0
gpart add -a 4k -t freebsd-boot -s 512k ada0
gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 ada0
Keep in mind that you have to use mfsbsd to remove the partition or maybe you can use this command to do it in live system:

Code:
sysctl kern.geom.debugflags=16
 

Sidius

New Member


Messages: 1

Facing the same problem.
Installing clean FreeBSD 11.2
makeing
Code:
gpart backup ada0 | gpart restore -F ada1
gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 ada1
Then makeing gmirror things. All is ok when i boot from first HDD (where i install FreeBSD 11.2).
But when i try to boot from second HDD it's
Code:
gptboot: invalid primary GPT header
gptboot: invalid backup GPT header
gptboot: unable to load GPT
When i try to put gptboot or gptboot+pmbr from freebsd 10.4 on second hdd - boot is not started and computer is cycling reboot when start to boot.

I try to do all the things described above - no luck :(

Maybe somebody have some new solutions?
 
OP
OP
CyberCr33p

CyberCr33p

Active Member

Reaction score: 20
Messages: 242

These 2 methods work for me:

1st method:

In live system:


gpart backup ada0 | gpart restore -F ada1

dd if=/dev/ada0 of=/dev/ada1 bs=512 count=40
gpart recover ada1
gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 ada1


2nd method:

Boot using mfsbsd and run:


gpart delete -i 1 ada1
gpart add -a 4k -t freebsd-boot -s 512k ada1
gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 ada1


gpart add command must use correct parameters for -a and -s so check first the other disk boot partition size with:

gpart show ada0 | grep freebsd-boot
 
Top