Jamyy's Weblog

在 Linux 製作 Windows 系統之 USB 安裝碟

by Jamyy on 八月.12, 2015, under Linux

需求:

  • Windows ISO 檔 (*註)
  • 4GB 以上 USB 隨身碟
  • Linux 工具程式: fdisk, mkfs.ntfs, lilo

*註: 需 Windows 7 (含) 以上, Windows 7、Windows Server 2012 均實作成功

將 USB 隨身碟格式化為 NTFS 格式

# fdisk /dev/sdc

t7a1w

(重點: 1. 設定分割區格式為 HPFS/NTFS/exFAT; 2. 賦予 bootable flag)

# fdisk -l /dev/sdc

Disk /dev/sdc: 4016 MB, 4016046080 bytes
56 heads, 15 sectors/track, 9337 cylinders, total 7843840 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0003a6b8

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1   *        2048     7843839     3920896    7  HPFS/NTFS/exFAT

# mkfs.ntfs -f /dev/sdc1

將 Boot Loader 寫入 MBR

# apt-get install lilo
# lilo -M /dev/sdc mbr

將 Windows 光碟資料寫入 USB 隨身碟

# mkdir ~/usb
# mount /dev/sdc1 ~/usb
# mkdir ~/loop
# mount -o loop /path/to/win7-x64.iso ~/loop
# cp -r ~/loop/* ~/usb/
# sync

測試開機

# qemu-system-x86_64 -enable-kvm -smp 2 -m 1024 -hda /dev/sdc

Ref: How to make Windows 7 USB flash install media from Linux? - Server Fault



:,