[Solved] LEDE installation on UEFI-only x86(_64) systems and HyperV G2 possible?

Hi, i am looking for a recipe for building and installing LEDE on a small uefi only atom x5 cherrytrail box (beelink bt4 / z83). The bios is already reflashed to 64 bit and it works fine with ubuntu 16.04 and openbsd, other OSses boot fine from usb sticks.

I want to make this box my primary home office router, but was unlucky with the usual suspects, freebsd router distros have problems with the newer serial ports in cherry trail devices, the openwrt minnowboard solution doesnt boot and efi framebuffering did not work, so i dont know why, since there is no physically accessible serial port on the mainboard.

I also tested this with LEDE with no success, but LEDE worked fine in several virtual enviroments in my home lab, thats why i like it and ask here.

Is there a better uefi howto than this one somewhere**?**
wiki.openwrt.org/toh/minnowboard/minnowboard-max

I was able to build LEDE 17.01 from github in a debian vm but my resulting kernels never worked.

Btw., UEFI support would also be great for using LEDE as a fast and compact cloud router under Hyper-V with Gen2 drivers.

1 Like

Hyper-V? Something like this? https://github.com/tedaz/Hyper-V-support-for-OpenWrt-Chaos-Calmer

LEDE already works fine under Hyper-V with Gen1 drivers (takes just a quick qemu-img conversion run on a x86-64-combined-ext4.img to .vhdx). State of the art Hyper-V Gen2 driver based systems are faster, but they require UEFI support.

And a lot of "tablet without display" type small pcs or nucs require it too. Its the present state of the bios art in x86 systems. And it should be workable. I just need some hints.

Do you have some? :wink:

System
Hostname lede
Model Microsoft Corporation Virtual Machine
Firmware Version LEDE Reboot SNAPSHOT r3114-1a83d4d / LuCI Master (git-17.024.46287-ec99429)
Kernel Version 4.4.42
Lokale Zeit Sat Jan 28 01:19:10 2017
Laufzeit 0h 2m 6s
Durchschnittslast 0.07, 0.02, 0.00

Seems the regular LEDE x86_64 Kernel is EFI enabled enough to be booted from gummiboot. :+1:

Installation was a sick hack, i had to install debian 8 with uefi support on a usb stick, installed and configured gummiboot there, extracted partition 2 from x86-64-combined-ext4.img to partition 4 on that stick and copied vmlinuz to the uefi boot partition and after some tries with different kernel option in the loader it bootet on my Beelink z83.

I don't have a hdmi tty yet, but i will see, first i have to clean this hacked mess up and straighten the install process. :slight_smile:

root@lede:~# login as: root

Password:
BusyBox v1.25.1 () built-in shell (ash)

 _________
/        /\      _    ___ ___  ___

/ LE / \ | | | | | |
/ DE / \ | |
| || |) | |
/
______/ LE \ |||/|| lede-project.org
\ \ DE /
\ LE \ / -----------------------------------------------------------
\ DE \ / Reboot (17.01-SNAPSHOT, r3042-ec095b5)
_
/ -----------------------------------------------------------

=== WARNING! =====================================
There is no root password defined on this device!
Use the "passwd" command to set up a new password
in order to prevent unauthorized SSH logins.

root@lede:~#

The same is true for Hyper-V Gen2. One can install LEDE piggyback on a Debian UEFI Hyper-V Gen2 installation using gummiboot as the loader.

It should also be possible to remove Debian completely afterwards, but for me it makes more sense to keep it as a kind of "rescue image" and work environment for upgrades.

\ DE \ / Reboot (17.01.0-rc1, r3042-ec095b5)
________/ -----------------------------------------------------------

=== WARNING! =====================================
There is no root password defined on this device!
Use the "passwd" command to set up a new password
in order to prevent unauthorized SSH logins.

root@lede:~# dmesg | grep -i efi
[ 0.000000] efi: EFI v2.31 by EDK II
[ 0.000000] efi: ACPI=0x3fffa000 ACPI 2.0=0x3fffa014 SMBIOS=0x3fff2000 PROP=0x3fda3d8
[ 0.000000] DMI: Microsoft Corporation Virtual Machine/Virtual Machine, BIOS Hyper-V UEFI Release v1.0 11/26/2012
[ 0.000000] clocksource: refined-jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[ 2.870783] EFI Variables Facility v0.08 2004-May-17

Hi Revered Experts,

Can some write a quick dummies guide in bullet points on how to install LEDE on a Debian machine installed using UEFI.

I installed, Debian 8, installed gummiboot but not sure where to go from there?

Thanks

Daniel

Sorry, i did not write an install script, all done manually. :wink:

  • Leave free space on the disk you installed debian on, add an empty ext4 partition there for Lede, for instance with gdisk

  • dd the unzipped rootfs-ext4.img.gz into that empty partition, resize it if you used a bigger partition size after a reboot

