From 270c128ca69cc8ad80bcda5ecd451b16573dcff3 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Sat, 28 Oct 2023 22:24:05 +0800 Subject: [PATCH] =?UTF-8?q?windows:=20=E5=AD=98=E5=9C=A8=E5=8F=AA=E8=AF=BB?= =?UTF-8?q?=20sda=20=E6=97=B6=E5=BA=94=E8=AF=A5=E5=AE=89=E8=A3=85=E5=88=B0?= =?UTF-8?q?=E7=AC=AC2=E4=B8=AA=E7=A1=AC=E7=9B=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- trans.sh | 10 ++++++++++ windows.xml | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) 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%