On Fri, May 6, 2016 at 8:47 AM Stefan Monnier <monn...@iro.umontreal.ca>
wrote:

> > I confirm that gdisk can convert a disk from MBR/MSDOS to GPT from
> > within a system running on the disk.
>
> Indeed that's exactly what I used for that.
>
>
However in this case the disk was GPT partitioned from the start, although
not initially in a UEFI compatible way (no ESP, as I didn't know it was
required at first). The non-UEFI boot was from a USB stick.


> > IMO a more elegant way is to install GRUB with the following options :
> > grub-install --target=x86_64-efi --removable
> > (or --target=i386-efi depending on the firmware flavour)
> > It does not require access to any EFI boot variable and will install
> > GRUB in the default EFI path.
>
> Ah, yes, that rings a bell.  Indeed, I had some difficulty convincing
> GRUB to install itself (I seem to remember that it had trouble deciding
> which target to use, at least).
>
>
That's interesting, and may be the explanation for the problem I
encountered in 11) below (which didn't stop me but puzzled me for a minute).

In the end I got it to work by doing the following, after building the full
system on the /dev/sda and finding it wouldn't boot, and fixing the
partition scheme and still not being able to boot:

1) Buy two new USB sticks from the local store, one small ,one larger.
2) Download Jessie netinst from ftp.jaist.ac.jp (I'm in Japan), burn to
smaller USB stick
3) Boot from smaller USB stick with larger USB stick connected, install
Jessie minimal install (no DE) to larger USB stick without mounting or
touching the system's SSD. Verify on grub menu as install was about to
start that was in UEFI mode.
4) Back to the store for a wired USB keyboard as the installer doesn't
support bluetooth even though the live does, at least not in the early
stages. Finish install.
5) Boot into new Jessie on larger USB stick. Verify EFI mode.
(/sys/firmware/efi/efivars exists)
6) Mount root partition of target install on the machine's SSD (/dev/sda2
-- /dev/sda1 being the ESP) at /mnt/lfs
7) Do the dance of several mounts eg bind mount /dev, remount devpts, proc,
sysfs and tmpfs, then chroot into the LFS environment. Mount the ESP at
/boot/efi .
8) efibootmgr with no params now runs without errors and lists up existing
boot settings -- THIS IS THE BREAKTHROUGH. At this point, Debian-installed
kernel is running, but all tools, libraries etc are self-built as per LFS
since I'm in the chroot.
9) Run grub-install again -- no complaints this time about EFI variables.
10) Reboot -- grub runs but fails to boot new kernel.
11) Try to boot USB-installed Jessie again -- machine now refuses to boot
it. Dunno why probably something to do with the grub-install I did for LFS.
12) Boot original Debian Live USB stick again, which works. Mount /dev/sda2
and fix the grub.cfg file from all the mess I made earlier while trying to
get it to work. Also fix a bug in the file introduced from the original
instructions I was following which had a very small but important error --
a semicolon in the boot instructions before the root= option...
13) Reboot and watch the LFS instance boot successfully!

Thanks to all who helped. Hopefully these steps will attract critique
and/or help others who follow on the same path.

Overall I have some impression that the people making the live ISOs and the
people making the installer are not talking to each other as much as they
COULD be. eg live supports bluetooth successfully, installer doesn't,
installer supports UEFI boot, live doesn't, etc. One of the few significant
downsides to community-based projects I suppose -- the upsides obviously
dwarf such downsides. Overall Debian rocks!

Mark

Reply via email to