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

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