05.04.16 12:30, Trond Endrest?l ?????:> What am I doing wrong? Can't gpart(8) write both the pmbr and the efi > image as a single command? Is it an off-by-one error in gpart(8)?Should it?> uname -a > FreeBSD 10.3-RELEASE FreeBSD 10.3-RELEASE #0 r297264: Fri Mar 25 02:10:02 UTC 2016 root at releng1.nyi.freebsd.org:/usr/obj/usr/src/sys/GENERIC amd64 > > gpart create -s gpt ada0 > ada0 created > > gpart add -a 4K -s 800K -t efi ada0 > ada0p1 added > > gpart add -a 4K -s 4G -t freebsd-swap ada0 > ada0p2 added > > gpart add -a 4K -t freebsd-zfs ada0 > ada0p3 added > > gpart show -p ada0 > => 34 41942973 ada0 GPT (20G) > 34 6 - free - (3.0K) > 40 1600 ada0p1 efi (800K) > 1640 8388608 ada0p2 freebsd-swap (4.0G) > 8390248 33552752 ada0p3 freebsd-zfs (16G) > 41943000 7 - free - (3.5K) > > gpart bootcode -b /boot/pmbr -p /boot/boot1.efifat -i 1 ada0 > gpart: /boot/boot1.efifat: file too big (524288 limit)Do you try to get only UEFI boot? Then do not use "-b" option. It is needed for BIOS boot. Do you need to get a system with both UEFI and BIOS boot? Then use two different partitions for UEFI and BIOS booting schemes.> gpart bootcode -b /boot/pmbr ada0 > bootcode written to ada0This is needed only for BIOS boot and together with "-p /boot/gptboot" option.> gpart bootcode -p /boot/boot1.efifat -i 1 ada0 > <no output>Hm, I'm not sure if this is supposed (like: supported) to be done like this. One may use dd to copy this partition image (boot1.efifat) if target partition is not less then the file length. Otherwise one may format the target efi partition as an msdos-fat one, create /EFI/BOOT mountpoint and copy boot64x.efi file there. Here is a link from another similar thead: http://www.wonkity.com/~wblock/docs/html/disksetup.html#_booting_with_uefi> System is bootable.HTH -- WBR, Boris Samorodov (bsam) FreeBSD Committer, http://www.FreeBSD.org The Power To Serve
On Tue, 5 Apr 2016 15:34+0300, Boris Samorodov wrote:> 05.04.16 12:30, Trond Endrest?l ?????: > > > What am I doing wrong? Can't gpart(8) write both the pmbr and the efi > > image as a single command? Is it an off-by-one error in gpart(8)? > > Should it?Yes, then it would complement the BIOS style invocation: gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada0> > uname -a > > FreeBSD 10.3-RELEASE FreeBSD 10.3-RELEASE #0 r297264: Fri Mar 25 02:10:02 UTC 2016 root at releng1.nyi.freebsd.org:/usr/obj/usr/src/sys/GENERIC amd64 > > > > gpart create -s gpt ada0 > > ada0 created > > > > gpart add -a 4K -s 800K -t efi ada0 > > ada0p1 added > > > > gpart add -a 4K -s 4G -t freebsd-swap ada0 > > ada0p2 added > > > > gpart add -a 4K -t freebsd-zfs ada0 > > ada0p3 added > > > > gpart show -p ada0 > > => 34 41942973 ada0 GPT (20G) > > 34 6 - free - (3.0K) > > 40 1600 ada0p1 efi (800K) > > 1640 8388608 ada0p2 freebsd-swap (4.0G) > > 8390248 33552752 ada0p3 freebsd-zfs (16G) > > 41943000 7 - free - (3.5K) > > > > gpart bootcode -b /boot/pmbr -p /boot/boot1.efifat -i 1 ada0 > > gpart: /boot/boot1.efifat: file too big (524288 limit) > > Do you try to get only UEFI boot? Then do not use "-b" option. It is > needed for BIOS boot.UEFI and GPT specify the PMBR as a way of telling legacy software not to meddle with the (P)MBR. I wouldn't expect a new disk to contain anything in disk block 0, thus the (misguided on my part?) need for initializing block 0 as a proper PMBR.> Do you need to get a system with both UEFI and BIOS boot? Then use two > different partitions for UEFI and BIOS booting schemes.I have no need for dual-booting.> > gpart bootcode -b /boot/pmbr ada0 > > bootcode written to ada0 > > This is needed only for BIOS boot and together with "-p /boot/gptboot" > option. > > > gpart bootcode -p /boot/boot1.efifat -i 1 ada0 > > <no output> > > Hm, I'm not sure if this is supposed (like: supported) to be done like > this. One may use dd to copy this partition image (boot1.efifat) if > target partition is not less then the file length. > > Otherwise one may format the target efi partition as an msdos-fat one, > create /EFI/BOOT mountpoint and copy boot64x.efi file there. > > Here is a link from another similar thead: > http://www.wonkity.com/~wblock/docs/html/disksetup.html#_booting_with_uefi > > > System is bootable.I guess I upset you all. Case closed. -- +-------------------------------+------------------------------------+ | Vennlig hilsen, | Best regards, | | Trond Endrest?l, | Trond Endrest?l, | | IT-ansvarlig, | System administrator, | | Fagskolen Innlandet, | Gj?vik Technical College, Norway, | | tlf. mob. 952 62 567, | Cellular...: +47 952 62 567, | | sentralbord 61 14 54 00. | Switchboard: +47 61 14 54 00. | +-------------------------------+------------------------------------+
On Tue, 5 Apr 2016, Boris Samorodov wrote:> 05.04.16 12:30, Trond Endrest?l ?????: > >> What am I doing wrong? Can't gpart(8) write both the pmbr and the efi >> image as a single command? Is it an off-by-one error in gpart(8)? >> >> gpart bootcode -b /boot/pmbr -p /boot/boot1.efifat -i 1 ada0 >> gpart: /boot/boot1.efifat: file too big (524288 limit) > > Do you try to get only UEFI boot? Then do not use "-b" option. It is > needed for BIOS boot. > > Do you need to get a system with both UEFI and BIOS boot? Then use two > different partitions for UEFI and BIOS booting schemes. > >> gpart bootcode -b /boot/pmbr ada0 >> bootcode written to ada0 > > This is needed only for BIOS boot and together with "-p /boot/gptboot" > option.Well... bootcode -b only writes to the PMBR and does not take a partition number with -i. So the short form version I use could be refused by a very strict option parser, requiring two separate steps: gpart bootcode -b /boot/pmbr ada0 gpart bootcode -p /boot/gptboot -i1 ada0 The way it parses options when working on EFI partitions might be more strict. Actually, the more I think about it, using bootcode -p to write the entire EFI partition seems dangerous. Unless it is surprisingly smart, it will wipe out any existing stuff on that EFI partition, which could be any number of important things put there by other utilities or operating systems, including device drivers. The safer way is to mount that partition and copy the boot1.efi file to it.