https://downloads.lede-project.org/releases/17.01.0-rc2/targets/x86/64/lede-17.01.0-rc2-r3131-42f3c1f-x86-64-rootfs-ext4.img.gz

  • copy debian + lede kernels and debian initrd image into the EFI Partition (usually mounted in debian as /boot/efi)

  • edit gummiboots config accordingly

  • reboot + choose Lede in the boot menu you will see after the reboot

Partitions on my hyperv vm:

Lede resides on sda4

root@debian:~# fdisk -l

Disk /dev/sda: 28 GiB, 30064771072 bytes, 58720256 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: A96843D6-E6DD-4A91-B12D-32B3FFBD532C

Device Start End Sectors Size Type
/dev/sda1 2048 1050623 1048576 512M EFI System
/dev/sda2 1050624 10815487 9764864 4,7G Linux filesystem
/dev/sda3 10815488 14721023 3905536 1,9G Linux swap
/dev/sda4 14721024 56664063 41943040 20G Linux filesystem

root@debian:~# ls -la /boot/efi/
insgesamt 20004
drwx------ 4 root root 4096 Jan 1 1970 .
drwxr-xr-x 4 root root 4096 Feb 1 10:56 ..
drwx------ 5 root root 4096 Jan 29 20:21 EFI
-rwx------ 1 root root 14726496 Jan 29 20:06 initrd.img
drwx------ 3 root root 4096 Jan 29 20:21 loader
-rwx------ 1 root root 3128032 Jan 2 22:45 vmlinuz.debian
-rwx------ 1 root root 2605648 Feb 1 10:43 vmlinuz.lede

root@debian:~# cat /boot/efi/loader/loader.conf
timeout 10
default Debian
LEDE

root@debian:~# cat /boot/efi/loader/entries/Debian.conf
title Debian
linux /vmlinuz.debian
initrd /initrd.img
options ro root=/dev/sda2

root@debian:~# cat /boot/efi/loader/entries/LEDE.conf
title LEDE
linux /vmlinuz.lede
options ro root=/dev/sda4 rootfstype=ext4 rootwait console=tty0

Thanks.

I really appreciate this.

I don't think that this is a sick hack. I actually found this to be an excellent idea and I am going to set up my OpenWRT like this as a default on x86 platforms. In the meantime (2y later) it seems that there there will be a combined UEFI 64bit OpenWRT image released quite soon that should work out of the box in Gen2 virtual machines (after conversion to a hper-v virtual disk). But I will stick to your "hack".

I just wanted to add to your explanations the basic steps that I took to sucessfully install 64bit OpenWRT 18.x in a Gen2 hyper-v machine:

  1. Downloaded 64bit Debian 9 minimal ISO

  2. Downloaded 64bit OpenWRT rootfs-ext4.img.gz and vmlinuz (compressed kernel) and moved the 2 files into an ISO-file (I used folder2iso on Windows) for mounting into the virtual machine later on

  3. Create new Gen2 virtual machine (I assigned 512MB RAM, a 4GB disk and two network interfaces) and I did not check secure boot in the firmware

  4. Mounted Debian ISO and booted from it, I used a minimal install without graphical interface as there was no need for me to do a full Debian install. I chose manual GPT partitioning and created an 256MB EFI boot partition (sda1), a 1 GB part for OpenWRT (sda2, unmounted as the UUID will change later), a 512 MB swap partition on sda3 and a 2GB+ Debian partition on sda4 taking up the remaining space. This way it is possible to expand the disk and enlarge the Debian partition later if needed. Finished Debian installation.

  5. Mounted the 2nd ISO to the VM, booted Debian and copied the OpenWRT kernel to /boot (EFI partition)

  6. Unzipped and wrote rootfs-ext4.img.gz to sda2 with dd, resized OpenWRT partition with resize2fs -p /dev/sda2 to its full size (1GB). Beware that this changes the UUID, that is also why I did not mount sda2 during install. I saw no need to use UUIDs to mount the partition in Debian. I just added /dev/sda2 in fstab to mount to a new folder named /openwrt. This mount will still work if you upgrade (dd) to a new image version.

  7. Told the bootmanager (GRUB2 by default in Debian 9) to boot the OpenWRT kernel

The past part seemed a bit complicated at first glance, but it is actually very simple if you know how to do it. Gummiboot or its sucessor are not needed (can be used optionally to replace GRUB). All you have to do for GRUB is to copy the following text to /etc/grub.d/40_custom and run update-grub

menuentry 'OpenWRT' {
echo 'Loading OpenWrt ...'
linux /boot/openwrt-nn.nn-x86-64-vmlinuz root=/dev/sda2 noinitrd
}

Of course you have to match the name of the kernel file to your version. I also changed the default to OpenWRT in /etc/default/grub (the 3rd menuentry is grub_default=2). Remark: You can also change the OpenWRT initial default LAN IP through /openwrt/lib/preinit/00_preinit.conf from Debian (only before you boot for the first time!). After a reboot of the Debian system OpenWRT should start.

The nice thing about having a rescue system is that it is now super easy to update, customize, backup or un-brick the image in case of troubles by booting into the Debian system. And all this takes up just 4GB. As I said before - not a sick hack at all.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.