Run AL2 as a virtual machine on premises
Use the AL2 virtual machine (VM) images for on-premises development and testing. We
offer a different AL2 VM image for each of the supported virtualization platforms. You
can view the list of supported platforms on the Amazon Linux 2 virtual machine
images
To use the AL2 virtual machine images with one of the supported virtualization platforms, do the following:
Step 1: Prepare the
seed.iso boot image
The seed.iso boot image includes the initial configuration
information that is needed to boot your new VM, such as the network configuration,
host name, and user data.
Note
The seed.iso boot image includes only the configuration
information required to boot the VM. It does not include the AL2 operating
system files.
To generate the seed.iso boot image, you need two configuration
files:
-
meta-data– This file includes the hostname and static network settings for the VM. -
user-data– This file configures user accounts, and specifies their passwords, key pairs, and access mechanisms. By default, the AL2 VM image creates anec2-useruser account. You use theuser-dataconfiguration file to set the password for the default user account.
To create the seed.iso boot disc
-
Create a new folder named
seedconfigand navigate into it. -
Create the
meta-dataconfiguration file.-
Create a new file named
meta-data. -
Open the
meta-datafile using your preferred editor and add the following.local-hostname:vm_hostname# eth0 is the default network interface enabled in the image. You can configure static network settings with an entry like the following. network-interfaces: | auto eth0 iface eth0 inet static address 192.168.1.10 network 192.168.1.0 netmask 255.255.255.0 broadcast 192.168.1.255 gateway 192.168.1.254Replace
vm_hostnamewith a VM host name of your choice, and configure the network settings as required. -
Save and close the
meta-dataconfiguration file.
For an example
meta-dataconfiguration file that specifies a VM hostname (amazonlinux.onprem), configures the default network interface (eth0), and specifies static IP addresses for the necessary network devices, see the sample Seed.iso file. -
-
Create the
user-dataconfiguration file.-
Create a new file named
user-data. -
Open the
user-datafile using your preferred editor and add the following.#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:plain_text_password# In the above line, do not add any spaces after 'ec2-user:'.Replace
plain_text_passwordwith a password of your choice for the defaultec2-useruser account. -
(Optional) By default, cloud-init applies network settings each time the VM boots. Add the following to prevent cloud-init from applying network settings at each boot, and to retain the network settings applied during the first boot.
# NOTE: Cloud-init applies network settings on every boot by default. To retain network settings # from first boot, add the following ‘write_files’ section: write_files: - path: /etc/cloud/cloud.cfg.d/80_disable_network_after_firstboot.cfg content: | # Disable network configuration after first boot network: config: disabled -
Save and close the
user-dataconfiguration file.
You can also create additional user accounts and specify their access mechanisms, passwords, and key pairs. For more information about the supported directives, see Module reference
. For an example user-datafile that creates three additional users and specifies a custom password for the defaultec2-useruser account, see the sample Seed.iso file. -
-
Create the
seed.isoboot image using themeta-dataanduser-dataconfiguration files.For Linux, use a tool such as genisoimage. Navigate into the
seedconfigfolder, and run the following command.$genisoimage -output seed.iso -volid cidata -joliet -rock user-data meta-dataFor macOS, use a tool such as hdiutil. Navigate one level up from the
seedconfigfolder, and run the following command.$hdiutil makehybrid -o seed.iso -hfs -joliet -iso -default-volume-name cidata seedconfig/
Step 2: Download the AL2 VM image
We offer a different AL2 VM image for each of the supported virtualization
platforms. You can view the list of supported platforms and download the correct VM
image for your chosen platform from the Amazon Linux 2 virtual
machine images
Step 3: Boot and connect to your new VM
To boot and connect to your new VM, you must have the seed.iso boot
image (created in Step
1) and an AL2 VM image (downloaded in Step 2). The steps vary
depending on your chosen VM platform.
After the VM has booted, log in using one of the user accounts that is defined in
the user-data configuration file. After you have logged in for the
first time, you can then disconnect the seed.iso boot image from the VM.