[SOLVED] Boot a GPT-partitioned hard drive from a non-UEFI machine
*BSDThis forum is for the discussion of all BSD variants.
FreeBSD, OpenBSD, NetBSD, etc.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Boot a GPT-partitioned hard drive from a non-UEFI machine
Hello,
I have a 10-year old 64 bit laptop that knows nothing about UEFI. I recently read that UEFI boot should also be possible from non-UEFI machines.
I am interested in Dragonfly and OpenBSD, which I plan to implement in a dual boot configuration on my laptop. I created a GPT partition table on the hard drive, which consists of a 512 MiB msdos formatted EFI partition (da0s0a), a 150 GiB DragonFly slice (da0s1) with 3 disklabel partitions (an UFS-formatted boot partition (a), a swap (b) and a hammer2 root partition (d)), and a 150 GiB OpenBSD partition left empty to later installation of OpenBSD. Copied the bootloader to the efi partition. The exact sequence of commands I used for the configuration are at the end of this post. However, the machine does not boot. Any suggestions will be appreciated.
Code:
gpt create -f da0
gpt add -i0 -s1048576 -t efi da0 # the 512 MiB efi slice
gpt label -i0 -l "EFI system" da0s0
disklabel -r -w da0s0 auto # write a new standard volume label
disklabel -e da0s0 # add `a: * * MSDOS', to add `a' partition with fstype FAT covering whole slice
gpt add -b1048577 -i1 -s314572800 -t dfly da0 # add the 150 GiB dragonfly GPT partition (slice)
gpt label -i1 -l "DragonFly" da0
disklabel -B -r -w da0s1 auto
disklabel64 -e da0s1 # add
a: 1G * 4.2BSD # the boot partition
b: 8G * swap
d: * * HAMMER2
gpt add -i2 da0 # add a GPT partition 2 with type ``OpenBSD'' using the remaining free space on da0
gpt label -i2 -l "OpenBSD" da0
newfs_hammer2 -L ROOT /dev/da0s1d
mount_hammer2 /dev/da0s1d /mnt
newfs /dev/da0s1a
mkdir /mnt/boot
mount_ufs /dev/da0s1a /mnt/boot
newfs_msdos /dev/da0s0a # format the efi partition with FAT
# copy file systems
cpdup / /mnt # copy the root file system
mkdir -p /mnt/EFI/BOOT
mount /dev/da0s0a /mnt/EFI/BOOT # mount the efi partition
cp /boot/boot1.efi /mnt/EFI/BOOT/BOOTx64.EFI # copy the bootloader to its right place in the efi partition
mkdir -p /mnt/EFI/dragonfly
cp /boot/boot1.efi /mnt/EFI/dragonfly/dragonfly_x64.efi
cpdup /boot /mnt/boot
# some system configuration:
cd /mnt
vi etc/fstab # add
/dev/da0s1d / hammer2 rw 1 1
/dev/da0s1b none swap sw 0 0
/dev/da0s1a /boot ufs rw 1 1
vi boot/loader.conf # add
vfs.root.mountfrom="hammer2:da0s1d"
cd
umount /mnt/boot
umount /mnt
reboot
I also tried issuing:
disklabel -B da0s0
but this did not change anything.
Hmmm, just relaying my personal experience, this may not be a solution. Also, I am running FreeBSD and not Open or Dragon.
I have an 8+ year old workstation that is a "hybrid" BIOS that can boot from GPT partitions. I do not create an EFI partition, I simply make a 512k "freebsd-boot" partition, plus whatever other partitions I need and do the install. It boots perfectly.
Can your laptop "just work" with a normal install on GPT partitions?
Hello,
I have a 10-year old 64 bit laptop that knows nothing about UEFI. I recently read that UEFI boot should also be possible from non-UEFI machines.
Do you have a link ?. That makes no sense (to me) as [U]EFI is the microcode on the machine - or in your case *not* on the machine.
"boot gpt disk on non-UEFI machines" - that is certainly possible. Note that gpt is not equivalent to [U]EFI.
Creating an EFI partition on a BIOS based machine is no different to creating any other partition - it will be ignored unless the loader code in the MBR knows to go looking for it. There's the problem - gpt uses a structure that effectively masks the "MBR", and on a machine that old, you probably don't have a BIOS that's smart enough to know the difference.
In the case of grub2 you need to create a BIOS_boot partition that grub2 will install into to handle the booting correctly. Works for Linux, but I have no experience on a BSD system.
Last edited by syg00; 10-29-2018 at 06:20 PM.
Reason: cleanup
The BSDs (FreeBSD anyway!) do not require grub2, they have their own bootloader. I am willing to bet if your laptop can use gpt partitions, it's just like my workstation and it will just boot, no efi partition required. As syg00 mentioned, gpt does not equal uefi.
For limited backward compatibility, the space of the legacy MBR is still reserved in the GPT specification, but it is now used in a way that prevents MBR-based disk utilities from misrecognizing and possibly overwriting GPT disks. This is referred to as a protective MBR.
thank you all for your replies. After considering your replies and some more research on the internet, I came to the conclusion that the
best way to proceed would be to revert to BIOS partitions with fdisk and MBR booting. However, the machine still fails to boot. I get a black screen with a single word: error. At the end of this post follows what I did. What am I missing? Any ideas would be appreciated.
Code:
dd if=/dev/zero of=/dev/da0 bs=512 count=32 # zero out the disk to start clean
fdisk -iB /dev/da0 # initialize sector 0 of the disk and install the MBR
# I created two fdisk partitions, each of 150 GB, da0s1 and da0s2. I marked da0s1 as active.
disklabel64 -r -w -B da0s1 auto
disklabel64 -e da0s1
a: 50G * HAMMER # the root partition
b: 8G * swap
d: * * HAMMER # the /home partition
newfs_hammer -L ROOT /dev/da0s1a # format the root partition with HAMMER
mount_hammer /dev/da0s1a /mnt # mount the root partition
mkdir /mnt/home
newfs_hammer -L HOME /dev/da0s1d # format the home partition with HAMMER
mount_hammer /dev/da0s1d /mnt/home
cpdup / /mnt # copy the root file system
vi /mnt/etc/fstab
/dev/da0s1a / hammer rw 1 1
/dev/da0s1b none swap sw 0 0
/dev/da0s1d /home hammer rw 1 1
vi /mnt/boot/loader.conf
vfs.root.mountfrom="hammer:da0s1a"
umount /mnt
reboot
Last edited by tramni1980; 11-01-2018 at 01:32 PM.
So, I finally managed to install DragonFly BSD in a dual-boot setting with OpenBSD
on my machine. Thank you all for your valuable comments. Long story short, I had
to select the sysid for the DragonFly slice 165 and for the OpenBSD slice 166.
Also, I had to create a separate disklabel partition for the /boot directory as
the fist partition on the slice and format it with UFS. Finally, I installed the
boot0 bootloader in the MBR of the hard drive in order to be able to select from a menu
which partition to boot.
Here follows in more detail what I did (any commentaries on my questions and notes are welcome):
Manual BIOS installation of DragonFly BSD with OpenBSD in a classical MBR setting
Code:
dd if=/dev/zero of=/dev/da0 bs=1m # zero out the disk to start clean
dd if=/dev/zero of=/dev/da0 bs=512 count=32 # zero out the disk to start clean
fdisk -Bi /dev/da0 # initialize sector 0 of the disk and install the MBR bootstrap code
fdisk da0
# The hard drive has a total number of sectors: 625142448
# create 2 slices: da0s0: 150 GiB for DragonFly and da0s1: 150 GiB for OpenBSD
# sysid for the dragonfly slice: 165 (supply explicitly, do not accept the default!)
# sysid for the openBSD slice: 166
# size: 314572800 (final size after corrections: 314560449)
# slice 2 starts at sector: 314560449 + 63 + 1 = 314560513 and has size
# 625142448 - 314560513 = 310581935. After corrections: start at 314560575,
# size 310576833.
I was not able to figure out how to tell fdisk to simply select the rest of the drive for
slice 2. Any ideas?
# Caution: 4 partitions are shown even if they do not exist. The 4th partition
# encompasses the whole disk and has to be deleted. For this purpose, it has to
# get a sysid of 0, start at 0, and have a size of 0.
# Note: after writing the partition table two mesages appear:
# da0s1: cannot find label (no disk label)
# da0s2: cannot find label (no disk label)
# make da0s1 bootable
dd if=/dev/zero of=/dev/da0s1 bs=512 count=32
disklabel64 -r -w -B /dev/da0s1 auto # Write a new standard volume label and install the bootstrap code for partition da0s1.
disklabel64 -e /dev/da0s1 # Add the disklabel partitions to /dev/da0s1
# add
a: 1G 0 4.2BSD # the boot partition
# add
# size offset fstype fsuuid
b: 8G * swap
to add `b' partition with fstype `swap' and size 8GB
# add
d: 50G * HAMMER
to add a 50GB root `d' partition with fstype `HAMMER'
# add
e: * * HAMMER
to add home partition spanning the rest of the slice
Note: I tried with the HAMMER2 filesystem, but the partitions failed to mount on the next steps.
That is why I remained with HAMMER
newfs /dev/da0s1a # format the boot partition with UFS
newfs_hammer -L ROOT /dev/da0s1d # format the root partition with HAMMER
newfs_hammer -L HOME /dev/da0s1e # format the home partition with HAMMER
mount_hammer /dev/da0s1d /mnt # mount the root partition: this fails with HAMMER2
mkdir /mnt/boot
mount /dev/da0s1a /mnt/boot
mkdir /mnt/home
mount_hammer /dev/da0s1e /mnt/home # this also fails with HAMMER2
# copy the file systems:
cpdup /boot /mnt/boot # copy the boot partititon
cpdup / /mnt # copy the root file system
# some system configuration:
vi /mnt/etc/fstab # add
/dev/da0s1a /boot ufs rw 1 1
/dev/da0s1b none swap sw 0 0
/dev/da0s1d / hammer rw 1 1
/dev/da0s1e /home hammer rw 1 1
vi /mnt/boot/loader.conf # add
vfs.root.mountfrom="hammer:da0s1d"
#Finally, unmount the partitions and reboot the machine. Once the machine is in reset, before it hits the BIOS, unplug your installation media:
umount /mnt/boot
umount /mnt/home
umount /mnt
boot0cfg -B /dev/da0 # makes boot0 recognize the other available slices
reboot
Last edited by tramni1980; 11-11-2018 at 07:16 AM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.