At the core of the Logilab infrastructure is a highly-available pair of small machines dedicated to our main directory and authentication services: LDAP, DNS, DHCP, Kerberos and Radius.

The machines are small fanless boxes powered by a 1GHz Via Eden processor, 512Mb of RAM and 2Gb of storage on a CompactFlash module.

They have served us well for many years, but now is the time for an improvement. We've bought a pair of Lanner FW-7543B that have the same form-factor. They are not fanless, but are much more powerful. They are pretty nice, but have one major drawback: their firmware does not boot on a legacy BIOS-mode device when set up in UEFI. Another hard point is that they do not have a video connector (there is a VGA output on the motherboard, but the connector is optional), so everything must be done via the serial console.

I knew the Debian Jessie installer would provide everything that is required to handle an UEFI-based system, but it took me a few tries to get it to boot.

First, I tried the standard netboot image, but the firmware did not want to boot from a USB stick, probably because the image requires a MBR-based bootloader.

Then I tried to boot from the Refind bootable image and it worked! At least I had the proof this little beast could boot in UEFI. But, although it is probably possible, I could not figure out how to tweak the Refind config file to make it boot properly the Debian installer kernel and initrd.

Finally I gave a try to something I know much better: Grub. Here is what I did to have a working UEFI Debian installer on a USB key.


First, in the UEFI world, you need a GPT partition table with a FAT partition typed "EFI System":

david@laptop:~$ sudo fdisk /dev/sdb
Welcome to fdisk (util-linux 2.25.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Command (m for help): g
Created a new GPT disklabel (GUID: 52FFD2F9-45D6-40A5-8E00-B35B28D6C33D).

Command (m for help): n
Partition number (1-128, default 1): 1
First sector (2048-3915742, default 2048): 2048
Last sector, +sectors or +size{K,M,G,T,P} (2048-3915742, default 3915742):  +100M

Created a new partition 1 of type 'Linux filesystem' and of size 100 MiB.

Command (m for help): t
Selected partition 1
Partition type (type L to list all types): 1
Changed type of partition 'Linux filesystem' to 'EFI System'.

Command (m for help): p
Disk /dev/sdb: 1.9 GiB, 2004877312 bytes, 3915776 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 52FFD2F9-45D6-40A5-8E00-B35B28D6C33D

Device     Start    End Sectors  Size Type
/dev/sdb1   2048 206847  204800  100M EFI System

Command (m for help): w

Install Grub

Now we need to install a grub-efi bootloader in this partition:

david@laptop:~$ pmount sdb1
david@laptop:~$ sudo grub-install --target x86_64-efi --efi-directory /media/sdb1/ --removable --boot-directory=/media/sdb1/boot
Installing for x86_64-efi platform.
Installation finished. No error reported.

Copy the Debian Installer

Our next step is to copy the Debian's netboot kernel and initrd on the USB key:

david@laptop:~$ mkdir /media/sdb1/EFI/debian
david@laptop:~$ wget -O /media/sdb1/EFI/debian/linux
--2016-06-13 18:40:02--  /images/netboot/debian-installer/amd64/linux
Resolving (, 2a01:e0c:1:1598::2
Connecting to (||:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3120416 (3.0M) [text/plain]
Saving to: ‘/media/sdb1/EFI/debian/linux’

/media/sdb1/EFI/debian/linux      100%[========================================================>]   2.98M      464KB/s   in 6.6s

2016-06-13 18:40:09 (459 KB/s) - ‘/media/sdb1/EFI/debian/linux’ saved [3120416/3120416]

david@laptop:~$ wget -O /media/sdb1/EFI/debian/initrd.gz
--2016-06-13 18:41:30--
Resolving (, 2a01:e0c:1:1598::2
Connecting to (||:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 15119287 (14M) [application/x-gzip]
Saving to: ‘/media/sdb1/EFI/debian/initrd.gz’

/media/sdb1/EFI/debian/initrd.g    100%[========================================================>]  14.42M    484KB/s   in 31s

2016-06-13 18:42:02 (471 KB/s) - ‘/media/sdb1/EFI/debian/initrd.gz’ saved [15119287/15119287]

Configure Grub

Then, we must write a decent grub.cfg file to load these:

david@laptop:~$ echo >/media/sdb1/boot/grub/grub.cfg <<EOF
menuentry "Jessie Installer" {
  insmod part_msdos
  insmod ext2
  insmod part_gpt
  insmod fat
  insmod gzio
  echo  'Loading Linux kernel'
  linux /EFI/debian/linux --- console=ttyS0,115200
  echo 'Loading InitRD'
  initrd /EFI/debian/initrd.gz

Et voilà, piece of cake!

blog entry of