Installing OpenWrt on AWS

I have selected export in vmdk format from make menuconfig.

Once i try uploading vmdk file using aws cli, it gives the error -->

ClientError: No initrd exists for this menuentry 0

Has anyone else faced this issue ?

Please help

I can't help but express my curiosity here as to what is the driver behind wanting to run OpenWrt on an EC2 instance?

Regardless, the only thing that comes to mind at the moment is whether the image you are producing is an EFI image or not. If EFI, perhaps try producing a non-EFI image and try with it instead.

Example of the possible options:

[ ] Build GRUB images (Linux x86 or x86_64 host only)
[*] Build GRUB EFI images (Linux x86 or x86_64 host only)

Update:
Just had another thought... the other thing I have come across with the OpenWrt built VMDK files is that they seem to be built in the VMware Workstation VMDK file format. They are not directly usable by ESXi, for example, without running them through the vmkfstools binary. It would generally look something like this (though there are many good guides on the net that go into greater detail):

vmkfstools -i workstation.vmdk -d thin newesx.vmdk

How does this relate? Well, I am assuming EC2 would be more likely to mirror the ESXi format requirement for the VMDK. Just a guess on my part, though.

Hey.. thanks so much for replying..

Well, so basically I have created a custom build of OpenWRT with quite a lot of changes which I normally deploy in physical hardware for the customers.

Now, there are some customers who need to perform certain routing and firewalling functions for the VMs they have hosted in the cloud.

Now I dont want to reinvent everything that has been already done. Hence the reason.

I understood your idea of converting into ESXI compatible format. Will surely try it out.

However, as per this thread ,

and the short instructions that the user has given, he has not done these steps and still managed to get it running which is kind of strange.

Yes, following this guide and running this command

aws ec2 import-image --disk-containers Format=vmdk,UserBucket="{S3Bucket=mybucket,S3Key=openwrt-22.03.2-x86-64-generic-ext4-combined-efi.vmdk}"

fails with the error above.

What worked was first importing the image as an EBS snapshot then creating an AMI from that snapshot (either using the CLI or UI). Then the AMI can be launched OK.

Here's a complete example using the raw disk images (official images or from ImageBuilder):

gunzip --keep openwrt-22.03.2-x86-64-generic-ext4-combined-efi.img.gz

qemu-img convert -f raw -O vmdk -o subformat=streamOptimized \
	openwrt-22.03.2-x86-64-generic-ext4-combined-efi.img \
	openwrt-22.03.2-x86-64-generic-ext4-combined-efi.vmdk

# Upload to S3 according to AMI import guide above

aws ec2 import-snapshot \
	--description "OpenWrt 22.03.2 Snapshot Import" \
	--disk-container Format=vmdk,UserBucket="{S3Bucket=mybucket,S3Key=openwrt-22.03.2-x86-64-generic-ext4-combined-efi.vmdk}"

aws ec2 describe-import-snapshot-tasks \
	--import-task-ids import-snap-XXXYYY

aws ec2 register-image \
	--name "myusername-openwrt-22.03.2" \
	--description "OpenWrt 22.03.2" \
	--architecture x86_64 \
	--root-device-name "/dev/sda2" \
	--virtualization-type hvm \
	--boot-mode uefi \
	--block-device-mappings '[{"DeviceName": "/dev/sda2","Ebs":{"SnapshotId":"snap-AAABBB","VolumeSize":1,"DeleteOnTermination":true,"VolumeType":"gp2"}}]'

(I'm not sure if the device names should be /dev/sda or somethnig else, but this works for me).