Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Host ONP on KVM #91

Open
kevydotvinu opened this issue Aug 21, 2023 · 0 comments
Open

Host ONP on KVM #91

kevydotvinu opened this issue Aug 21, 2023 · 0 comments

Comments

@kevydotvinu
Copy link
Owner

kevydotvinu commented Aug 21, 2023

$ cat macvtap.xml
<network>
  <name>macvtap-net</name>
  <forward mode="bridge">
    <interface dev="ens1f0"/>
  </forward>
</network>
$ cat vm.sh
VM_NAME=${1}
ISO=${2}
VCPU=20
MEMORY=81920
VM_DISK=${VM_NAME}.img,bus=scsi
# NETWORK=network=macvtap-net,model=virtio,mac=52:54:00:1e:4d:ae
NETWORK=network=macvtap-net,model=virtio
CDROM=${ISO}

virsh destroy ${VM_NAME}
virsh undefine ${VM_NAME}
sudo qemu-img create ${VM_NAME}.img 540G
virt-install --name $VM_NAME \
        --os-variant fedora-coreos-stable \
        --vcpus $VCPU \
        --memory $MEMORY \
        --disk $VM_DISK \
        --network $NETWORK \
        --pxe \
        --cdrom $CDROM \
        --boot hd,cdrom \
        --filesystem type=mount,mode=mapped,source=/mnt,target=/mnt \
        --graphics spice,listen=0.0.0.0 \
        --video virtio \
        --channel spicevmc \
        --console pty,target.type=virtio \
        --serial pty \
        --noautoconsole

function WAIT_FOR_REBOOT {
sp='/-\|'
sc=0

spin() {
   printf "\r[${sp:sc++:1}] $1"
   ((sc==${#sp})) && sc=0
}

endspin() {
   printf "\r%s\n" "$@"
}

until [[ $(sudo virsh -q list | grep -o ${VM_NAME} | wc -c) -eq 0 ]]
do spin "Waiting for the installation and restart ..."
sleep 0.5
done
endspin
}

function START_NODE {
        sudo virsh start ${VM_NAME} > /dev/null
        echo "[✔] Installation completed!"
}

WAIT_FOR_REBOOT
START_NODE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant