LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > *BSD
User Name
Password
*BSD This forum is for the discussion of all BSD variants.
FreeBSD, OpenBSD, NetBSD, etc.

Notices


Reply
  Search this Thread
Old 10-29-2018, 03:03 PM   #1
tramni1980
Member
 
Registered: Jul 2006
Location: Köln, Germany
Distribution: Slackware64-14.2 & -current, DragonFly BSD, OpenBSD
Posts: 819

Rep: Reputation: 55
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.
 
Old 10-29-2018, 03:37 PM   #2
sevendogsbsd
Senior Member
 
Registered: Sep 2017
Distribution: FreeBSD
Posts: 2,252

Rep: Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011
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?
 
Old 10-29-2018, 05:56 PM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,120

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Quote:
Originally Posted by tramni1980 View Post
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
 
Old 10-29-2018, 07:10 PM   #4
sevendogsbsd
Senior Member
 
Registered: Sep 2017
Distribution: FreeBSD
Posts: 2,252

Rep: Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011
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.
 
Old 10-30-2018, 01:22 AM   #5
jggimi
Member
 
Registered: Jan 2016
Distribution: None. Just OpenBSD.
Posts: 289

Rep: Reputation: 169Reputation: 169
Source: https://en.wikipedia.org/wiki/GUID_Partition_Table
Quote:
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.
 
Old 10-30-2018, 11:33 AM   #6
cynwulf
Senior Member
 
Registered: Apr 2005
Posts: 2,727

Rep: Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367
Did you try what was suggested in the response to your message on dragonfly-users yesterday?
 
Old 11-01-2018, 12:34 PM   #7
tramni1980
Member
 
Registered: Jul 2006
Location: Köln, Germany
Distribution: Slackware64-14.2 & -current, DragonFly BSD, OpenBSD
Posts: 819

Original Poster
Rep: Reputation: 55
Hello,

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.
 
Old 11-02-2018, 04:54 AM   #8
cynwulf
Senior Member
 
Registered: Apr 2005
Posts: 2,727

Rep: Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367
Are you following this https://www.dragonflybsd.org/docs/ha...tion/#index3h1 ?

I believe you will need a small UFS /boot partition?

Any particular reason for doing a manual install?
 
Old 11-11-2018, 07:12 AM   #9
tramni1980
Member
 
Registered: Jul 2006
Location: Köln, Germany
Distribution: Slackware64-14.2 & -current, DragonFly BSD, OpenBSD
Posts: 819

Original Poster
Rep: Reputation: 55
@cynwulf: Yes, I am following these instructions.

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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
FreeBSD 11.2 ZFS dual boot with Linux in UEFI-GPT mode from a single hard drive deepclutch *BSD 0 10-23-2018 08:45 PM
[SOLVED] Booting USB hard drive on UEFI machine in legacy mode aikempshall Slackware 5 01-05-2018 01:04 AM
[SOLVED] Repair Dual-Boot UEFI/GPT Malacoda93 Linux - General 7 05-08-2015 01:03 PM
[SOLVED] Booting USB hard drive on UEFI machine in legacy mode aikempshall Slackware 6 11-20-2014 04:14 PM
Need to know the command which shows all non-partitioned & partitioned hard drive saidul Linux - Newbie 2 12-04-2007 04:02 PM

LinuxQuestions.org > Forums > Other *NIX Forums > *BSD

All times are GMT -5. The time now is 06:30 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration