무인설치(autounattend.xml)에서 자동으로 디스크를 초기화하고 파티션을 생성하는

방법입니다.

 

무조건 완전자동 무인설치 ISO 이미지를 열어보면

autounattend.xml 파일과 uncon-dp.exe 파일이 들어있습니다.

 

 

 

 

uncon-dp.exe 파일이 자동으로 첫번째 디스크를 MBR 디스크로 초기화하고,

디스크 전체를 주파티션으로 만들고 활성화(active)해주는 작업을 수행합니다.

 

uncon-dp.exe 파일은 autounattend.xml 파일에서 아래처럼 실행시킵니다. 

 

<settings pass="windowsPE">
    <component name="Microsoft-Windows-International-Core-WinPE" processorArchitecture="x86" 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>ko-KR</UILanguage>
        </SetupUILanguage>
        <InputLocale>ko-KR</InputLocale>
        <SystemLocale>ko-KR</SystemLocale>
        <UILanguage>ko-KR</UILanguage>
        <UserLocale>ko-KR</UserLocale>
    </component>
    <component name="Microsoft-Windows-Setup" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <RunSynchronous>
            <RunSynchronousCommand wcm:action="add">
                <Order>1</Order>
                <Description>Run Uncon-dp</Description>
                <Path>cmd /q /c "FOR %i IN (C D E F G H I J K L N M O P Q R S T U V W X Y Z) DO IF EXIST %i:\uncon-dp.exe cmd /c %i:\uncon-dp.exe"</Path>
            </RunSynchronousCommand>
        </RunSynchronous>
        <Display>
            <ColorDepth>32</ColorDepth>
            <HorizontalResolution>1024</HorizontalResolution>
            <VerticalResolution>768</VerticalResolution>
        </Display>
        <ImageInstall>
            <OSImage>
                <InstallFrom>
                    <MetaData wcm:action="add">
                        <Key>/IMAGE/INDEX</Key>
                        <Value>1</Value>
                    </MetaData>
                </InstallFrom>
                <InstallTo>
                    <DiskID>0</DiskID>
                    <PartitionID>1</PartitionID>
                </InstallTo>
                <WillShowUI>OnError</WillShowUI>
                <InstallToAvailablePartition>false</InstallToAvailablePartition>
            </OSImage>
        </ImageInstall>
        <UserData>
            <AcceptEula>true</AcceptEula>
            <FullName>SwanPark</FullName>
            <Organization>idoforu.tistory.com</Organization>
        </UserData>
    </component>
</settings>

 

 

uocon-dp.exe 파일은 autoit으로 만들었는데 소스 코드는 다음과 같습니다.

 

#NoTrayIcon
Global Const $myPath = "x:\sources"
Global Const $dpScript = $myPath & "\dpswan.txt"
Global $instOk, $hTextFile

If Not FileExists($myPath) Then Exit

MsgBox(0, "확 인", "첫번째 디스크를 초기화하고" & @CRLF & "윈도우 설치용 파티션을 만듭니다.",3)

$hTextFile = FileOpen($dpScript, 1)
If $hTextFile = -1 Then
  MsgBox(0, "확 인", "스크립트 파일 생성 오류")
  Exit
EndIf
FileWriteLine($hTextFile, "select disk 0")
FileWriteLine($hTextFile, "clean")
FileWriteLine($hTextFile, "convert mbr noerr")
FileWriteLine($hTextFile, "create partition primary")
FileWriteLine($hTextFile, "format quick fs=ntfs")
FileWriteLine($hTextFile, "assign letter=C noerr")
FileWriteLine($hTextFile, "active")
FileClose($hTextFile)

Sleep(2000)

If Not FileExists($dpScript) Then
 MsgBox(0, "확 인", "스크립트 파일을 찾을 수 없습니다.")
 Exit
EndIf

RunWait(@ComSpec & " /c " & "diskpart /s " & $dpScript)

Sleep(2000)

FileDelete($dpScript)

MsgBox(0, "확 인", "윈도우 설치용 파티션 생성 작업 완료!", 3)

Exit

 

 

위의 autoit 소스 코드를 배치 파일(CMD)로 바꾸면 이렇게 됩니다.

 

if not exist x:\sources exit
>> dpswan.txt echo select disk 0
>> dpswan.txt echo clean
>> dpswan.txt echo convert mbr noerr
>> dpswan.txt echo create partition primary
>> dpswan.txt echo format quick fs=ntfs
>> dpswan.txt echo assign letter=C noerr
>> dpswan.txt echo active
diskpart /s dpswan.txt
del dpswan.txt
exit 

 

이 배치 파일을 uncon-dp.cmd로 저장했다면

autounattend.xml 파일에서 uncon-dp.exe를 uncon-dp.cmd로 바꿔주시고

uncon-dp.cmd 파일을 autounattend.xml 파일과 함께 ISO 파일 루트에 넣어주면 됩니다.

 

Posted by 백조자리
,