«   2024/05   »
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
Archives
Today
Total
관리 메뉴

정보보관소

Linux 에서 Windows PE 부팅 이미지 생성하기 본문

소프트웨어

Linux 에서 Windows PE 부팅 이미지 생성하기

노을러브 2020. 3. 30. 13:39

사전 준비사항

 

- windows 10 설치 ISO 파일

- wimtools 패키지

- chntpw 패키지

- genisoimage 패키지

- qemu 패키지

 

Windows 설치 ISO 에는 이미 Windows PE 파일이 존재합니다.

 

Windows ISO 이미지 내부에 /sources/boot.wim 파일이 바로 Windows PE 파일입니다.

 

Windows 설치 ISO 를 마운트 합니다.

 

$ sudo mount windows10.iso /mnt

 

이미지 내부 디렉토리 구조는 아래와 같습니다.

 

├── boot

│   ├── fonts

│   ├── ko-kr

│   └── resources

├── efi

│   ├── boot

│   └── microsoft

│   └── boot

│   ├── fonts

│   └── resources

├── sources

└── support

 

Windows PE 부팅 이미지 생성을 위해서는 boot, efi 디렉토리 전체와 sources 디렉토리 내부 boot.wim 파일만 있으면 됩니다.

 

$ mkdir winpe

$ cd winpe

$ cp -R /mnt/boot boot

$ cp -R /mnt/efi efi

$ mkdir sources

$ cp /mnt/sources/boot.wim sources/boot.wim

 

이제 Windows PE 부팅 이미지 생성을 위한 기본 작업은 끝난 상태입니다.

 

winpe 디렉토리 내부를 그대로 부팅이미지로 생성하게 되면 부팅시 에러가 발생합니다.

 

부팅시 디렉토리 구조가 달라서 발생하는 에러입니다.

 

이 에러를 수정하기 위해서는 boot.wim 파일내부를 수정할 필요가 있습니다.

 

우선 boot.wim 파일을 풀어봅시다.

 

$ cd ..

$ wimextract winpe/sources/boot.wim 1 boot

 

wim 파일의 경우 다수의 패키지를 포함하고 있는 구조입니다.

 

$ wiminfo boot.wim

 

WIM Information:

----------------

Path: boot.wim

GUID: 0x5f159a9720f9171b22b7a88a70b4ec3f

Version: 68864

Image Count: 1

Compression: LZX

Chunk Size: 32768 bytes

Part Number: 1/1

Boot Index: 1

Size: 389592003 bytes

Attributes: Relative path junction

 

Available Images:

-----------------

Index: 1

Name: win10

Description:

Display Name: Windows (TM) 10 Preinstallation Environment

Display Description: Windows (TM) 10 Preinstallation Environment

Directory Count: 4098

File Count: 17128

Total Bytes: 1809349821

Hard Link Bytes: 825394397

Creation Time: Mon Mar 30 03:40:40 2020 UTC

Last Modification Time: Mon Mar 30 03:40:40 2020 UTC

Architecture: x86_64

Product Name: Windows (TM) 10 Preinstallation Environment

Edition ID: WindowsPE

Installation Type: WindowsPE

Product Type: WinNT

Languages: ko-KR

Default Language: ko-KR

System Root: WINDOWS

Major Version: 10

Minor Version: 0

Build: 18362

Service Pack Build: 592

Service Pack Level: 0

Flags: WindowsPE

WIMBoot compatible: no

 

boot.wim 파일의 경우 1개의 패키지가 포함되어 있으면 index 번호가 1입니다.

 

Windows 10 설치 ISO 내부 boot.wim 이 있는 위치에 install.esd 라는 파일이 있는데 이 파일의 경우 마이크로소프트에서 내려받은 ISO 파일 기준으로 3개의 패키지가 포함되어 있습니다.

 

Home, Education, Pro 3가지의 버전이 하나의 파일로 존재하는 형태입니다.

 

개별 설치 패키지를 풀어내려고 하면 해당 패키지의 index 번호를 입력하면 됩니다.

 

이제 boot.wim 파일을 풀었으니 발생하는 에러를 수정해보도록 하겠습니다.

 

위에서 언급한 에러의 경우 수정해야 할 대상이 윈도우 Registry 파일입니다.

 

윈도우 Registry 파일을 수정하기 위해서 필요한 패키지가 chntpw 입니다.

위 에러가 발생하는 곳은 Windows/System32/config/SOFTWARE 파일입니다.

 

$ chntpw -e boot/Windows/System32/config/SOFTWARE

Hive <win10/Windows/System32/config/SOFTWARE> name (from header): <indows\system32\config\SOFTWARE>

ROOT KEY at offset: 0x001020 * Subkey indexing type is: 686c <lh>

File size 9437184 [900000] bytes, containing 2117 pages (+ 1 headerpage)

Used for data: 156249/8519184 blocks/bytes, unused: 1857/825680 blocks/bytes.

 

Simple registry editor. ? for help.

 

> cd Microsoft\Windows NT\CurrentVersion\WinPE

 

\Microsoft\Windows NT\CurrentVersion\WinPE> cat InstRoot

Value <InstRoot> of type REG_SZ (1), data length 8 [0x8]

X:\$windows.~bt\

 

 

\Microsoft\Windows NT\CurrentVersion\WinPE> ed InstRoot

EDIT: <InstRoot> of type REG_SZ (1) with length 8 [0x8]

[ 0]: X:\$windows.~bt\

 

Now enter new strings, one by one.

Enter nothing to keep old.

[ 0]: X:\$windows.~bt\

-> X:\

 

\Microsoft\Windows NT\CurrentVersion\WinPE> q

 

Hives that have changed:

# Name

0 <win10/Windows/System32/config/SOFTWARE>

Write hive files? (y/n) [n] : y

 

이제 위 에러 발생 원인을 수정하였으니 이대로 부팅 이미지를 생성해보도록 하겠습니다.

 

$ wimcaptrue boot winpe/sources/boot.wim –boot

$ sudo mkisofs -U -A "Win10PE" -V "Win10PE" -volset "Win10PE" -udf -b boot/etfsboot.com -no-emul-boot -boot-load-size 8 -eltorito-alt-boot -e efi/microsoft/boot/efisys.bin -no-emul-boot -o winpe.iso winpe

 

이제 Windows 10 PE 부팅 이미지가 winpe.iso 파일로 생성되었습니다.

 

생성된 이미지가 제대로 동작하는지 qemu 로 테스트 해봅니다.

 

$ sudo qemu-system-x86_64 -enable-kvm -boot d -cdrom winpe.iso

 

부팅이 되면서 윈도우 cmd 창이 뜨면 제대로 동작이 되는 겁니다.

 

이제부터는 Windows PE 용도에 맞게끔 필요한 프로그램들을 해당 boot.wim 내부에 넣어주고 수정해주고 다시 부팅 이미지를 생성해 주기만 하면 됩니다.

 

PS. 부팅에 사용되는 BCD 파일이 Registry 와 같은 HIVE 포맷을 사용한다.

'소프트웨어' 카테고리의 다른 글

Zorin OS  (0) 2020.03.13
Chrome OS  (1) 2020.02.29
Markdown Preview Enhanced - Visual Studio Code Extension  (0) 2020.01.08
Power Mockup - best wireframe tool  (0) 2019.12.18