From ff7f42e5b89d6c1cf664ae866f29f790132a7da7 Mon Sep 17 00:00:00 2001 From: hc Date: Thu, 2 Jan 2025 15:08:49 +0800 Subject: debianuuid --- others/vm3/compute/create.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'others/vm3/compute') 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 -- cgit v1.2.3-70-g09d2