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 +++++- others/vm3/default.xml | 13 +++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 others/vm3/default.xml (limited to 'others/vm3') 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 diff --git a/others/vm3/default.xml b/others/vm3/default.xml new file mode 100644 index 0000000..bf71f7c --- /dev/null +++ b/others/vm3/default.xml @@ -0,0 +1,13 @@ + + default + 3d6341fb-fad2-49c1-b54a-41d2027f56cc + + + + + + + + + -- cgit v1.2.3-70-g09d2