Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jms/d7b2cce6df2174e49b603a7562b54fcc to your computer and use it in GitHub Desktop.
Save jms/d7b2cce6df2174e49b603a7562b54fcc to your computer and use it in GitHub Desktop.
Install and run Amazon AWS Linux 2 locally on KVM virt-manager with qemu virtual disk

install and run AWS linux 2 on home computer as a virtual machine

These instructions are tailored for KVM and virt-manager specifically .

Detailed Instructions are here : https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/amazon-linux-2-virtual-machine.html ( for VMWare and VirtualBox and Hyoer-V in addiation to KVM )

Instructions sample configs and cloud-init files for on on-premises images: https://cdn.amazonlinux.com/os-images/2.0.20201111.0/

KVM / qemu / virt-manager instructions -

Step 1

Download 2 files - the seed.iso and then the actual OS disk image.     For KVM/qemu/virt-manager the OS file is currently named amzn2-kvm-2.0.20201111.0-x86_64.xfs.gpt.qcow2
Here: 
https://cdn.amazonlinux.com/os-images/2.0.20201111.0/kvm/

Step 2 ( or step 1.5 )

Download "SHA256sums" file containing sha256 sums   and download shasums signature file ( .gpg ) 
check sha256sum
import this AWS  key:  0x11CF1F95C87F5B1A
validate signature on the shasum signature file ( SHA256SUMS.gpg ) with gpg

If the sha256sum checks out and the signature file is valid then proceed:

Step 3 ( NoCloud data source creation )

Create two simple local text configuration files named 'meta-data' and 'user-data' .
meta-data is network settings and user-data sets up the ec2-user username account.
See this link for default settings; 
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/amazon-linux-2-virtual-machine.html#amazon-linux-2-virtual-machine-prepare 

Change the network settings to fit your local network IP addresses or DHCP.

Note - the 2 local text files act as a "data source" named NoCloud - that is the IP addresses and usernames are NOT taken from AWS-EC2 or from DigitalOcean etc etc. See this: https://cloudinit.readthedocs.io/en/latest/topics/datasources/nocloud.html

and the far more intimidating version of that info here:

https://cdn.amazonlinux.com/os-images/2.0.20201111.0/README.cloud-init and finally - the whole list of potential data sources here, with some blah-blah about telling the guest OS about the host virt. platform

Cloud Init docs

https://cloudinit.readthedocs.io/en/latest/topics/datasources.html

Step 4

Generate a boot ISO using  seed.iso along with data-source files named 'meta-data' and 'user-data'  that you created:
That is to say - run the genisoimage command below: 
$ genisoimage -output seed.iso -volid cidata -joliet -rock user-data meta-data

Step 5

Create a new vm in virt-manager 
    Select Import existing disk image and use the qcow VM file  ( amzn2-kvm-2.0.20201111.0-x86_64.xfs.gpt.qcow2 )
    " For OS type and Version, choose Linux and Red Hat Enterprise Linux 7.0 "
    Create a _new_ CDROM custom storage 
        Browse local and choose the _generated_ seed.iso 
Begin Installation.

"After the VM has booted, log in using one of the user accounts that is defined in the user-data configuration file. " Disconnect the seed.iso after you log in supposedly

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