diff --git a/trans.sh b/trans.sh index 5c45fd7..d6b53e7 100644 --- a/trans.sh +++ b/trans.sh @@ -1704,6 +1704,16 @@ install_windows() { locale=$(wiminfo $install_wim | grep 'Default Language' | head -1 | awk '{print $NF}') sed -i "s|%arch%|$arch|; s|%image_name%|$image_name|; s|%locale%|$locale|" /tmp/Autounattend.xml + # sda 只读,放的是 cloud-init 配置,通常 win 有驱动,能识别 + # 而 vda/nvme/xen 加载驱动后才能识别,所以这时 disk_id 应该为 1 + if [ -e "/sys/class/block/sda/ro" ] && + [ "$(cat /sys/class/block/sda/ro)" = 0 ]; then + disk_id=1 + else + disk_id=0 + fi + sed -i "s|%disk_id%|$disk_id|" /tmp/Autounattend.xml + # 修改应答文件,分区配置 if is_efi; then sed -i "s|%installto_partitionid%|3|" /tmp/Autounattend.xml diff --git a/windows.xml b/windows.xml index aab6f7b..120e538 100644 --- a/windows.xml +++ b/windows.xml @@ -12,7 +12,7 @@ OnError - 0 + %disk_id% false @@ -31,7 +31,7 @@ OnError - 0 + %disk_id% %installto_partitionid%