工作中有时需要配置Windows的开发/测试环境,那么如何用Linux制作Win10启动盘呢?
可以使用WoeUSB工具,这款工具是纯python开发的,可以安装在python虚拟环境里。制作U盘的过程可以是图形化也可以是命令行。
所以非常方便
这里我们需要用到的是一个叫WoeUSB的软件,有两种方式安装:
复制代码
#pre-install
sudo apt-get install git p7zip-full python3-pip python3-wxgtk4.0
# install by pip3
sudo pip3 install WoeUSB-ng -i https://pypi.mirrors.ustc.edu.cn/simple/
# install by source code
git clone https://github.com/WoeUSB/WoeUSB-ng.git
cd WoeUSB-ng
sudo pip3 install .
复制代码
安装完成之后,可以选择UI方式安装,也可以选择command line的方式。
By UI
在Ubuntu的桌面上找到WoeUSB的图标
后面的就比较傻瓜了,插好U盘,在UI里选择Windows的ISO文件,选择NTFS模式,选择好目标设备(也就是你插入的U盘),点击Install就可以了。
# By Command line
woeusb --device <Your_Win10_iso_path> <Your_USB_Strorage_Path_Default_/dev/sdb> --target-filesystem NTFS
比如我想在Debian系统(Linux系统的一种)中制作windows server 2019的启动盘,使用如下命令
woeusb --device /resources/ISO/cn_windows_server_2019_x64_dvd_4de40f33.iso /dev/sdb --target-filesystem NTFS
记录一下我的命令行返回:
root@server001:~/WoeUSB-ng# woeusb --device /resources/ISO/cn_windows_server_2019_x64_dvd_4de40f33.iso /dev/sdb --target-filesystem NTFS
WoeUSB v0.2.10
==============================
Mounting source filesystem...
Wiping all existing partition table and filesystem signatures in /dev/sdb
/dev/sdb: 2 bytes were erased at offset 0x000001fe (dos): 55 aa
/dev/sdb: calling ioctl to re-read partition table: 成功
Ensure that /dev/sdb is really wiped...
Creating new partition table on /dev/sdb...
Creating target partition...
Making system realize that partition table has changed...
Wait 3 seconds for block device nodes to populate...
Cluster size has been automatically set to 4096 bytes.
Creating NTFS volume structures.
mkntfs completed successfully. Have a nice day.
Mounting target filesystem...
Copying files from source media...
/bootmgr
/boot/boot.sdi
/boot/fonts/chs_boot.ttf
/boot/fonts/cht_boot.ttf
/boot/fonts/kor_boot.ttf
/boot/resources/bootres.dll
/efi/microsoft/boot/cdboot_noprompt.efi
/efi/microsoft/boot/memtest.efi
/efi/microsoft/boot/fonts/chs_boot.ttf
/efi/microsoft/boot/fonts/cht_boot.ttf
/efi/microsoft/boot/fonts/kor_boot.ttf
/sources/acmigration.dll
/sources/appraiser.dll
/sources/background_svr.bmp
/sources/boot.wim
/sources/diagtrack.dll
/sources/gatherosstate.exe
/sources/install.wim
/sources/mediasetupuimgr.dll
/sources/migapp.xml
/sources/migcore.dll
/sources/migstore.dll
/sources/reagent.dll
/sources/setuphost.exe
/sources/setupplatform.dll
/sources/setupprep.exe
/sources/sflistrs1.dat
/sources/sflistw7.dat
/sources/sflistwb.dat
/sources/sflistwt.dat
/sources/sflistwt.woa.dat
/sources/spwizimg.dll
/sources/upgradeagent.dll
/sources/w32uires.dll
/sources/windlp.dll
/sources/wpx.dll
/sources/dlmanifests/printing-spooler-core-dl.man
/sources/dlmanifests/microsoft-windows-iis-dl/iismig.dll
/sources/migration/wtr/powershell_en-us_noloc.inf
/sources/replacementmanifests/onecore_speechcommon-rep.man
/sources/replacementmanifests/microsoft-windows-appmanagement-migration/appmanmigrationplugin.dll
/sources/replacementmanifests/microsoft-windows-textservicesframework-migration/imjpmig.dll
/sources/sxs/microsoft-windows-netfx3-ondemand-package~31bf3856ad364e35~amd64~~.cab
/sources/zh-cn/setup_help_upgrade_or_custom.rtf
/support/adprep/dca8f425-baae-47cd-b424-e3f6c76ed08b.dcpromo.csv
Copied 4.7GiB from a total of 4.7GiB
/support/samples/headlessunattend.xml
Copied 4.7GiB from a total of 4.7GiBased with EFI support, applying workaround to make it support UEFI booting
100%
INFO: Detected existing EFI bootloader, workaround skipped.
Installing GRUB bootloader for legacy PC booting support...
正在为 i386-pc 平台进行安装。
安装完成。没有报告错误。
Installing custom GRUB config for legacy PC booting...
Unmounting and removing /media/woeusb_source_1662701347_3445...
Unmounting and removing /media/woeusb_target_1662701347_3445...
You may now safely detach the target device
Done :)
The target device should be bootable now
root@server001:~/WoeUSB-ng#
如果报错:Target device is currently busy, unmount all mounted partitions in target device then try again.
则需要unmount掉U盘已经挂载的分区,比如
umount /dev/sdb1
如果出现Remote end closed connection without response
说明USB接口不稳定,U盘与电脑连接断了,重新制作一下。