2018年10月7日

P6 如何用 Windows系統映像管理員(Windows System Image Manager) 製作Windows 10自動安裝回應檔案
PART VI 使用DiskPart建立磁碟分割


PART I 準備工作
PART II 瞭解Windows 10安裝過程
PART III 製作自動安裝回應檔案
PART IV 如何使用
PART V 關閉[SMB 1.0/CIFS 檔案共用支援]功能
PART VI 使用DiskPart建立磁碟分割
PART VII 不要預留[保留的儲存空間]
PART VIII 指定電腦名稱與加入網域
PART IX 彈性搭配批次檔使用
PART Max 懶人包

利用DiskPart建立磁碟分割後再安裝Windows會比直接寫在autounattend.xml內來得有彈性. (像是把Recovery tools分割擺在最後面)

以UEFI為例, DiskPart可以透過內含命令的文字檔來建立所需要的磁碟分割.
原理可參考: UEFI/GPT-based hard drive partitions

DiskParts.txt (注意: 會先清掉硬碟原先的分割和資料)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
select disk 0
clean
convert gpt
create partition efi size=100
format quick fs=fat32 label="System"
assign letter="S"
create partition msr size=16
create partition primary 
shrink minimum=500
format quick fs=ntfs label="Windows"
assign letter="W"
create partition primary
format quick fs=ntfs label="Recovery tools"
assign letter="R"
set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac"
gpt attributes=0x8000000000000001
list volume
exit


windowsPE階段的內容修改如下:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<!-- By Proliantaholic https://proliantaholic.blogspot.com -->
    <settings pass="windowsPE">
        <component name="Microsoft-Windows-International-Core-WinPE" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <SetupUILanguage>
                <UILanguage>zh-TW</UILanguage>
            </SetupUILanguage>
            <InputLocale>zh-TW</InputLocale>
            <SystemLocale>zh-TW</SystemLocale>
            <UILanguage>zh-TW</UILanguage>
        </component>
        <component name="Microsoft-Windows-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <UserData>
                <ProductKey>
                    <Key>W269N-WFGWX-YVC9B-4J6C9-T83GX</Key>
                    <WillShowUI>OnError</WillShowUI>
                </ProductKey>
                <AcceptEula>true</AcceptEula>
            </UserData>
            <RunSynchronous>
                <RunSynchronousCommand wcm:action="add">
                    <Order>1</Order>
                    <Path>cmd /c DiskPart /s A:\DiskParts.txt</Path>
                    <Description>Create partitions</Description>
                </RunSynchronousCommand>
            </RunSynchronous>
            <DiskConfiguration>
                <WillShowUI>OnError</WillShowUI>
            </DiskConfiguration>
            <ImageInstall>
                <OSImage>
                    <InstallFrom>
                        <MetaData wcm:action="add">
                            <Key>/IMAGE/DISPLAYNAME</Key>
                            <Value>Windows 10 Pro</Value>
                        </MetaData>
                    </InstallFrom>
                    <InstallToAvailablePartition>true</InstallToAvailablePartition>
                    <WillShowUI>OnError</WillShowUI>                    
                </OSImage>
            </ImageInstall>
        </component>
    </settings>


安裝過程會看到類似這樣:


2020.05.05 補充: 另一種寫法, 可以判斷是BIOS還是UEFI模式, 呼叫DiskPart分割磁碟.
使用方法請參考: PART Max 懶人包
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
@echo off
REM ###########################################################
REM #  By Proliantaholic https://proliantaholic.blogspot.com  #
REM ###########################################################

for /f "tokens=9 delims= " %%i in ('find /i "Detected boot environment" "%systemdrive%\windows\Panther\setupact.log"') do set FirmwareType=%%i
if "%FirmwareType%" == "BIOS" goto BIOS
if "%FirmwareType%" == "EFI" goto UEFI
Echo Detection error!
pause
goto end

:BIOS
(
Echo select disk 0
Echo clean
Echo.
Echo create partition primary size=50
Echo format quick fs=ntfs
Echo assign letter="S"
Echo active
Echo.
Echo create partition primary
Echo shrink minimum=550
Echo format quick fs=ntfs
Echo assign letter="W"
Echo.
Echo create partition primary
Echo format quick fs=ntfs
Echo assign letter="R"
Echo set id=27
Echo.
Echo list volume
Echo exit
) > %TEMP%\BIOSpart.txt
DiskPart /s %TEMP%\BIOSpart.txt
Echo.
Echo Detected Firmware Type: %FirmwareType%
Echo Partitions created use: BIOSpart.txt
Echo.
goto end

:UEFI
(
Echo select disk 0
Echo clean
Echo convert gpt
Echo.
Echo create partition efi size=100
Echo format quick fs=fat32
Echo assign letter="S"
Echo.
Echo create partition msr size=16
Echo.
Echo create partition primary 
Echo shrink minimum=550
Echo format quick fs=ntfs
Echo assign letter="W"
Echo.
Echo create partition primary
Echo format quick fs=ntfs
Echo assign letter="R"
Echo set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac"
Echo gpt attributes=0x8000000000000001
Echo.
Echo list volume
Echo exit
) > %TEMP%\UEFIpart.txt
DiskPart /s %TEMP%\UEFIpart.txt
Echo.
Echo Detected Firmware Type: %FirmwareType%
Echo Partitions created use: UEFIpart.txt
Echo.
goto end

:end



繼續閱讀:
PART VII 不要預留[保留的儲存空間]

3 則留言:

版權宣告

Creative Commons License
本著作由 PROLIANTAHOLIC 製作,以創用CC 姓名標示-非商業性-禁止改作 3.0 台灣 授權條款釋出。
文內所述之產品和公司名稱均為其各自擁有者的商標及(或)服務標記。