What is Amazon Linux?
Amazon Linux 2 is a Linux operating system from Amazon Web Services (AWS). It provides a security-focused, stable, and high-performance execution environment to develop and run cloud applications. -https://aws.amazon.com/amazon-linux-2
Creating the VM
- Open a web browser and navigate to the ProxMox web UI (ie https://ProxMoxDNSorIP:8006/)
- Right click the Proxmox node name > Create VM
- Give the VM a unique ID and Name > Next
- On the OS tab, Select Do not use any media, leave the Type as Linux and the Version as 5.x - 2.6 Kernel > Next
- On the System tab, leave the defaults and check the Qemu Agent box to enable it > Next
- On the Hard Disk tab, delete the scsi0 disk > Next
- On the CPU tab, set Cores to 1 or more and Type to host > Next
- On the Memory tab, set the Memory to 512 or more > Next
- Leave the defaults on the Network tab > Next
- Verify the summary and click Finish
- Click the Proxmox node in the left navigation menu > Shell
- Run the following commands in the web shell
# lookup the latest amazon linux file name
regex='<td><a href="([^/]*\.qcow2)">[^/]*<\/a><\/td>' && response=$(curl -s -L https://cdn.amazonlinux.com/os-images/latest/kvm/) && [[ $response =~ $regex ]] && downloadURL="${BASH_REMATCH[1]}"
# download the amazon linux virtual disk
wget -O /tmp/al2.qcow2 https://cdn.amazonlinux.com/os-images/latest/kvm/$downloadURL
# import the downloaded virtual disk
# update the vmid and destination storage pool to match your environment
# usage
# qm importdisk <%target vmid%> <%path to source disk%> <%destination storage device%> [OPTIONS]
qm importdisk 2000 /tmp/al2.qcow2 SSD_100GB - Once the import completes, select the newly created Amazon Linux VM from the left navigation panel
- Select Hardware from the left sub-navigation menu
- Double click the Unused Disk to edit it > Click the Add button
- Click the Add dropdown > CloudInit Drive
- Set the target storage for the CloudInit drive > Click the Add button
- Select Cloud-Init from the left sub-navigation menu
- Edit each of the Cloud-Init fields to set a username, password and DNS/network parameters
- Select Options from the left sub-navigation menu
- Double click Boot Order
- Check the Enabled box next to the hard disk and drag it up in the boot order as needed, typically below the CD-ROM device
- Click OK
- Click the Start button in the top right of the screen
- Select Console from the left sub-navigation menu to watch the boot process
Setting Up Amazon Linux 2
- Once the boot process completes, login with the username and password set in the Cloud-Init settings earlier
- Run the following commands in the terminal
# elavate to root
sudo su
# enable hostname preservation in cloud-init config
echo -e "\npreserve_hostname: true" >> /etc/cloud/cloud.cfg
# set the hostname
hostnamectl set-hostname amazon-linux
# output hostname details
hostnamectl
# update software repositories
yum check-update
# install available updates
yum update
# install qemu-guest-agent
yum install qemu-guest-agent -y
# shutdown
shutdown now - Once the VM has shutdown completely, power it back up on clicking the Start button at the top right of the screen
- After the boot process completes, login back in
- Continue with the following command in the terminal
# verify hostname details were retained
sudo hostnamectl - Welcome to Amazon Linux running in Proxmox