mirror of
https://github.com/bin456789/reinstall.git
synced 2025-01-19 04:49:13 +08:00
windows: 在 pe 下重设 efi 分区大小
This commit is contained in:
parent
976e152fdf
commit
61c78e6316
45
trans.sh
45
trans.sh
@ -2019,56 +2019,11 @@ install_windows() {
|
|||||||
locale=$(wiminfo $install_wim | grep 'Default Language' | head -1 | awk '{print $NF}')
|
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
|
sed -i "s|%arch%|$arch|; s|%image_name%|$image_name|; s|%locale%|$locale|" /tmp/autounattend.xml
|
||||||
|
|
||||||
# 修改 disk_id
|
|
||||||
if false; then
|
|
||||||
# sda 只读,放的是 cloud-init 配置,通常 win 有驱动,能识别
|
|
||||||
# 而 vda/nvme/xen 加载驱动后才能识别,所以这时 disk_id 应该为 1
|
|
||||||
if [ -e "/sys/class/block/sda/ro" ] &&
|
|
||||||
[ "$(cat /sys/class/block/sda/ro)" = 1 ]; then
|
|
||||||
disk_id=1
|
|
||||||
else
|
|
||||||
disk_id=0
|
|
||||||
fi
|
|
||||||
sed -i "s|%disk_id%|$disk_id|" /tmp/autounattend.xml
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 修改应答文件,分区配置
|
# 修改应答文件,分区配置
|
||||||
if is_efi; then
|
if is_efi; then
|
||||||
sed -i "s|%installto_partitionid%|3|" /tmp/autounattend.xml
|
sed -i "s|%installto_partitionid%|3|" /tmp/autounattend.xml
|
||||||
insert_into_file /tmp/autounattend.xml after '<ModifyPartitions>' <<EOF
|
|
||||||
<ModifyPartition wcm:action="add">
|
|
||||||
<Order>1</Order>
|
|
||||||
<PartitionID>1</PartitionID>
|
|
||||||
<Format>FAT32</Format>
|
|
||||||
</ModifyPartition>
|
|
||||||
<ModifyPartition wcm:action="add">
|
|
||||||
<Order>2</Order>
|
|
||||||
<PartitionID>2</PartitionID>
|
|
||||||
</ModifyPartition>
|
|
||||||
<ModifyPartition wcm:action="add">
|
|
||||||
<Order>3</Order>
|
|
||||||
<PartitionID>3</PartitionID>
|
|
||||||
<Format>NTFS</Format>
|
|
||||||
</ModifyPartition>
|
|
||||||
EOF
|
|
||||||
else
|
else
|
||||||
sed -i "s|%installto_partitionid%|1|" /tmp/autounattend.xml
|
sed -i "s|%installto_partitionid%|1|" /tmp/autounattend.xml
|
||||||
insert_into_file /tmp/autounattend.xml after '<ModifyPartitions>' <<EOF
|
|
||||||
<ModifyPartition wcm:action="add">
|
|
||||||
<Order>1</Order>
|
|
||||||
<PartitionID>1</PartitionID>
|
|
||||||
<Format>NTFS</Format>
|
|
||||||
</ModifyPartition>
|
|
||||||
EOF
|
|
||||||
fi
|
|
||||||
|
|
||||||
# ei.cfg
|
|
||||||
if false; then
|
|
||||||
cat <<EOF >/os/installer/sources/EI.CFG
|
|
||||||
[Channel]
|
|
||||||
_Default
|
|
||||||
EOF
|
|
||||||
unix2dos /os/installer/sources/EI.CFG
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 挂载 boot.wim
|
# 挂载 boot.wim
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
@echo off
|
@echo off
|
||||||
|
|
||||||
|
:: 使用高性能模式
|
||||||
|
:: https://learn.microsoft.com/windows-hardware/manufacture/desktop/capture-and-apply-windows-using-a-single-wim
|
||||||
|
:: win8 pe 没有 powercfg
|
||||||
|
call powercfg /s 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c 2>nul
|
||||||
|
|
||||||
:: 安装 SCSI 驱动
|
:: 安装 SCSI 驱动
|
||||||
for %%F in ("X:\drivers\*.inf") do (
|
for %%F in ("X:\drivers\*.inf") do (
|
||||||
:: 不要查找 Class=SCSIAdapter 因为有些驱动等号两边有空格
|
:: 不要查找 Class=SCSIAdapter 因为有些驱动等号两边有空格
|
||||||
@ -16,10 +21,47 @@ echo wscript.sleep(5000) > sleep.vbs
|
|||||||
cscript //nologo sleep.vbs
|
cscript //nologo sleep.vbs
|
||||||
|
|
||||||
:: 获取主硬盘 id
|
:: 获取主硬盘 id
|
||||||
|
:: 注意 vista pe 没有 wmic
|
||||||
for /F "tokens=2 delims==" %%A in ('wmic logicaldisk where "VolumeName='installer'" assoc:value /resultclass:Win32_DiskPartition ^| find "DiskIndex"') do (
|
for /F "tokens=2 delims==" %%A in ('wmic logicaldisk where "VolumeName='installer'" assoc:value /resultclass:Win32_DiskPartition ^| find "DiskIndex"') do (
|
||||||
set "DiskIndex=%%A"
|
set "DiskIndex=%%A"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
:: 判断 efi 还是 bios
|
||||||
|
echo list vol | diskpart | find "efi" && (
|
||||||
|
set boot_type=efi
|
||||||
|
) || (
|
||||||
|
set boot_type=bios
|
||||||
|
)
|
||||||
|
|
||||||
|
:: 重新分区/格式化
|
||||||
|
(if "%boot_type%"=="efi" (
|
||||||
|
echo select disk %DiskIndex%
|
||||||
|
|
||||||
|
echo select part 1
|
||||||
|
echo delete part override
|
||||||
|
echo select part 2
|
||||||
|
echo delete part override
|
||||||
|
echo select part 3
|
||||||
|
echo delete part override
|
||||||
|
|
||||||
|
echo create part efi size=100
|
||||||
|
echo format fs=fat32 quick
|
||||||
|
|
||||||
|
echo create part msr size=16
|
||||||
|
|
||||||
|
echo create part primary
|
||||||
|
echo format fs=ntfs quick
|
||||||
|
) else (
|
||||||
|
echo select disk %DiskIndex%
|
||||||
|
|
||||||
|
echo select part 1
|
||||||
|
echo format fs=ntfs quick
|
||||||
|
)) > X:\diskpart.txt
|
||||||
|
|
||||||
|
|
||||||
|
:: 使用 diskpart /s ,出错不会执行剩下的 diskpart 命令
|
||||||
|
diskpart /s X:\diskpart.txt
|
||||||
|
|
||||||
:: 设置 autounattend.xml 的主硬盘 id
|
:: 设置 autounattend.xml 的主硬盘 id
|
||||||
set "file=X:\autounattend.xml"
|
set "file=X:\autounattend.xml"
|
||||||
set "tempFile=X:\tmp.xml"
|
set "tempFile=X:\tmp.xml"
|
||||||
@ -38,5 +80,5 @@ set "replace=%DiskIndex%"
|
|||||||
move /y %tempFile% %file%
|
move /y %tempFile% %file%
|
||||||
|
|
||||||
:: 执行 setup.exe
|
:: 执行 setup.exe
|
||||||
ren X:\setup.exe.disabled setup.exe
|
rename X:\setup.exe.disabled setup.exe
|
||||||
X:\setup.exe
|
X:\setup.exe /emsport:COM1 /emsbaudrate:115200
|
||||||
|
Loading…
x
Reference in New Issue
Block a user