1

I am trying to create a custom Debian based AMI with my own custom kernel for AWS EC2 instances, specifically I'm trying to run it on t4g.micro/medium instances.

I debootstrap an ARM64 Debian and copy the required /boot/efi/EFI/* contents from an AWS EC2 machine, I create an ESP/vfat partition to hold the EFI data and copy the contents of /boot from an original EC2 instance, however, when I try to boot the instance I encouter an EFI shell, (after 10 minutes of waiting).

  1. The image does not use secure boot, so booting it should work.
  2. I am using the same kernel provided by AWS as a dry run to remove the concern that my kernel is valid.
  3. I created a raw disk using qemu-nbd and mkfs.vfat.

Does anyone know what is the issue here? I am a bit lost.

I'm attaching my script:

sudo qemu-debootstrap --arch=arm64 --include=openssh-server,curl,tar,gcc,libc6-dev,time,strace,sudo,less,psmisc,selinux-utils,policycoreutils,checkpolicy,selinux-policy-default,firmware-atheros --components=main,contrib,non-free stable debian
fallocate -l4G disk.raw 
DISKDEV=/dev/nbd0
sudo qemu-nbd -c /dev/nbd0 --format=raw disk.raw
echo -en "g\nn\n\n\n+110M\nt\n1\nn\n2\n\n\n\nw\n" | sudo fdisk
PARTDEV=$DISKDEV"p2"
sudo -E mkfs.ext4 -O ^resize_inode,^has_journal,ext_attr,extents,huge_file,flex_bg,dir_nlink,sparse_super $PARTDEV
mkdir -p disk.mnt
sudo mount $PARTDEV disk.mnt
sudo mkfs.vfat -F 32 $DISKDEV"p1"
mkdir efi.mnt
sudo mount -t vfat $DISKDEV"p1" efi.mnt
sudo cp -r ./debian/boot/efi/ ./efi.mnt/
sudo cp -a debian/. disk.mnt/.
.. unmounting flow goes here ..
user620284
  • 11
  • 2
  • can you elaborate? i copied the kernel image from t4g.micro instance, from the ``/boot`` directory. am i creating the partition correctly? should the vfa/ESP partition be -F32 or maybe -F16? I wish there was better documentation or an example for something like it, but i don't see one :( – user620284 Mar 02 '21 at 10:24
  • The ESP part looks right. But there is conflicting information in your question - have you used that script to ensure you are loading a kernel debootstrap unpacked using a bootloader debootstrap configured? Or have you manually copied files from a different image which may have ended up in inappropriate paths? (Suggestion: Clarify your question with the output of `find efi.mnt` and `ls -l disk.mnt/boot/`) – anx Mar 02 '21 at 12:09
  • I don't understand your question @anx :( can you please clarify it? – user620284 Mar 04 '21 at 17:22

0 Answers0