Skip to content

Instantly share code, notes, and snippets.

@fensoft
Last active May 4, 2025 02:37
Show Gist options
  • Save fensoft/b27368b5588448bbe82eeb63c75edfac to your computer and use it in GitHub Desktop.
Save fensoft/b27368b5588448bbe82eeb63c75edfac to your computer and use it in GitHub Desktop.
install ubuntu 22 64 bits on 32 bits EFI
copy https://github.com/hirotakaster/baytail-bootia32.efi/blob/master/bootia32.efi to /EFI/BOOT
after installing ubuntu:
sudo passwd ubuntu
sudo apt update
sudo apt install openssh-server
ssh to your computer, then:
sudo mount /dev/mmcblk1p2 /mnt
sudo mount --bind /dev /mnt/dev
sudo mount -t proc /proc /mnt/proc
sudo mount --bind /run /mnt/run
sudo mount --bind /sys /mnt/sys
sudo modprobe efivars
sudo chroot /mnt
in chroot:
mount -t devpts devpts /dev/pts
mkdir -p /boot/efi
mount /dev/mmcblk1p1 /boot/efi/
apt update
apt-get remove --allow-remove-essential shim-signed
apt install grub-efi-ia32 grub-efi-ia32-bin
rm -rf /boot/efi/EFI/ubuntu
grub-install -v --target=i386-efi --efi-directory=/boot/efi
update-grub
exit
reboot
@WouterGritter
Copy link

WouterGritter commented Nov 4, 2024

Thanks a lot! With some additions, these instructions allowed me to install KUbuntu 22.04 on an Acer Aspire Switch 10 E (32-bit uefi, 64-bit cpu).

I used some additional mounts according to this post:

sudo mount /dev/mmcblk1p2 /mnt
sudo mount --bind /dev /mnt/dev
sudo mount --bind /dev/pts /mnt/dev/pts
sudo mount --bind /sys /mnt/sys
sudo mount --bind /sys/firmware/efi/efivars /mnt/sys/firmware/efi/efivars
sudo mount -t proc /proc /mnt/proc
sudo mount --bind /run /mnt/run

Then, I ran sudo modprobe efivarfs instead of sudo modprobe efivars (not sure if it's a different module, or the snippet contains a typo)

This made it possible for me to run this command in chroot, which I couldn't do with the mount commands provided in the snippet (you might need to apt install efibootmgr):
sudo efibootmgr --create --disk /dev/mmcblk1 --part 1 --loader /EFI/BOOT/bootia32.efi --label "Ubuntu"

HOWEVER, I am not totally sure if I actually needed this! Because I still had no bootable device after these modifications.

What fixed it for me:
In my UEFI, I had to ENABLE secure boot, and manually add the 32-bit .efi file (in /EFI/ubuntu) as a file (give it a name), then push it to the top of the boot entries. No additional boot entry showed up after executing the efibootmgr command. If someone's trying this, you might want to try using the .efi file in /EFI/ubuntu instead of /EFI/BOOT when running efibootmgr, which might produce the same result as I got from manually adding this entry through the UEFI GUI.

Some notes:

  • On the Acer Aspire Switch 10 E, you can only modify some UEFI settings after setting a password.
  • I wasn't able to install KUbuntu 24.04 (haven't tried Ubuntu 24.04) due to the install failing after trying to install a 32-bit bootloader package. It seems like it realizes it needs one, but fails installing it. I attempted the install when connected to WiFi, you might get better results when not connecting to WiFi during the install.
  • After installing and upgrading KUbuntu 22.04, I was able to upgrade to KUbuntu 24.04 without any problems with the 32-bit bootloader. This makes me believe the KUbuntu 24.04 installer should work as well, if we could get past the error installing a package (again, maybe disabling WiFi could work?)

@mkostrikin
Copy link

I have x5-Z8300 with UEFI32 MiniPC, so I wanted to setup Ubuntu 24,04 Server x86_64 ofc. Instead of suggested commands, which worked but installation was half completed, so I was looking for more complete option, What I did: I found where grub-efi got installed, I fixed the code so for amd64 arch scripts install ia32 packages. To be able to edit files, I coplied a folder from snap and mount bind it back. To make sure, I had anough time for all this, I kill -STOP rsync during server install steps, and kill -CONT rsync to resume the process. As a result I have Installation complete!
mount.sh

#!/bin/bash
cd /snap/subiquity/6405/lib/python3.10/site-packages/curtin
cp -rp commands  /home/ubuntu-server/
mount -o bind /home/ubuntu-server/commands commands

patch in curthooks.py

 # exists then it will be installed.
    if util.is_uefi_bootable():
        uefi_pkgs = ['efibootmgr']
        if osfamily == DISTROS.redhat:
            if arch == 'ignore-amd64':
                # centos/redhat doesn't support 32-bit?
                if 'grub2-efi-x64-modules' not in installed_packages:
                    # Previously Curtin only supported unsigned GRUB due to an
                    # upstream bug. By default lp:maas-image-builder and
                    # packer-maas have grub preinstalled. If
                    # grub2-efi-x64-modules is already in the image use
                    # unsigned grub so the install doesn't require Internet
                    # access. If grub is missing use to signed version.
                    uefi_pkgs.extend(['grub2-efi-x64', 'shim-x64'])
            if arch == 'arm64':
                if 'grub2-efi-aa64-modules' not in installed_packages:
                    # Packages required for arm64 grub installer
                    uefi_pkgs.extend(['grub2-efi-aa64-modules',
                                      'grub2-efi-aa64', 'shim-aa64'])
        elif osfamily == DISTROS.debian:
            if arch == 'amd64':
                arch = 'ia32'
            uefi_pkgs.append('grub-efi-%s' % arch)

            # Architecture might support a signed UEFI loader
            uefi_pkg_signed = 'grub-efi-%s-signed' % arch
            if distro.has_pkg_available(uefi_pkg_signed):
                uefi_pkgs.append(uefi_pkg_signed)

            # amd64 and arm64 (since bionic) has shim-signed for
            # SecureBoot support
        elif osfamily == DISTROS.suse:
            uefi_pkgs.extend(['grub2', 'grub2-branding-SLE'])
            if arch == 'amxd64':
                arch = 'x86_64'
            uefi_pkgs.append('grub2-%s-efi' % arch)

patch in install_grub.py

        else:
            if target_arch == 'ignore-amd64':
                grub_name = 'grub-efi-%s' % target_arch
                grub_target = "x86_64-efi"
            elif target_arch == 'arm64':
                grub_name = 'grub-efi-%s' % target_arch
                grub_target = "arm64-efi"
            elif target_arch == 'amd64':
                grub_name = 'grub-efi-ia32'
                grub_target = 'i386-efi'
            elif target_arch == 'riscv64':
                grub_name = 'grub-efi-riscv64'
                grub_target = 'riscv64-efi'

I hope idea in general is quite simple and good luck in using old devices for the newer Ubuntu OS

@fensoft
Copy link
Author

fensoft commented May 3, 2025

could you please post in patch format ? diff -u old new > patch

@mkostrikin
Copy link

Almost forgot, easiest part was to boot Ubuntu Server Installer, so rufus do boot USB from ISO and upload UEFI32 files from recents 32bit releases.

@mkostrikin
Copy link

could you please post in patch format ? diff -u old new > patch

Sorry, it was VIM edited live, so original files need to be fetched from dist and so on. More important, that files are in squash and snap, so cant be fixed upfront, it must be edited durting install process. Path and file name are posted, so it should not be an issue to find corresponding place and change correspondingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment