From owner-freebsd-stable@freebsd.org Sat Dec 17 09:29:59 2016 Return-Path: Delivered-To: freebsd-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E7CC3C81452 for ; Sat, 17 Dec 2016 09:29:59 +0000 (UTC) (envelope-from elferdo@gmail.com) Received: from mail-io0-x232.google.com (mail-io0-x232.google.com [IPv6:2607:f8b0:4001:c06::232]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A769316BC; Sat, 17 Dec 2016 09:29:59 +0000 (UTC) (envelope-from elferdo@gmail.com) Received: by mail-io0-x232.google.com with SMTP id p42so117212095ioo.1; Sat, 17 Dec 2016 01:29:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=g2qJkS+WJmEO8yMnc4jmpCyV0Svp9O/iDRcMTWv9b1k=; b=pi+VPg3uPhqFoFGmXvMqlILCFYLKrJNCjKPP7tLZXsuDzVmPEEqG6vf9fcoNqNGvHF nevYz3ADRasweaQScz65fmd3MUbQiwPNdWwRONUeIOGN4Q55vtdnqoFjaq0sVDhEXPpv DuU/gy38XcXr4aMLQTOFrQah3w0SxAYTiph7EV5OpYPfMAHU9HQURdM5LDfSb6Wjzb6J rGJJYR3yZ1QNp1xakvHD7lAjSh3j8F2FWvh3ucfH80It6rWy9ya/+lVRVMuQrkxwYG2d RZ99FhWbJ7+oTHtG64UMS2Dq5Fo8xQS/6QY7pC98T3SU47EsMqsNU83UPw5ykG/z+KBA OQZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=g2qJkS+WJmEO8yMnc4jmpCyV0Svp9O/iDRcMTWv9b1k=; b=MEfFLMd3CxX3so96SliF4RbfnFxKqWypJdVaCFNlXJv4SnYMR0m4Cn6iIrA/WzlyS7 b4bksUhSaaID/4lQgKZhB6djdugiEMJsTihevpqKcF2CzL2hwh+iEEy3kO3gYybuKjMI GAbbiKnkJXYn3k6reLmnwzp2dz87OPJtOX2FNbPX1Jw/vFus6mvBd8C+inqmst9T8C8p JvPBXGhNpUa28PNPixQ381QWphIOL66svMbGju/eo7mf4s3I9YXxcJ0/R/40W5gXcjRj Jzygo+xEhzhW+lfpsaFcFluWrqjejzzRm2MVahzRUWCl8s+xT5qs/R1mFMzNQkP8WnBw foLg== X-Gm-Message-State: AIkVDXI7QETH/eaKQuEbzVUf0iPaFcwz2JN1yNZlPyq4KkAnC81Y4p+Iv4aYVSOm/ZHHP3p9ecgFD2GAt9hfKg== X-Received: by 10.107.134.136 with SMTP id q8mr6728448ioi.82.1481966998885; Sat, 17 Dec 2016 01:29:58 -0800 (PST) MIME-Version: 1.0 Received: by 10.36.43.67 with HTTP; Sat, 17 Dec 2016 01:29:58 -0800 (PST) In-Reply-To: References: <20161216173930.GD90401@zxy.spb.ru> <85F3F813-D821-439B-B700-DCE51C53E035@FreeBSD.org> From: =?UTF-8?Q?Fernando_Herrero_Carr=C3=B3n?= Date: Sat, 17 Dec 2016 10:29:58 +0100 Message-ID: Subject: Re: Upgrading boot from GPT(BIOS) to GPT(UEFI) To: Warner Losh Cc: Dimitry Andric , Antony Uspensky , Eric van Gyzen , freebsd-stable , Slawa Olhovchenkov Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 17 Dec 2016 09:30:00 -0000 2016-12-17 9:21 GMT+01:00 Fernando Herrero Carr=C3=B3n : > > > 2016-12-16 23:56 GMT+01:00 Warner Losh : > >> On Fri, Dec 16, 2016 at 11:00 AM, Dimitry Andric wrote= : >> > On 16 Dec 2016, at 18:53, Antony Uspensky wrote: >> >> >> >> On Fri, 16 Dec 2016, Eric van Gyzen wrote: >> >>> On 12/16/2016 11:39, Slawa Olhovchenkov wrote: >> >>>> On Fri, Dec 16, 2016 at 06:08:34PM +0100, Fernando Herrero Carr?n >> wrote: >> >>>>> Hi everyone, >> >>>>> >> >>>>> A few months ago I got myself a new box and I have been happily >> running >> >>>>> FreeBSD on it ever since. I noticed that the boot was not as fast >> as I had >> >>>>> expected and I've realized that, while my disk is GPT partitioned, >> the boot >> >>>>> process is still BIOS based: >> >>>>> >> >>>>> % gpart show >> >>>>> =3D> 34 976773101 <976%2077%2031%2001> ada0 GPT (466G) >> >>>>> 34 6 - free - (3.0K) >> >>>>> 40 1024 1 freebsd-boot (512K) >> >>>>> 1064 984 - free - (492K) >> >>>>> 2048 67108864 2 freebsd-swap (32G) >> >>>>> 67110912 909662208 3 freebsd-zfs (434G) >> >>>>> 976773120 <976%2077%2031%2020> 15 - free - (7.5K) >> > ... >> >> I would shrink ada0p1 down to 128K (size of gptzfsboot =3D 88K now) a= nd >> place efi partition (~800K) on free space between new p1 and p2. No need= to >> touch swap partition. >> > >> > Yes, this is almost exactly what I have done on a machine that was >> > originally installed with gptzfsboot on the first partition, which was >> > 512K. Since all the partitions on this SSD were aligned to 1M, I >> > reduced the size of the first partition to 224K, freeing up a hole of >> > exactly 800K for an EFI partition: >> > >> > =3D> 40 976773088 ada0 GPT (466G) >> > 40 2008 - free - (1.0M) >> > 2048 448 1 freebsd-boot (224K) >> > 2496 1600 4 efi (800K) >> > 4096 33554432 2 freebsd-swap (16G) >> > 33558528 943214592 <943%2021%2045%2092> 3 freebsd-zfs (450G) >> > 976773120 <976%2077%2031%2020> 8 - free - (4.0K) >> > >> > Then I wrote the preformatted boot1.efifat image to it, using: gpart >> > bootcode -p /boot/boot1.efifat -i 4 ada0. You can also use dd of >> > course, but I prefer using gpart for these kinds of manipulations. >> > >> > This way, you can choose between booting in old school BIOS mode, or >> > UEFI mode. If the UEFI mode works flawlessly, you can always decide >> > later to dump the freebsd-boot partition, and use only an EFI partitio= n. >> > >> > -Dimitry >> > >> > P.S.: The only thing that triggers my OCD here is that the EFI partiti= on >> > has index 4, but is physically the second. But I can live with that, >> > until I finally delete the freebsd-boot partition. :) >> >> >> You likely want to carve out more like 50MB instead of 800k for UEFI >> partition. 800k is the minimum, but it also precludes many things you >> may need to do with UEFI applications down the line. >> >> Warner >> > > Thanks guys for all the answers, I think I will just nuke freebsd-boot > and create a smallish efi where I can place boot1.efifat as suggested by > Dimitry. If this works, I can always shrink swap if I really need to late= r > on. > > So, it worked! I took a spare USB stick with a bootonly image and changed partitions there first. Once I had it working I modified my hard drive's partitions, installed efifat image with gpart, rebooted, and here I am. Some conclusions: * While getting to FreeBSD's loader seems a bit faster (or maybe that's just confirmation bias), bringing up the system does not seem much faster. * If anything, I have a slightly higher resolution console now. * uefi(8) hints at gpart: /boot/boot1.efifat msdosfs(5) FAT file system image containing boot1.efi fo= r use by bsdinstall(8) and the bootcode argument to gpart(8). maybe a little example would help (gpart bootcode -p /boot/boot1.efifat -i 1 ada0) * Despite gpart(8)'s excellent BOOTSTRAPPING section, no mention is made to booting from an efi partition there. Best, Fernando