Solved Need a bootloader

At the moment I am unable to boot up FreeBSD on my ThinkPad X220 because the FreeBSD bootloader doesn't work, although I can manage to boot somehow by booting from a Super Grub2 USB stick which manages to locate bootable partitions. The disk did boot originally when I installed FreeBSD, but then I went an added Ubuntu which screwed things up.

The problem is due to a Lenovo BIOS bug -https://lists.freebsd.org/pipermail/freebsd-current/2015-July/056543.html for which there appears to have been a fix but the link in to post has gone.

What to do?
 
Update your BIOS, I almost am sure it is UEFI, not BIOS

I recommend use reEFInd to boot manager, but this may mean that you have to reinstall everything again

What bootloader did FreeBSD install?

What bootloader did Ubuntu install?
 
What bootloader did FreeBSD install?

When you run bsdinstall() initially it recognises that you have a Lenovo X220 and asks if you want to apply a fix to overcome some BIOS bug. It looks like my only option is to find somewhere to copy the root filesystem, reinstall FreeBSD and then copy the files back...
Bit of a pain, but....
 
How did you determined the problem is due to that bug?

If you are talking about this fix, it is already in the source tree.

As I recall I suggested grub-install on that laptop and it failed, afterwards installing FreeBSD boot code. Did't installing the boot code work out?

I did not know about this. Should I just run :-
gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 ada0
 
I was referring to this Thread 71344. Apparently I was mistaken. My apologies.

The BIOS is at latest version as you mentioned in another thread. Would you consider a fresh install?
 
Is it for the same reason that I can't boot an SSD on a T460 which boots fine on a T430 (both latest BIOS)?
It also boots fine on a T410, but does NOT boot on an X121e.

Code:
 # gpart show ada0
=>        34  1000215149  ada0  GPT  (477G)
          34           6        - free -  (3.0K)
          40         200     1  freebsd-boot  [bootme]  (100K)
         240        1808        - free -  (904K)
        2048    41943040     2  freebsd-ufs  (20G)
    41945088   958269440     3  freebsd-zfs  (457G)
  1000214528         655        - free -  (328K)
Is there a workaround/hack/fix to make the disk boot? If I created the GPT with a gpart before the patch, how can I fix it afterwards?
 
Is there a workaround/hack/fix to make the disk boot? If I created the GPT with a gpart before the patch, how can I fix it afterwards?
Make sure your T460 or X121e BIOS/UEFI is configured in BIOS style booting, also called Compatibility Support Module (CSM)

I would try with
Code:
gpart bootcode -b /boot/pmbr ada0
Or doing a backup and a restore with -F
Code:
gpart backup ada0 > /media/usb/ada0.backup
gpart restore -F -l ada0 < /media/usb/ada0.backup
For more info, check the manual gpart(8)

Should I just run :-
Code:
gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 ada0
in order to respond, we need to know:

What's Your Boot Mode
And the output of gpart show ada0 assuming ada0 is your laptop's disk (ThinkPad X220)
 
gpart show da0:-
Code:
=>        40  1953525088  da0  GPT  (932G)
          40        1024    1  freebsd-boot  (512K)
        1064   536870912    2  freebsd-ufs  (256G)
   536871976     8388608    3  freebsd-swap  (4.0G)
   545260584         984       - free -  (492K)
   545261568        2048    4  bios-boot  (1.0M)
   545263616  1408260096    5  linux-data  (672G)
  1953523712        1416       - free -  (708K)

The disk is da0 currently because I'm trying to copy files onto another system before deciding whether to reinstall.

Remember this disk booted OK before I installed Ubuntu.

As far as Boot Mode goes, not sure exactly what that means...
In BIOS -> Startup I have
UEFI/Legacy Boot [Both]
UEFI/Legacy Boot Priority [Legacy First]
but I've tried various options. Also
in BIOS -> Config -> SATA
I've tried both AHCI and Compatibity
 
Is it for the same reason that I can't boot an SSD on a T460 which boots fine on a T430 (both latest BIOS)?
It also boots fine on a T410, but does NOT boot on an X121e.

