I am trying to create a KVM guest instance running Amazon Linux 2 in an on-premises environment, on a CentOS 7 host. I am doing this over SSH (e.g. my local machine -> SSH to the CentOS host).
I know my hypervisor setup works, as using the following commands, I can create a CentOS 7 guest with SSH access no problem at all:
OS_IMG=CentOS-7-x86_64-GenericCloud.qcow2
DIR=/home/libvirt
SCRIPTS=$DIR/scripts
BOOT=$DIR/boot
IMG=$DIR/images
VM=centos-vm-test
# +++ Downloading image OS image
cd $BOOT
wget http://cloud.centos.org/centos/7/images/$OS_IMG
# +++ Creating meta/user data
cd $IMG/$VM
echo -e "instance-id: $VM\nlocal-hostname: $VM" > meta-data
cp $SCRIPTS/user-data user-data
cp $BOOT/$OS_IMG $VM.qcow2
# +++ Creating disk
export LIBGUESTFS_BACKEND=direct
qemu-img create -f qcow2 -o preallocation=metadata $VM.new.image 40G
virt-resize --quiet --expand /dev/sda1 $VM.qcow2 $VM.new.image
mv $VM.new.image $VM.qcow2
# +++ Creating CD-ROM containing cloud init data
mkisofs -o $VM-cidata.iso -V cidata -J -r user-data meta-data
# +++ Creating VM"
virt-install --import --name $VM \
--memory 4096 --vcpus 2 --cpu host \
--disk $VM.qcow2,format=qcow2,bus=virtio \
--disk $VM-cidata.iso,device=cdrom \
--network bridge=virbr0,model=virtio \
--os-type=linux \
--os-variant=centos7.0 \
--noautoconsole
Within seconds, I can run virsh net-dhcp-leases
and see an IP address which I can SSH to.
I have tried to replicate this process with Amazon Linux 2, using the image found here: https://cdn.amazonlinux.com/os-images/2.0.20200304.0/kvm/
For user-data
, I have tried my CentOS file (quite lengthy, including a lot of runcmd
lines) and the recommended basic contents found here: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/amazon-linux-2-virtual-machine.html. I don't see any difference when using the 2 different files.
This doesn't appear to work however, and I'm stuck as to how I can proceed further.
- I am unable to run
virsh console myvmname
, as it just gets stuck onEscape character is ^]
(return key does nothing). On the CentOS guest, I can runvirsh console myvmname
and with a single hit of the return key, I'm connected as expected - If I run
virsh net-dhcp-leases default
, there are no leases - so I don't have an IP address that I can attempt SSH connection on - Logs in
/var/log/libvirt/qemu
show nothing wrong; the failed AL2 logs look identical to the working CentOS guests' logs.
I have also tried to copy the process exactly as recommended on the previous Amazon link, including using genisoimage
with the seed.iso
file etc. but this appears to make no difference.
How can I get access to this VM, or at least attempt to work out what's going wrong? Boot logs would be ideal.