0% found this document useful (0 votes)
12 views3 pages

Run Amazon Linux 2 As A Virtual Machine On Premises - Amazon Elastic Compute Cloud

Uploaded by

ZhendongHe
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views3 pages

Run Amazon Linux 2 As A Virtual Machine On Premises - Amazon Elastic Compute Cloud

Uploaded by

ZhendongHe
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Run Amazon Linux 2 as a virtual machine on premises - Ama... https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/amazo...

AWS Documentation Amazon EC2 User Guide for Linux Instances

このページはお客様の⾔語に翻訳されていません。 翻訳のリクエスト

Run Amazon Linux 2 as a virtual machine on premises


PDF (/pdfs/AWSEC2/latest/UserGuide/ec2-ug.pdf#amazon-linux-2-virtual-machine) RSS (amazon-ec2-release-notes.rss)

Use the Amazon Linux 2 virtual machine (VM) images for on-premises development and testing. We offer a different Amazon Linux 2 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 (https://cdn.amazonlinux.com/os-images/latest/) page.

To use the Amazon Linux 2 virtual machine images with one of the supported virtualization platforms, do the following:

• Step 1: Prepare the seed.iso boot image (#amazon-linux-2-virtual-machine-prepare)


• Step 2: Download the Amazon Linux 2 VM image (#amazon-linux-2-virtual-machine-download)
• Step 3: Boot and connect to your new VM (#amazon-linux-2-virtual-machine-boot)

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 Amazon
Linux 2 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 Amazon
Linux 2 VM image creates an ec2-user user account. You use the user-data configuration file to set the password for the default user
account.

To create the seed.iso boot disc

1. Create a new folder named seedconfig and navigate into it.


2. Create the meta-data configuration file.
a. Create a new file named meta-data .
b. Open the meta-data file 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.254

Replace vm_hostname with a VM host name of your choice, and configure the network settings as required.
c. Save and close the meta-data configuration file.
For an example meta-data configuration 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

1 / 3 2023/12/30 21:12
Run Amazon Linux 2 as a virtual machine on premises - Ama... https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/amazo...

(https://cdn.amazonlinux.com/os-images/latest/) .

3. Create the user-data configuration file.


a. Create a new file named user-data .
b. Open the user-data file 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_password with a password of your choice for the default ec2-user user account.
c. (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

d. Save and close the user-data configuration 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 (http://cloudinit.readthedocs.io/en/latest/topics/modules.html) . For an example user-
data file that creates three additional users and specifies a custom password for the default ec2-user user account, see the sample
Seed.iso file (https://cdn.amazonlinux.com/os-images/latest/) .

4. Create the seed.iso boot image using the meta-data and user-data configuration files.
For Linux, use a tool such as genisoimage. Navigate into the seedconfig folder, and run the following command.

$ genisoimage -output seed.iso -volid cidata -joliet -rock user-data meta-data

For macOS, use a tool such as hdiutil. Navigate one level up from the seedconfig folder, and run the following command.

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

Step 2: Download the Amazon Linux 2 VM image


We offer a different Amazon Linux 2 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
(https://cdn.amazonlinux.com/os-images/latest/) page.

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 (#amazon-linux-2-virtual-machine-prepare) )
and an Amazon Linux 2 VM image (downloaded in Step 2 (#amazon-linux-2-virtual-machine-download) ). The steps vary depending on your
chosen VM platform.

VMware vSphere KVM Oracle VirtualBox Microsoft Hyper-V

To boot the VM using KVM

2 / 3 2023/12/30 21:12
Run Amazon Linux 2 as a virtual machine on premises - Ama... https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/amazo...

1. Open the Create new VM wizard.


2. For Step 1, choose Import existing disk image.
3. For Step 2, browse to and select the VM image. For OS type and Version, choose Linux and Red Hat Enterprise Linux 7.0
respectively.
4. For Step 3, specify the amount of RAM and the number of CPUs to use.
5. For Step 4, enter a name for the new VM and select Customize configuration before install, and choose Finish.
6. In the Configuration window for the VM, choose Add Hardware.
7. In the Add New Virtual Hardware window, choose Storage.
8. In the Storage configuration, choose Select or create custom storage. For Device type, choose CDROM device. Choose Manage,
Browse Local, and then navigate to and select the seed.iso file. Choose Finish.
9. Choose Begin Installation.

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.

© 2023, Amazon Web Services, Inc. or its affiliates.All rights reserved.

3 / 3 2023/12/30 21:12

You might also like