Code:
# gpart show ada0
=>        34  1000215149  ada0  GPT  (477G)
          34           6        - free -  (3.0K)
          40         200     1  freebsd-boot  [bootme]  (100K)
         240        1808        - free -  (904K)
        2048    41943040     2  freebsd-ufs  (20G)
    41945088   958269440     3  freebsd-zfs  (457G)
  1000214528         655        - free -  (328K)
Is there a workaround/hack/fix to make the disk boot? If I created the GPT with a gpart before the patch, how can I fix it afterwards?
Don't hijack the thread, create a new one, it makes things confusing.
 
I'm just trying to install FreeBSD 12.0-RELEASE onto my ThinkPad X220 on a different disk and the first msg which pops up says:-
Your model of Lenovo is known to have a BIOS bug that prevents it booting from GPT partitions without UEFI. Would you like the installer to apply a workaround for you?

I selected yes. Not sure exactly what this workaround was... but maybe I could copy it to the other disk using dd()...
 
gpart show da0:-
Code:
=>        40  1953525088  da0  GPT  (932G)
          40        1024    1  freebsd-boot  (512K)
        1064   536870912    2  freebsd-ufs  (256G)
   536871976     8388608    3  freebsd-swap  (4.0G)
   545260584         984       - free -  (492K)
   545261568        2048    4  bios-boot  (1.0M)
   545263616  1408260096    5  linux-data  (672G)
  1953523712        1416       - free -  (708K)

The disk is da0 currently because I'm trying to copy files onto another system before deciding whether to reinstall.

Remember this disk booted OK before I installed Ubuntu.

As far as Boot Mode goes, not sure exactly what that means...
In BIOS -> Startup I have
UEFI/Legacy Boot [Both]
UEFI/Legacy Boot Priority [Legacy First]
but I've tried various options. Also
in BIOS -> Config -> SATA
I've tried both AHCI and Compatibity
One post you say the disk is ada, next it's da? I gotta say this is all very confusing if you're not posting actual commands and results.
Then again, I'm easily confused...
 
I'm just trying to install FreeBSD 12.0-RELEASE onto my ThinkPad X220 on a different disk and the first msg which pops up says:-


I selected yes. Not sure exactly what this workaround was... but maybe I could copy it to the other disk using dd()...
Well the workaround is you can't boot. :p
You say it worked before (that is you booted FreeBSD?), then you added ubuntu which I assume silently added its own (grub?) boot manager? Don't you get the grub 'menu'?

Have you tried to put the bootcode on da0p1 using gpart?

In the gpart manual it states under bootstrapping:


Both types of bootstrap code are used to boot from the GUID Partition Ta-
ble. First, a protective MBR is embedded into the first disk sector from
the /boot/pmbr image. It searches through the GPT for a freebsd-boot
partition (see the PARTITION TYPES section) and runs the next bootstrap
stage from it. The freebsd-boot partition should be smaller than 545 KB.
It can be located either before or after other FreeBSD partitions on the
disk. There are two variants of bootstrap code to write to this parti-
tion: /boot/gptboot and /boot/gptzfsboot.



So, your freebsd-boot is da0p1 and you should put these code images in there.
???

In the gptboot manual it specifically states if you do the setup as you have show in your previous post
(gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 ada0 )
you need to do:
Set the bootme attribute for partition 2:

gpart set -a bootme -i 2 ada0

Set the bootonce attribute for partition 2, automatically also setting
the bootme attribute:

gpart set -a bootonce -i 2 ada0
 
We are aproaching the problem the wrong way.

First: FreeBSD only on disk boots fine, second: installing Ubuntu installed GRUB2, see bios-boot in gpart show da0, third: obviously Super Grub Disk can boot FreeBSD.

Have you tried editing a menu entry for FreeBSD in Ubuntu to create a /boot/grub/grub.cfg file as I explained in Thread 71344 ?
 
Well the workaround is you can't boot. :p

