Re: How to boot in UEFI mode: practically no documentation

2018-06-01 Thread John Nemeth
On May 29, 10:34am, Martin Husemann wrote:
} On Tue, May 29, 2018 at 08:15:43AM +, Thomas Mueller wrote:
} 
} > Where do I find documentation on how to boot NetBSD amd64 or
} > possibly i386 in UEFI mode?
} 
} I'm working on a wiki page (and will change the NetBSD 8.0 install docs
} to point to that).
} 
} I can't answer how to boot into alternative operating systems (haven't tried
} that yet). But the basic installation goes like this:

 UEFI has a boot manager.  You configure it by manipulating
EFI variables (I don't know if NetBSD has a way of doing this).
Alternatively, you can install a 3rd party boot manager, such as
rEFInd.

}  - You want to boot from the uefi usb install image. This requires "secure
}boot" to be disabled. Some firmwares require you to set a firmware
}password before allowing to disable that
} 
} Assuming you have a scratch disk (called wd0) you want to fully
} use for NetBSD you do something like:
} 
}  gpt destroy wd0
}  gpt create wd0
}  gpt add -a 2m -l "EFI system" -t efi -s 128m wd0

 Obviously, if you want to install on a disk that already has other
OSes, you would skip these three steps.

}  gpt add -a 2m -l NetBSD -t ffs -s 118g wd0   # replace 118g as needed
}  gpt add -a 2m -l swap -t swap wd0# this will use all remaining space

 Having a "small" NetBSD partition and using the remainder for
