Last active
April 3, 2023 05:32
-
-
Save jianzzha/7fa7992d30dbfc9cdb6fec30e6cf2286 to your computer and use it in GitHub Desktop.
How to boot the AI discovery with VM console access
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/bash | |
# important: download the minimum iso image, not the full image iso | |
export MEMORY=16384 | |
export VCPUS=4 | |
export MASTER_MAC_BASE=52:54:00:f9:8e:2 | |
export WORKER_MAC=52:54:00:f9:8e:30 | |
export CDROM=/var/www/html/discovery_image_test.iso | |
export QCOWS=/var/lib/libvirt/images | |
mkdir -p /mnt/ai | |
umount /mnt/ai | |
mount -o loop,ro ${CDROM} /mnt/ai | |
kernel=/mnt/ai/images/pxeboot/vmlinuz | |
cat /mnt/ai/images/pxeboot/initrd.img /mnt/ai/images/ignition.img /mnt/ai/images/assisted_installer_custom.img > superinitrd.img | |
initrd=$PWD/superinitrd.img | |
kernel_args='console=tty0 console=ttyS0 '$(sed -r -n -e "s/.*(random.trust_cpu.*)/\1/p" /mnt/ai/EFI/redhat/grub.cfg) | |
# Create VM | |
for i in `seq 0 2`; do | |
virt-install \ | |
--autostart \ | |
--virt-type=kvm \ | |
--name ocp4-upi-master${i} \ | |
--memory $MEMORY \ | |
--vcpus=$VCPUS \ | |
--os-variant=rhel8.4 \ | |
--install kernel=${kernel},initrd="${initrd}",kernel_args="${kernel_args}",kernel_args_overwrite=yes \ | |
--network=bridge:baremetal,mac="${MASTER_MAC_BASE}$i" \ | |
--disk path=$QCOWS/ocp4-upi-master${i}.qcow2,size=120,bus=scsi,sparse=yes \ | |
--check disk_size=off \ | |
--wait=-1 \ | |
--noautoconsole \ | |
--events on_reboot=restart \ | |
--quiet & | |
done | |
virt-install \ | |
--autostart \ | |
--virt-type=kvm \ | |
--name ocp4-upi-worker0 \ | |
--memory $MEMORY \ | |
--vcpus=$VCPUS \ | |
--os-variant=rhel8.4 \ | |
--install kernel=${kernel},initrd="${initrd}",kernel_args="${kernel_args}",kernel_args_overwrite=yes \ | |
--network=bridge:baremetal,mac="${WORKER_MAC}" \ | |
--disk path=$QCOWS/ocp4-upi-worker${i}.qcow2,size=120,bus=scsi,sparse=yes \ | |
--check disk_size=off \ | |
--wait=-1 \ | |
--noautoconsole \ | |
--events on_reboot=restart \ | |
--quiet & |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment