UFS problem booting from 2nd drive

k.jacker

Aspiring Daemon

Reaction score: 330
Messages: 567

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: 11
Messages: 147

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 ?
 

k.jacker

Aspiring Daemon

Reaction score: 330
Messages: 567

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: 11
Messages: 147

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: 11
Messages: 147

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
 
Top