swap is probably not what you want.

}  dkctl wd0 listwedges
} 
} Now note which dk* is the EFI one and newfs it (also note the ffs one
} for later, see below):
} 
}  newfs_msdos /dev/rdk3# replace dk3 with proper device

 Don't do this if the disk already has other OSes.

} Then make it bootable:
} 
}  mount -t msdos /dev/dk3 /mnt
}  mkdir -p /mnt/EFI/boot
}  cp /usr/mdec/*.efi /mnt/EFI/boot
}  umount /mnt

This part is always needed.

} I have sysinst changes that will allow the remaining part to be handled
} by sysinst in NetBSD 8.0 (hope to finsih that soon).
} 
} But for now you will have to install manually. Check the dkctl output
} for which dk* is the ffs one and newfs/mount it:
} 
}  newfs -O 2 dk4   # replace dk4 by approrpiate device, see above
}  mount -o async /dev/dk4 /mnt
}  cd /mnt
} 
} Now extract (with tar xpzf) all sets you want, including the appropriate
} kernel. Also:
} 
}  cp /usr/mdec/boot .  # copy secondary bootloader (XXX is this needed for 
uefi)?

 No, it isn't needed for UEFI boot.

}  cd dev
}  sh MAKEDEV all
}  vi /etc/fstab
} 
} A fstab could look like:
} 
} NAME=NetBSD   /   ffs rw  1 1
} NAME=swap noneswapsw,dp   0 0
} kernfs/kern   kernfs  rw
} ptyfs /dev/pts ptyfs  rw
} procfs/proc   procfs  rw
} tmpfs /var/shm  tmpfs   rw,-m1777,-sram%25
} 
} Finally set rc_configured=YES in /mnt/etc/rc.conf, plus add hostname=
} and whatever settings you need.
} 
} Now reboot, remove install usb medium, and watch NetBSD boot from uefi.

 A brief explanation of the different booting methods would
probably help clear up the boot2 question.

 With BIOS booting, the BIOS simply loads the first sector on
the hard drive into memory and jumps to it.  Keep in mind that this
sector also contains the MBR partition table, so there is only 369
bytes available for the code.  This is the code that gets installed
when you do 'fdisk -i' and comes from /usr/mdec/mbr*.  This code
contains just enough smarts to find the first active MBR partition,
read the first sector from it, and jump to it.  That is the first
sector of /usr/mdec/bootxx_*, which is installed by installboot(8).
That code reads the next N sectors, where N varies by OS and file
system type, into memory and jumps to it.  This code finally has
enough smarts to understand a file system.  It searches the file
system for an OS dependent file (in the case of NetBSD, "boot"
which is commonly known as boot2), loads it and jumps to it.  boot2
is responsible for presenting the boot menu, loading the kernel
(and other stuff), setting up some information for the kernel,
switching the system into 32-bit mode, and starting the kernel.
If the kernel is an amd64 kernel, then one of the first things it
does is switch the system into 64-bit mode (formally known as "long
mode").

 UEFI is very different.  UEFI is essentially a mini-OS.  It
brings the processor into its native mode early on.  It provides
OS like services:  memory management, file system access, device
abstraction, etc..  A UEFI boot loader is really just an UEFI
application.  UEFI applications can do other things besides boot
an operating system.  efiboot is an UEFI application that does the
equivalent of boot2 replacing /boot (UEFI itself has done all the
earlier steps).  Note that our efiboot has a hack where it drops
a 64-bit system back down to 32-bit mode in order to be able to
load an unmodified kernel.  I think it would be better if our kernel
was modified with a UEFI entrypoint added, similar to the 

Re: How to boot in UEFI mode: practically no documentation

2018-05-30 Thread Thomas Mueller


Thanks for the suggestions.  I could try to see what happens with 
/usr/mdec/bootx64.efi and FreeBSD's /loader.efi, possibly copied to 
$EFI_PARTITION/EFI/boot

Also, I have an EFI and non-EFI version of grub2 compiled for FreeBSD, also 
want to take a look at FreeBSD's efibootmgr (in base system, I believe).

I built current computers from parts, never had to deal with secure boot.

Next question is whether NetBSD or FreeBSD will be more stable on UEFI boot 
than non-UEFI, need to try it and find out.

Tom


Re: How to boot in UEFI mode: practically no documentation

2018-05-29 Thread Chavdar Ivanov
Just to say that all this worked for me. I had some 100gb left free on a
GPT disk with a few other systems installed and finally decided to try EFI
boot, using the efi boot image from releng. I only had to create /dev
entries for dk16, dk17 and dk18, 16 were not enough. I also had to disable
nouveau, the geforce 950m apparently is still unsupported and I get 'no
console device'. I haven't been able to get X running on this laptop, but
the rest seems fine.

Chavdar

On Tue, 29 May 2018, 09:34 Martin Husemann,  wrote:

> On Tue, May 29, 2018 at 08:15:43AM +, Thomas Mueller wrote:
> > Where do I find documentation on how to boot NetBSD amd64 or possibly
> i386 in UEFI mode?
>
> I'm working on a wiki page (and will change the NetBSD 8.0 install docs
> to point to that).
>
> I can't answer how to boot into alternative operating systems (haven't
> tried
> that yet). But the basic installation goes like this:
>
>  - You want to boot from the uefi usb install image. This requires "secure
>boot" to be disabled. Some firmwares require you to set a firmware
>password before allowing to disable that
>
> Assuming you have a scratch disk (called wd0) you want to fully use for
> NetBSD you
> do something like:
>
>  gpt destroy wd0
>  gpt create wd0
>  gpt add -a 2m -l "EFI system" -t efi -s 128m wd0
>  gpt add -a 2m -l NetBSD -t ffs -s 118g wd0 # replace 118g as
> needed
>  gpt add -a 2m -l swap -t swap wd0  # this will use all remaining space
>  dkctl wd0 listwedges
>
> Now note which dk* is the EFI one and newfs it (also note the ffs one
> for later, see below):
>
>  newfs_msdos /dev/rdk3  # replace dk3 with proper device
>
> Then make it bootable:
>
>  mount -t msdos /dev/dk3 /mnt
>  mkdir -p /mnt/EFI/boot
>  cp /usr/mdec/*.efi /mnt/EFI/boot
>  umount /mnt
>
> I have sysinst changes that will allow the remaining part to be handled
> by sysinst in NetBSD 8.0 (hope to finsih that soon).
>
> But for now you will have to install manually. Check the dkctl output
> for which dk* is the ffs one and newfs/mount it:
>
>  newfs -O 2 dk4 # replace dk4 by approrpiate device, see above
>  mount -o async /dev/dk4 /mnt
>  cd /mnt
>
> Now extract (with tar xpzf) all sets you want, including the appropriate
> kernel. Also:
>
>  cp /usr/mdec/boot .# copy secondary bootloader (XXX is this needed
> for uefi)?
>  cd dev
>  sh MAKEDEV all
>  vi /etc/fstab
>
> A fstab could look like:
>
> NAME=NetBSD /   ffs rw  1 1
> NAME=swap   noneswapsw,dp   0 0
> kernfs  /kern   kernfs  rw
> ptyfs   /dev/pts ptyfs  rw
> procfs  /proc   procfs  rw
> tmpfs /var/shmtmpfs   rw,-m1777,-sram%25
>
> Finally set rc_configured=YES in /mnt/etc/rc.conf, plus add hostname=
> and whatever settings you need.
>
> Now reboot, remove install usb medium, and watch NetBSD boot from uefi.
>
> Martin
>


Re: How to boot in UEFI mode: practically no documentation

2018-05-29 Thread Martin Husemann
On Tue, May 29, 2018 at 08:15:43AM +, Thomas Mueller wrote:
> Where do I find documentation on how to boot NetBSD amd64 or possibly i386 in 
> UEFI mode?

I'm working on a wiki page (and will change the NetBSD 8.0 install docs
to point to that).

I can't answer how to boot into alternative operating systems (haven't tried
that yet). But the basic installation goes like this:

 - You want to boot from the uefi usb install image. This requires "secure
   boot" to be disabled. Some firmwares require you to set a firmware
   password before allowing to disable that

Assuming you have a scratch disk (called wd0) you want to fully use for NetBSD 
you
do something like:

 gpt destroy wd0
 gpt create wd0
 gpt add -a 2m -l "EFI system" -t efi -s 128m wd0
 gpt add -a 2m -l NetBSD -t ffs -s 118g wd0 # replace 118g as needed
 gpt add -a 2m -l swap -t swap wd0  # this will use all remaining space
 dkctl wd0 listwedges

Now note which dk* is the EFI one and newfs it (also note the ffs one
for later, see below):

 newfs_msdos /dev/rdk3  # replace dk3 with proper device

Then make it bootable:

 mount -t msdos /dev/dk3 /mnt
 mkdir -p /mnt/EFI/boot
 cp /usr/mdec/*.efi /mnt/EFI/boot
 umount /mnt

I have sysinst changes that will allow the remaining part to be handled
by sysinst in NetBSD 8.0 (hope to finsih that soon).

But for now you will have to install manually. Check the dkctl output
for which dk* is the ffs one and newfs/mount it:

 newfs -O 2 dk4 # replace dk4 by approrpiate device, see above
 mount -o async /dev/dk4 /mnt
 cd /mnt

Now extract (with tar xpzf) all sets you want, including the appropriate
kernel. Also:

 cp /usr/mdec/boot .# copy secondary bootloader (XXX is this needed for 
uefi)?
 cd dev
 sh MAKEDEV all
 vi /etc/fstab

A fstab could look like:

NAME=NetBSD /   ffs rw  1 1
NAME=swap   noneswapsw,dp   0 0
kernfs  /kern   kernfs  rw
ptyfs   /dev/pts ptyfs  rw
procfs  /proc   procfs  rw
tmpfs /var/shmtmpfs   rw,-m1777,-sram%25

Finally set rc_configured=YES in /mnt/etc/rc.conf, plus add hostname=
and whatever settings you need.

Now reboot, remove install usb medium, and watch NetBSD boot from uefi.

Martin


Re: How to boot in UEFI mode: practically no documentation

2018-05-29 Thread Patrick Welche
On Tue, May 29, 2018 at 08:15:43AM +, Thomas Mueller wrote:
> Where do I find documentation on how to boot NetBSD amd64 or possibly i386 in 
> UEFI mode?
> 
> I couldn't find any man page and couldn't find anything useful in the online 
> NetBSD wiki.
> 
> I don't want to be limited to NetBSD, would also want to be able to boot 
> FreeBSD and Linux in UEFI mode.
> 
> I noticed /usr/mdec/bootx64.efi and bootia32.efi (on an amd64 installation) 
> but don't really know where these would lead to.
> 
> I also saw /usr/src/sys/arch/i386/stand/efiboot .

Did you see Petra's excellent page:

  https://wiki.netbsd.org/users/spz/moderndisk/

?

Cheers,

Patrick


Re: How to boot in UEFI mode: practically no documentation

2018-05-29 Thread Paul Goyette

I bookmarked this Email a while ago - it might help...

https://mail-index.netbsd.org/current-users/2017/02/28/msg031220.html

On Tue, 29 May 2018, Thomas Mueller wrote:

Where do I find documentation on how to boot NetBSD amd64 or possibly 
i386 in UEFI mode?


I couldn't find any man page and couldn't find anything useful in the 
online NetBSD wiki.


I don't want to be limited to NetBSD, would also want to be able to 
boot FreeBSD and Linux in UEFI mode.


I noticed /usr/mdec/bootx64.efi and bootia32.efi (on an amd64 
installation) but don't really know where these would lead to.


I also saw /usr/src/sys/arch/i386/stand/efiboot .


Tom


!DSPAM:5b0d0c85242761302317190!




+--+--++
| Paul Goyette | PGP Key fingerprint: | E-mail addresses:  |
| (Retired)| FA29 0E3B 35AF E8AE 6651 | paul at whooppee dot com   |
| Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd dot org |
+--+--++


How to boot in UEFI mode: practically no documentation

2018-05-29 Thread Thomas Mueller
Where do I find documentation on how to boot NetBSD amd64 or possibly i386 in 
UEFI mode?

I couldn't find any man page and couldn't find anything useful in the online 
NetBSD wiki.

I don't want to be limited to NetBSD, would also want to be able to boot 
FreeBSD and Linux in UEFI mode.

I noticed /usr/mdec/bootx64.efi and bootia32.efi (on an amd64 installation) but 
don't really know where these would lead to.

I also saw /usr/src/sys/arch/i386/stand/efiboot .


Tom