I just installed FreeBSD successfully on the X220 using a different disk with bsdinstall() accepting all the defaults and here's how the disk is partitioned:-
Code:
root@FreeBSD:~ # gpart show ada0
=>      40  62533216  ada0  GPT  (30G)
        40      1024     1  freebsd-boot  (512K)
      1064  58719232     2  freebsd-ufs  (28G)
  58720296   3127296     3  freebsd-swap  (1.5G)
  61847592    685664        - free -  (335M)

So the install put 'something' on the disk which enabled it to boot. Now if I can figure exactly what then maybe I can copy it to the other disk...
(Thinking aloud)...
Maybe I should compare the first 512 bytes of both disks and see how they differ. I know the partition tables will be different but I'm guessing any other differences will be because of the 'workaround'.
 
It's still not mentioned how you try to boot FreeBSD with Ubuntu on disk. With GRUB2 from Ubuntu?

If yes did you created a FreeBSD GRUB menu entry?
 
We are aproaching the problem the wrong way.

First: FreeBSD only on disk boots fine, second: installing Ubuntu installed GRUB2, see bios-boot in gpart show da0, third: obviously Super Grub Disk can boot FreeBSD.

Have you tried editing a menu entry for FreeBSD in Ubuntu to create a /boot/grub/grub.cfg file as I explained in Thread 71344 ?

Actually I was mistaken that I could boot FreeBSD off that hard disk using Super GRUB2. I saw this in Super Grub's Operating System menu:-

FreeBSD (ufs2 hd0,gpt5)

I had forgotten that I installed FreeBSD on this USB stick and that is what I've been booting. It did not find a FreeBSD installation on the hard disk. I guess I'll try installing Grub2 again and see if I can manually add FreeBSD. Not sure if I can install it from the USB stick - couldn't find such an option.
 
Have you tried the " lenovofix" attribute ( man gpart)?
Would you believe I've spent ages looking at those manpages and never spotted that. I was hoping that something like that existed but didn't know what it might be called.

Many thanks for pointing that out.
 
It was the same for me ... but it didn't help either.
So I ended up replacing my freebsd-boot partition with an efi partition and set the Thinkpad BIOS to prefer UEFI. But you need 800kB for that, so you would have to move your ufs ....
gpart delete -i 1 adaX
gpart add -i 1 -s 800K -t efi adaX
gpart bootcode -p /boot/boot1.efifat -i 1 adaX


... or could you just replace your "bios-boot" by that?
 
I just installed FreeBSD successfully on the X220 using a different disk with bsdinstall() accepting all the defaults and here's how the disk is partitioned:-
Code:
root@FreeBSD:~ # gpart show ada0
=>      40  62533216  ada0  GPT  (30G)
        40      1024     1  freebsd-boot  (512K)
      1064  58719232     2  freebsd-ufs  (28G)
  58720296   3127296     3  freebsd-swap  (1.5G)
  61847592    685664        - free -  (335M)

So the install put 'something' on the disk which enabled it to boot. Now if I can figure exactly what then maybe I can copy it to the other disk...
(Thinking aloud)...
Maybe I should compare the first 512 bytes of both disks and see how they differ. I know the partition tables will be different but I'm guessing any other differences will be because of the 'workaround'.
The install 'obviously'? put what was mentioned in your opening article:
https://lists.freebsd.org/pipermail/freebsd-current/2015-July/056543.html

Why not avoid gpt altogether and save the angst? I know I would - even zfs is ok on it, see
 
Your disk has partitions to boot in BIOS with GPT

In the BIOS select UEFI/Legacy Boot Priority [Legacy First]
BIOS -> Config -> SATA -> AHCI

To rewrite the files to boot FreeBSD, run this commands

Code:
gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 da0
gpart set -a lenovofix da0
 
Your disk has partitions to boot in BIOS with GPT

In the BIOS select UEFI/Legacy Boot Priority [Legacy First]
BIOS -> Config -> SATA -> AHCI

To rewrite the files to boot FreeBSD, run this commands

Code:
gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 da0
gpart set -a lenovofix da0

Just discovered that I need to apply the 'lenovofix' on the ThinkPad T420 also...

That is for anyone using a disk with a GPT partition.
 
Back
Top