01) Install Hyper-V Features.
In Windows, search for "Turn Windows features on or off" and click, tick "Hyper-V" and click <Ok> to install.
Follow any prompts, like reboot to complete installation.
02) Download and Extract latest Amazon Linux 2023 on premise distrobution for Hyper-V: https://cdn.amazonlinux.com/al2023/os-images/latest/
Example: https://cdn.amazonlinux.com/al2023/os-images/2023.6.20241010.0/hyperv/al2023-hyperv-2023.6.20241010.0-kernel-6.1-x86_64.xfs.gpt.vhdx.zip
03) Extract Hard Disk Image File from compressed download.
Example: al2023-hyperv-2023.6.20241010.0-kernel-6.1-x86_64.xfs.gpt.vhdx
04) In Linux (WSL Ubuntu or other) create files for seed.iso cloud-init(no cloud) configuration.
# cd ~
# mkdir ~/seed
05) Create meta-data file:
# cd ~/seed
# vi meta-data
#cloud-config
instance-id: al2023
local-hostname: al2023
06) Install mkpasswd command:
# apt install whois
07) Generate encrypted password, for example "amazon":
# mkpasswd -m sha-512
08) Generate SSH Key for example user "user1", enter user1 when prompted for filename:
# cd ~
# ssh-keygen -C "user1"
Generating public/private ed25519 key pair.
Enter file in which to save the key (/root/.ssh/id_ed25519): user1
user1 already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in user1
Your public key has been saved in user1.pub
The key fingerprint is:
SHA256:HAGhj82L+infJmhuFvJITjgMTXfvaOPDQKmBtfA488c user1
The key's randomart image is:
+--[ED25519 256]--+
| oo. |
|. o ... . |
| O o.o .. |
|* = o= ... |
|++ =. +oS |
|+++ E.+.. |
|+= +.=.. |
|..B..o= |
| =o++o.. |
+----[SHA256]-----+
# ls -ltr user1*
-rw-r--r-- 1 root root 87 Oct 18 12:51 user1.pub
-rw------- 1 root root 387 Oct 18 12:51 user1
09) Create user-data file (replace passwd string with above output):
# cd ~/seed
# vi user-data
#cloud-config
#vim:syntax=yaml
users:
- default
- name: user1
groups: sudo
sudo: ['ALL=(ALL) NOPASSWD:ALL']
shell: /bin/bash
passwd: $6$eeBSP/YQRclTQTpj$EfkPClBIL1.xqxiGUJci/QjanFB2oReYfRKRocE/TUgPXbpTnPMvEWzntlHUwgAE5uYziOBx5dfBgPaSh2WxV1
lock_passwd: false
ssh_authorized_keys:
- ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMy9/FBckJgwzCCPLHPB1GNgr3D8OpD65os1AEo+ExNS user1
chpasswd:
list: |
ec2-user:amazon
10) Create STATIC IP Network Configuration:
# cd ~/seed
# vi network-config
# cloud-config
version: 2
ethernets:
eth0:
addresses:
- 192.168.1.199/24
gateway4: 192.168.1.1
nameservers:
addresses:
- 8.8.8.8
- 8.8.4.4
11) Install Generation ISO Image:
# apt install genisoimage
12) Create seed.iso image.
# cd ~/seed
# genisoimage -output seed.iso -volid cidata -joliet -rock user-data meta-data network-config
# ls -ltr seed.iso
-rw-r--r-- 1 root root 376832 Oct 18 13:36 seed.iso
14) In Windows take a copy of the Amazon Linux 2023 vhdx file into a new folder (i.e. C:\AmazonLinux2023)
15) Take a copy of the gerenate seed.iso into C:\AmazonLinux2023
Example (WSL Ubuntu):
# cd ~/seed
# cp seed.iso /mnt/c/AmazonLinux2023/
16) In Windows open Hyper-V Manager.
17) In left hand window, under Hyper-V Manager, click your PC Name and list of available virtual machines will be listed (if any).
18) In right hand action window, click Virtual Switch Manager.
19) Click External and Create Virtual Switch, enter the following details.
Name: VMNetwork
External network: <Select you active network device, i.e. wifi card)
Click <OK>.
Accept any warning prompts.
20) In right hand action window, click new --> Virtual Machine.
Click next on "Before you begin" if displayed.
Change name to al2023
Click store the virtual maching in different location if needed, and select alternative location.
Click Next.
Click Generation 1.
Click Next.
Click Generation 1.
Change Memory if requried,
Unselect Dynamic Memory if required (less notification messages later).
Click Next.
Change connection to VMNetwork
Click Next.
Click use an existing virtual hard disk and select the copy of vhdx file from STEP 14.
Click Finish.
21) New virtual machine will now be listed, right click it and select Settings..
Select IDE Controller 1 --> DVD Drive
Change to image file and select copy of seed.iso from STEP 15
Click <OK>
22) On virtual machine al2023, double click and it will start in a seperate window...
23) If ALL goes well after a while you should be prompted with a logon...
al2024 Login:
24) Enter credentials:
User: user1
Pass: amazon
25) If all good and logged on check network by performing "sudo yum update" and "sudo yum upgrade".
NOTE: If you need to repeat the install for any reason (i.e updates to the seed.iso) remember to re-copy your original Amazon Linux 2013 Virtual Hard Disk Image as this caused me several hours figuring why I had an issue :-) (STEP 14 onwards).
Move and Expand Virtual Hard Disk
01) Turn off Amazon Linux 2023 VM if running.
On virtual machine al2023,right click it and select Shutdown...
02) Create directory "Virtual Hard Disks" in C:\VirtualMachines\al2023\
03) Copy exiting Virtual Hard Disk image, from original location (i.e. C:\AmazonLinux2023) to C:\VirtualMachines\al2023\Virtual Hard Disks\
04) Highlight Virtual Machine (i.e. al2034) and Remove any checkpoints of reported.
Select Checkpoint, right click and select Delete Checkpoint...
Confirm notification
05) Edit Virtual Machine Hard Controller.
On virtual machine al2023,right click it and select Settings.
Select IDE Controller 0 --> Hard Drive
06) Browse and replace existing vhdx file with new location (STEP03).
07) Expand Virtual Hard Disk Image
Click <Edit>
Click <Next> to confirm vhdx file location.
Click <Expand> and <Next> to increase Hard Drive Image from 25Gb
Update New Size (i.e. 120Gb)
Click <Next> to confirm increase.
Check Summary and Click <Finish> to confirm changes.
08) Turn on AL2023 Virtual Machine and check new size now reported for /dev/sda1 filesystem.
[user1@al2023 ~]$ sudo su -
[root@al2023 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 120G 0 disk
├─sda1 8:1 0 120G 0 part /
├─sda127 259:0 0 1M 0 part
└─sda128 259:1 0 10M 0 part /boot/efi
sr0 11:0 1 368K 0 rom
[root@al2023 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 4.0M 0 4.0M 0% /dev
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 1.6G 8.6M 1.6G 1% /run
/dev/sda1 120G 2.4G 118G 2% /
tmpfs 3.9G 0 3.9G 0% /tmp
/dev/sda128 10M 1.3M 8.7M 13% /boot/efi
tmpfs 794M 0 794M 0% /run/user/1000