From owner-freebsd-hackers@freebsd.org Fri May 1 15:34:44 2020 Return-Path: Delivered-To: freebsd-hackers@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CA3E52D876C for ; Fri, 1 May 2020 15:34:44 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mailman.nyi.freebsd.org (unknown [127.0.1.3]) by mx1.freebsd.org (Postfix) with ESMTP id 49DGX43ZS0z3DNT for ; Fri, 1 May 2020 15:34:44 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mailman.nyi.freebsd.org (Postfix) id 788A72D876B; Fri, 1 May 2020 15:34:44 +0000 (UTC) Delivered-To: hackers@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7842F2D876A for ; Fri, 1 May 2020 15:34:44 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-qk1-x72d.google.com (mail-qk1-x72d.google.com [IPv6:2607:f8b0:4864:20::72d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49DGX25VL6z3DNS for ; Fri, 1 May 2020 15:34:42 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-qk1-x72d.google.com with SMTP id k81so6857025qke.5 for ; Fri, 01 May 2020 08:34:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=qhNCaw4DXB7Vj0cBrrVEtLJUDeZqVVHqqhG/gxaBpE0=; b=OA3dAwCDwBfgdveb99E3UA29yeF/QUwop7Rw71ruPPFkb5lyuJNt8b3NJHqDMZbQCl yEHqW5m+4CiwdYI51dne2oQCS8sZg3ibDvcB65zhkftWSArH2S4YaIoYdFG5NefJb/YZ EXCngcbMhBg6AL8/ntM3bZfUt5Q8P75/th/muL9fvco+ooHZyaCLzL+7RPsKLn4xT2l9 IUmONMqR423xVCG6MWMfsdGg/Smkz5m9dRwuSWxF95pvEqW8bzlzCOBRrZz5vj26NFIa pSahyM6YCZcrbyIGFZRNrg7lj57YI/6V+ITsDsusa6iwNXQpkpbmlwZlDa9W9DMy9+t/ 9S2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=qhNCaw4DXB7Vj0cBrrVEtLJUDeZqVVHqqhG/gxaBpE0=; b=PujvdJ2hIuaI6Dho0Js1H/sWk3YAXDNOodM4Vs7Lry7++FqMXMg/Na3RZtzr5JyGPD XDT2QvBx8enQ7tPsZCBM1xzYetuePMC69ncNqkMo2dZbJpH9i99mOcpA8vqbUMgONSsB iAzTQEq5B1RO4jh4AvSKbILxkmrVhHiblt6yxFzSd3t6odncBaAK45FpcyuC+TudNC8Y OGu+xBsQajklwHciKZW1JVYDOkC6ZQjGBrMMwpj4Z/zOu/eAj0phWwMOrpQ8GjD1A58T 34eHeZMSZd8PObJozYsn3XuPBotAAaD5n0JvzEgKzIAg6pUYfDfEnpOxS1pXzZmAwuXs vGRA== X-Gm-Message-State: AGi0PuZbjtRru7jh1guZS4shKxu3G+pzogr7PcZ8uNUfcLAbh8AEpZTn 4DhLDLf1FZH4tFxwhIpMXEIGgld7OVICfjYTJ//40A== X-Google-Smtp-Source: APiQypLEjO0xSIs480sl4e1hhLRKLUaMIz5iGPtHlc/kSTA6MTpLJnLuDUkLPjaDcZifWtXQh3W/VoPfzg473ngCDus= X-Received: by 2002:a37:6ce:: with SMTP id 197mr4024781qkg.495.1588347281270; Fri, 01 May 2020 08:34:41 -0700 (PDT) MIME-Version: 1.0 References: <8B798F61-783C-4A1C-AEED-4B42E88E5010@cs.huji.ac.il> <9FAAF98B-77D1-4D39-8E8E-D20F2B4C2E5C@cs.huji.ac.il> In-Reply-To: <9FAAF98B-77D1-4D39-8E8E-D20F2B4C2E5C@cs.huji.ac.il> From: Warner Losh Date: Fri, 1 May 2020 09:34:30 -0600 Message-ID: Subject: Re: efi boot question To: Daniel Braniss Cc: =?UTF-8?Q?Trond_Endrest=C3=B8l?= , "freebsd-hackers@freebsd.org" X-Rspamd-Queue-Id: 49DGX25VL6z3DNS X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=bsdimp-com.20150623.gappssmtp.com header.s=20150623 header.b=OA3dAwCD; dmarc=none; spf=none (mx1.freebsd.org: domain of wlosh@bsdimp.com has no SPF policy when checking 2607:f8b0:4864:20::72d) smtp.mailfrom=wlosh@bsdimp.com X-Spamd-Result: default: False [-4.00 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; R_DKIM_ALLOW(-0.20)[bsdimp-com.20150623.gappssmtp.com:s=20150623]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; PREVIOUSLY_DELIVERED(0.00)[hackers@freebsd.org]; DMARC_NA(0.00)[bsdimp.com]; TO_MATCH_ENVRCPT_SOME(0.00)[]; TO_DN_ALL(0.00)[]; DKIM_TRACE(0.00)[bsdimp-com.20150623.gappssmtp.com:+]; RCVD_IN_DNSWL_NONE(0.00)[d.2.7.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.4.6.8.4.0.b.8.f.7.0.6.2.list.dnswl.org : 127.0.5.0]; R_SPF_NA(0.00)[]; FORGED_SENDER(0.30)[imp@bsdimp.com,wlosh@bsdimp.com]; MIME_TRACE(0.00)[0:+,1:+,2:~]; IP_SCORE(-2.00)[ip: (-9.19), ipnet: 2607:f8b0::/32(-0.33), asn: 15169(-0.43), country: US(-0.05)]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; FROM_NEQ_ENVFROM(0.00)[imp@bsdimp.com,wlosh@bsdimp.com]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2] Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 May 2020 15:34:44 -0000 On Fri, May 1, 2020 at 3:54 AM Daniel Braniss wrote: > > > > On 1 May 2020, at 11:42, Trond Endrest=C3=B8l > wrote: > > > > On Fri, 1 May 2020 11:16+0300, Daniel Braniss wrote: > > > >> hi, > >> I have none efi boot that: > >> - the bios is set to do network boot/pxe > >> - if the dhcpd.conf is configured with filename set to pxeboot, i= t > loads as diskless, > >> or if set to =E2=80=9Cpmbr=E2=80=9D then goes and boots off the= hard disk. > >> (this is faster than changing the bios boot order) > >> > >> > >> so now i'm experimenting with efi boot, > >> the GPT is: > >> > >> =3D> 40 5857345456 mfid0 GPT (2.7T) > >> 40 409600 1 efi (200M) > >> 409640 8388608 2 freebsd-ufs ( 4.0G) > >> 8798248 100663296 3 freebsd-swap (48G) > >> 109461544 5747883952 4 freebsd-zfs (2.7T) > >> > >> but am at loss figuring out what boot file to download. > >> any insight is appreciated, > > > > You can try this: > > > > gpart bootcode -p /boot/boot1.efifat -i 1 mfid0 > > > > This will populate /dev/mdid0p1 with a FAT filesystem containing > > /boot/boot1.efi, saved as efi/boot/BOOTx64.efi. You may later replace > > the latter file with /boot/loader.efi. You will also find > > efi/boot/startup.nsh which simple instructs the boot firmware to load > > and run BOOTx64.efi. > > > > I haven't worked out how you can grow the small 800K FAT filesystem to > > take advantage of your 200M partition. And indeed, we will need an ESP > > of more than 800K in the near future. > > > > This fstab entry might be handy: > > > > # Device Mountpoint FStype Options > Dump Pass# > > /dev/mfid0p1 /esp msdosfs rw,-l,-m=3D664,-M=3D775,noauto = 0 > 0 > > > > -- > > Trond. > > > the fat partition is fine, has all that is needed, but > I need the right bootblock instead of pmbr, and there are many *efi* in > /boot and I don=E2=80=99t > know which one to use :-( > You don't need boot blocks in UEFI. Create the FAT partition, use newfs_msdos to initialize it. mount it and create a top-level directory named EFI. There are several options from here: (1) use the 'old style' of putting boot1.efi or loader.efi into EFI/BOOT/BOOTX64.EFI. If you have a really simple setup, this is likely the easiest. It usually works (though there are exceptions for some crazy BIOSes). This works because the UEFI BIOS looks for removable devices with a ESP that has /EFI/BOOT/BOOTxxx.EFI (where xxx varies on architecture, for AMD64 its X64). It loads this. Both boot1.efi and loader.efi know what to do from here if your root filesystem is on the same disk as the ESP. boot1.efi searches a little harder for things, while loader.efi is more disciplined in what it searches for to allow for predictable behavior. This option works great for a FreeBSD only machine. (2) Use the new style. mount the esp somewhere, say /boot/efi. Put loader.efi into /boot/efi/EFI/FreeBSD and use the following command: efibootmgr --create --loader /boot/efi/efi/freebsd/loader.efi --kernel /boot/kernel/kernel --label "FreeBSD Rocks" --activate --verbose which creates and activates a UEFI boot variable, that tells it to load loader.efi first and have it load the default kernel and to label it "FreeBSD Rocks". This also works well for FreeBSD only machines and gives you more control if you are doing things like having redundant partitions and you want to nail down exactly the right one. This also works for people that want to have multiple versions of FreeBSD on the machine (though 11 and older works less well than 12 and newer). (3) There are a number of 3rd party chain loaders rEFInd is likely the most popular. I don't use those, so I can't comment on them further. These work well when you have multiple OSes that each have their own fussy notion of the proper early boot setup. Warner