diff options
Diffstat (limited to 'others/vm3/compute')
| -rwxr-xr-x | others/vm3/compute/create.sh | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/others/vm3/compute/create.sh b/others/vm3/compute/create.sh index 1a0411b..3588db4 100755 --- a/others/vm3/compute/create.sh +++ b/others/vm3/compute/create.sh @@ -91,10 +91,14 @@ fi # Define the disk options based on OS type if [ "$os" = "debian12" ]; then disk_opts="--disk path=${new_vm},format=qcow2" + virt-customize -a ${new_vm} --run-command "rm -f /etc/machine-id && systemd-machine-id-setup" else disk_opts="--disk path=${new_vm},format=qcow2 --disk path=$seed_iso,device=cdrom" fi +generate_mac() { + printf "52:54:00:%02x:%02x:%02x\n" $((RANDOM%256)) $((RANDOM%256)) $((RANDOM%256)) +} # Use the conditional disk options in virt-install sudo virt-install --name $vmname \ @@ -105,7 +109,7 @@ sudo virt-install --name $vmname \ --os-variant $os \ --virt-type kvm \ --graphics none \ - --network bridge=virbr0,model=virtio \ + --network bridge=virbr0,model=virtio,mac=$(generate_mac) \ --print-xml > $xml || { sudo rm -rf $new_vm; exit 1; } # if you want this in a new storage pool, move it to a new storage pool after initialisation |
