windows: 支持安装 Vista / Server 2008
This commit is contained in:
parent
75301bd040
commit
9f5fcbd87a
40
trans.sh
40
trans.sh
@ -1973,9 +1973,9 @@ install_windows() {
|
|||||||
|
|
||||||
# https://github.com/virtio-win/virtio-win-pkg-scripts/issues/40
|
# https://github.com/virtio-win/virtio-win-pkg-scripts/issues/40
|
||||||
# https://github.com/virtio-win/virtio-win-pkg-scripts/issues/61
|
# https://github.com/virtio-win/virtio-win-pkg-scripts/issues/61
|
||||||
case "$sys" in
|
case "$nt_ver" in
|
||||||
vista | w7 | 2k8 | 2k8R2) dir=archive-virtio/virtio-win-0.1.173-9 ;;
|
6.0 | 6.1) dir=archive-virtio/virtio-win-0.1.173-9 ;; # vista | w7 | 2k8 | 2k8R2
|
||||||
w8 | w8.1 | 2k12 | 2k12R2) dir=archive-virtio/virtio-win-0.1.215-1 ;;
|
6.2 | 6.3) dir=archive-virtio/virtio-win-0.1.215-1 ;; # win8 | w8.1 | 2k12 | 2k12R2
|
||||||
*) dir=stable-virtio ;;
|
*) dir=stable-virtio ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
@ -2013,12 +2013,18 @@ install_windows() {
|
|||||||
sed -i "s|%installto_partitionid%|1|" /tmp/autounattend.xml
|
sed -i "s|%installto_partitionid%|1|" /tmp/autounattend.xml
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 评估版 iso 需要删除 autounattend.xml 里面的 <Key />
|
|
||||||
# 否则会出现 Windows Cannot find Microsoft software license terms
|
|
||||||
# shellcheck disable=SC2010
|
# shellcheck disable=SC2010
|
||||||
if ei_cfg="$(ls -d /os/installer/sources/* | grep -i ei.cfg)"; then
|
if ei_cfg="$(ls -d /os/installer/sources/* | grep -i ei.cfg)"; then
|
||||||
|
# 评估版 iso 需要删除 autounattend.xml 里面的 <Key><Key/>
|
||||||
|
# 否则会出现 Windows Cannot find Microsoft software license terms
|
||||||
if grep -i EVAL "$ei_cfg"; then
|
if grep -i EVAL "$ei_cfg"; then
|
||||||
sed -i '/<Key \/>/d' /tmp/autounattend.xml
|
sed -i "s|<Key></Key>||" /tmp/autounattend.xml
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# vista 需密钥,密钥与 edition 可以不一致
|
||||||
|
if [[ "$image_name" = 'Windows Vista'* ]]; then
|
||||||
|
vista_gvlk=VKK3X-68KWM-X2YGT-QR4M6-4BWMV
|
||||||
|
sed -i "s|<Key></Key>|<Key>$vista_gvlk</Key>|" /tmp/autounattend.xml
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -2028,28 +2034,32 @@ install_windows() {
|
|||||||
|
|
||||||
cp_drivers() {
|
cp_drivers() {
|
||||||
src=$1
|
src=$1
|
||||||
path=$2
|
shift
|
||||||
|
|
||||||
[ -n "$path" ] && filter="-ipath $path" || filter=""
|
|
||||||
find $src \
|
find $src \
|
||||||
$filter \
|
|
||||||
-type f \
|
-type f \
|
||||||
-not -iname "*.pdb" \
|
-not -iname "*.pdb" \
|
||||||
-not -iname "dpinst.exe" \
|
-not -iname "dpinst.exe" \
|
||||||
|
"$@" \
|
||||||
-exec cp -rfv {} /wim/drivers \;
|
-exec cp -rfv {} /wim/drivers \;
|
||||||
}
|
}
|
||||||
|
|
||||||
# 添加驱动
|
# 添加驱动
|
||||||
mkdir -p /wim/drivers
|
mkdir -p /wim/drivers
|
||||||
|
[ -d $drv/virtio ] && {
|
||||||
[ -d $drv/virtio ] && cp_drivers $drv/virtio "*/$sys/$arch/*"
|
if [ "$nt_ver" = 6.0 ]; then
|
||||||
|
# 气球驱动有问题
|
||||||
|
cp_drivers $drv/virtio -ipath "*/$sys/$arch/*" -not -ipath "*/balloon/*"
|
||||||
|
else
|
||||||
|
cp_drivers $drv/virtio -ipath "*/$sys/$arch/*"
|
||||||
|
fi
|
||||||
|
}
|
||||||
[ -d $drv/aws ] && cp_drivers $drv/aws
|
[ -d $drv/aws ] && cp_drivers $drv/aws
|
||||||
[ -d $drv/xen ] && cp_drivers $drv/xen "*/$arch_xen/*"
|
[ -d $drv/xen ] && cp_drivers $drv/xen -ipath "*/$arch_xen/*"
|
||||||
[ -d $drv/gce ] && {
|
[ -d $drv/gce ] && {
|
||||||
[ "$arch_wim" = x86 ] && gvnic_suffix=-32 || gvnic_suffix=
|
[ "$arch_wim" = x86 ] && gvnic_suffix=-32 || gvnic_suffix=
|
||||||
cp_drivers $drv/gce/gvnic "*/$sys_gce$gvnic_suffix/*"
|
cp_drivers $drv/gce/gvnic -ipath "*/$sys_gce$gvnic_suffix/*"
|
||||||
# gga 驱动不分32/64位
|
cp_drivers $drv/gce/gga -ipath "*/$sys_gce/*"
|
||||||
cp_drivers $drv/gce/gga "*/$sys_gce/*"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# win7 要添加 bootx64.efi 到 efi 目录
|
# win7 要添加 bootx64.efi 到 efi 目录
|
||||||
|
@ -20,12 +20,6 @@ for %%F in ("X:\drivers\*.inf") do (
|
|||||||
echo wscript.sleep(5000) > sleep.vbs
|
echo wscript.sleep(5000) > sleep.vbs
|
||||||
cscript //nologo sleep.vbs
|
cscript //nologo sleep.vbs
|
||||||
|
|
||||||
:: 获取主硬盘 id
|
|
||||||
:: 注意 vista pe 没有 wmic
|
|
||||||
for /F "tokens=2 delims==" %%A in ('wmic logicaldisk where "VolumeName='installer'" assoc:value /resultclass:Win32_DiskPartition ^| find "DiskIndex"') do (
|
|
||||||
set "DiskIndex=%%A"
|
|
||||||
)
|
|
||||||
|
|
||||||
:: 判断 efi 还是 bios
|
:: 判断 efi 还是 bios
|
||||||
echo list vol | diskpart | find "efi" && (
|
echo list vol | diskpart | find "efi" && (
|
||||||
set boot_type=efi
|
set boot_type=efi
|
||||||
@ -33,6 +27,25 @@ echo list vol | diskpart | find "efi" && (
|
|||||||
set boot_type=bios
|
set boot_type=bios
|
||||||
)
|
)
|
||||||
|
|
||||||
|
:: 获取 installer 卷 id
|
||||||
|
for /f "tokens=2" %%a in ('echo list vol ^| diskpart ^| find "installer"') do (
|
||||||
|
set "VolIndex=%%a"
|
||||||
|
)
|
||||||
|
|
||||||
|
:: 将 installer 分区设为 Y 盘
|
||||||
|
(echo select vol %VolIndex% & echo assign letter=Y) | diskpart
|
||||||
|
|
||||||
|
:: 设置虚拟内存,好像没必要,安装时会自动在 C 盘设置虚拟内存
|
||||||
|
rem wpeutil CreatePageFile /path=Y:\pagefile.sys
|
||||||
|
|
||||||
|
:: 获取主硬盘 id
|
||||||
|
:: vista pe 没有 wmic,因此用 diskpart
|
||||||
|
(echo select vol %VolIndex% & echo list disk) | diskpart | find "* " > X:\disk.txt
|
||||||
|
for /f "tokens=3" %%a in (X:\disk.txt) do (
|
||||||
|
set "DiskIndex=%%a"
|
||||||
|
)
|
||||||
|
del X:\disk.txt
|
||||||
|
|
||||||
:: 重新分区/格式化
|
:: 重新分区/格式化
|
||||||
(if "%boot_type%"=="efi" (
|
(if "%boot_type%"=="efi" (
|
||||||
echo select disk %DiskIndex%
|
echo select disk %DiskIndex%
|
||||||
@ -58,9 +71,13 @@ echo list vol | diskpart | find "efi" && (
|
|||||||
echo format fs=ntfs quick
|
echo format fs=ntfs quick
|
||||||
)) > X:\diskpart.txt
|
)) > X:\diskpart.txt
|
||||||
|
|
||||||
|
|
||||||
:: 使用 diskpart /s ,出错不会执行剩下的 diskpart 命令
|
:: 使用 diskpart /s ,出错不会执行剩下的 diskpart 命令
|
||||||
diskpart /s X:\diskpart.txt
|
diskpart /s X:\diskpart.txt
|
||||||
|
del X:\diskpart.txt
|
||||||
|
|
||||||
|
:: 盘符
|
||||||
|
rem X boot.wim (ram)
|
||||||
|
rem Y installer
|
||||||
|
|
||||||
:: 设置 autounattend.xml 的主硬盘 id
|
:: 设置 autounattend.xml 的主硬盘 id
|
||||||
set "file=X:\autounattend.xml"
|
set "file=X:\autounattend.xml"
|
||||||
@ -79,6 +96,9 @@ set "replace=%DiskIndex%"
|
|||||||
)) > %tempFile%
|
)) > %tempFile%
|
||||||
move /y %tempFile% %file%
|
move /y %tempFile% %file%
|
||||||
|
|
||||||
:: 执行 setup.exe
|
|
||||||
rename X:\setup.exe.disabled setup.exe
|
rename X:\setup.exe.disabled setup.exe
|
||||||
X:\setup.exe /emsport:COM1 /emsbaudrate:115200
|
|
||||||
|
:: 运行 X:\setup.exe 的话
|
||||||
|
:: vista 会找不到安装源
|
||||||
|
:: server 23h2 会无法运行
|
||||||
|
Y:\setup.exe /emsport:COM1 /emsbaudrate:115200
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<AcceptEula>true</AcceptEula>
|
<AcceptEula>true</AcceptEula>
|
||||||
<ProductKey>
|
<ProductKey>
|
||||||
<WillShowUI>OnError</WillShowUI>
|
<WillShowUI>OnError</WillShowUI>
|
||||||
<Key />
|
<Key></Key>
|
||||||
</ProductKey>
|
</ProductKey>
|
||||||
</UserData>
|
</UserData>
|
||||||
<DiskConfiguration>
|
<DiskConfiguration>
|
||||||
|
Loading…
Reference in New Issue
Block a user