Amazon Linux 2 on Premise Installation Guide

Amazon Linux 2 on Premise Installation Guide

Almost since the beginning of Amazon Web Services (AWS), there has been Amazon Linux powering it. Amazon Linux has always been their own flavour of Red Hat’s community edition of Fedora Linux, tweaked and optimized for Amazon’s requirements.  Towards the back end of 2017 AWS released a version of the Amazon Linux 2 AMI for use in your own environment. Amazon provides a ‘Running Amazon Linux 2 as a Virtual Machine On-Premises‘ guide of their own, while it’s very good, but despite this it is somewhat lacking in a number of areas. For this reason I’ve put together my own ‘Amazon Linux 2 on Premise Installation Guide’, which I hope fills in the gaps.

Amazon Linux 2 on Premise Installation Guide – Assumptions

  1. You are using Mac OS
  2. The on-premise environment is being setup up using VMware. In my case VMfusion
  3. You have a basic understanding of the Mac terminal and Amazon Linux 2 environments.

Getting Started

  1. First of all, download the example seed.iso file from Amazon

The seed.iso contains the required user and network settings for your environment and will be used on first boot up. Your seed.iso will contain two files meta-data and user-data.

Setting up your files

  1. Now we will create your configuration files to use in the seed.iso
  2. Create a folder called ‘seedconfig’ and remember where you created it
  3. Double click on the seed.iso to mount the file and see the enclosed configuration files
  4. Copy these two files to your newly created ‘seedconfig’ folder. Do not try and edit these two files in a text editor, consequently if you do, none of your settings will be applied.

Editing Your Configuration Files

Meta-data Configuration

  1. Open ‘Terminal’ on your Mac
  2. Change the directory to where you downloaded the seed.iso. Example: cd /users/your.account/seedconfig
  3. Now we can edit the first file ‘meta-data’. In the Terminal session type: sudo nano meta-data and you will now see a screen similar to that below
Meta-Data Terminal
Using the ‘sudo nano’ command to change the meta-data config file.
  1. Remove the ‘#’ from all but two lines in the image
  2. Rename your instance in the first line (if you wish) by changing the name after ‘local-hostname:’.
  3. Change each of the network settings as required. I didn’t, as they were ok for me
  4. Click ‘Control + O’ to save your change, pressing return to confirm the changes
  5. Exit this window by clicking ‘Control + X’.

User-data Configuration

  1. Now you can edit the second file ‘user-data’. In the Terminal session type: sudo nano user-data.
  2. Delete the contents of this file and replace them with (replacing ‘YourPasswordHere’ with your own secure password):

#cloud-config
#vim:syntax=yaml
users:
# A user by the name `ec2-user` is created in the image by default.
- default
chpasswd:
list: |
ec2-user:YourPasswordHere
# In the above line, do not add any spaces after 'ec2-user:'.

  1. You should now be left with the screen shown below

User-data terminal

  1. Click ‘Control + O’ to save your change, pressing return to confirm the changes
  2. Exit this window by clicking ‘Control + X’.

Create the seed.iso Boot File

Now we generate the seed.iso boot image that we are going to use when the VM machine starts up.

  1. In the terminal window type:

hdiutil makehybrid -o seed.iso -hfs -joliet -iso -default-volume-name cidata seedconfig/

This will now generate an iso file named seed.iso in the folder you are currently in. Check this in ‘finder’.

Creating the Amazon Linux 2 VM Machine

Getting Started

  1. Download the latest Amazon Linux 2 image (official link) for VMware
  2. Start VMfusion and choose ‘File > New>
  3. Now choose ‘Create a custom virtual machine’ and click ‘Continue’
Creating a custom machine with VMfusion.
Creating a custom machine with VMfusion.
  1. Now select the Linux operating system as shown in the picture below and click ‘continue’
OS Selection Screen
Choose the Linux version as shown.
  1. Leave the ‘Choose Firmware Type’ settings as they are and click ‘continue’
Choose firmware type
Leave these settings as they are.
  1. From the ‘Choose a virtual disk’ window, click ‘use an existing disk’, then click ‘choose virtual disk…’. You will now be prompted to navigate to the Amazon Linux 2 .vmdk file you downloaded earlier.
Virtual disk selection
Choose to use an existing virtual disk.
  1. While selecting your downloaded .vmdk file make sure that ‘make a separate copy of the virtual disk’ is selected at the bottom of the screen. In the event of the setup failing, you will be able to start over with downloading the .vmdk file again
Create a copy of the virtual disk
Create a copy of the virtual disk.
  1. At the ‘Finish’ screen choose ‘Customise settings’. You should now be prompted to save your virtual machine file
The finish screen
Choose customise settings on the finish screen
  1. From the settings screen, choose ‘CD/DVD IDE’ and tick ‘Connect CD/DVD drive’. Further settings can also be changed from here, for example, RAM and processors
  2. From the drop-down select ‘Choose a disc or disc image’, from the resultant pop up locate and select the seed.iso file you created earlier and close this window
Choose connect CD
Connect a DVD to your virtual machine and mount the seed.iso file.
  1. Your machine is now ready for you to start. When you start your machine the name you specified should be displayed on startup.
The login screen
The login screen displaying your machine name.

Warning

Please beware that if for any reason your settings do not apply despite all your hard work to this point, you will have to delete your VM and start again, because the user-data and meta-data files are only applied the first time you boot up your machine.

Well, that’s my Amazon Linux 2 on premise installation guide, have you tried this guide? Then let me know how you get on either in the comments below or on Twitter.

Be the first to comment

Leave a Reply

Your email address will not be published.


*


This site uses Akismet to reduce spam. Learn how your comment data is processed.