13 Commits
Author SHA1 Message Date
ValdikSS 9f855faabd Merge branch 'master' of https://github.com/recolic/windows2usb 2022-01-09 18:11:44 +03:00
ValdikSS 905f95ae7b Final fix for wim file size detection 2022-01-09 18:11:34 +03:00
Recolic K 2af0bed0df Document improvement: add feature matrix #23
Squashed commit of the following:

commit c279195a08
Author: Recolic K <bensl@microsoft.com>
Date:   Thu Nov 25 17:50:06 2021 +0800

    doc improvement: add feature matrix

commit 7b0f5d9912
Author: Recolic K <bensl@microsoft.com>
Date:   Thu Nov 25 17:43:26 2021 +0800

    doc improvement: add feature matrix

commit 60d1f7d758
Author: Recolic K <bensl@microsoft.com>
Date:   Thu Nov 25 17:41:52 2021 +0800

    doc improvement: add feature matrix

commit f8d27f725d
Author: Recolic K <bensl@microsoft.com>
Date:   Thu Nov 25 17:39:57 2021 +0800

    doc improvement: add feature matrix

Signed-off-by: ValdikSS <iam@valdikss.org.ru>
2022-01-09 17:36:45 +03:00
ValdikSS bcc7f08832 Fix for 1786bd582d 2022-01-09 17:28:03 +03:00
ValdikSS 0ad90c7ef7 Do not try to split WIM if install.wim is missing 2022-01-09 17:27:55 +03:00
ValdikSS 9361a3cd4b Extract bootmgfw.efi from both .wim and .esd (customized Win7 ISO) 2022-01-09 16:15:38 +03:00
ValdikSS 6fc6f0ad94 Mount FAT32 partitions in UTF-8 mode
Fixes #21
2022-01-09 16:14:46 +03:00
ValdikSS 8354ffdc14 Use C.utf8 locale for customized ISO with non-latin filenames
Fixes #21
2022-01-09 16:14:18 +03:00
ValdikSS 68b616a916 Fix bootmgfw.efi extraction with split wim activated
Fixes #25
2022-01-08 14:15:26 +03:00
ValdikSS fd26a51536 Wait 3 seconds inside format_drive function, not in the caller 2022-01-07 04:14:57 +03:00
ValdikSS 00d4a7ea5a Make mode optional and assume MBR by default 2022-01-07 04:13:55 +03:00
ValdikSS 1786bd582d Wait 1 second for new patition table to apply.
Hopefully fix #24
2022-01-07 04:05:34 +03:00
Recolic ed82962bae Bug fix: MBF-FAT32 mode not working on /dev/loop0
```
 == Writing bootloader ==
/dev/loop0 seems to be a disk partition device,
use the switch -f to force writing of a master boot record
```
2021-11-25 17:25:40 +08:00
2 changed files with 39 additions and 27 deletions
+16 -3
View File
@@ -17,9 +17,9 @@ Features:
Windows 7/8/8.1/10/11 ISO to Flash Drive burning utility
WARNING: this program will delete all existing data on your drive!
windows2usb <device> <windows iso> <mbr/gpt/gptntfs/gpt+uefintfs>
windows2usb <device> <windows iso> [mbr/gpt/gptntfs/gpt+uefintfs]
mbr mode: the most universal, RECOMMENDED method.
mbr mode: the most universal, RECOMMENDED and DEFAULT method.
This mode creates MBR partition table with FAT32 partition,
installs BIOS and UEFI bootloaders, supports Secure Boot.
install.wim file larger than 4 GiB will be split.
@@ -44,12 +44,25 @@ gpt+uefintfs mode: alternative hacky installation method, not recommended.
Download latest [portable AppImage version](https://github.com/ValdikSS/windows2usb/releases) from the **Releases** page, set *execution bit* (`chmod +x windows2usb-*.AppImage`) and run it from the terminal.
`windows2usb <device> <windows iso> <mbr/gpt/gptntfs/gpt+uefintfs>"`
`windows2usb <device> <windows iso>`
For example:
`./windows2usb.AppImage /dev/sdz /home/valdikss/windows10.iso`
The program prints removable storage list if no arguments are supplied.
If you don't want to use AppImage, you'll need to install all dependencies and download [uefi-ntfs.img](https://github.com/pbatard/rufus/tree/master/res/uefi) from Rufus project.
### Feature Matrix
|Modes |Legacy/UEFI-CSM Boot|UEFI Boot|Large ISO (>4GB)|Secure Boot|File System|Part Table|
|:----------:|:------------------:|:-------:|:--------------:|:---------:|:---------:|:--------:|
|mbr(hybrid) |Supported |Supported|Supported |Supported |FAT32 |MBR |
|gpt |No |Supported|Supported |Supported |FAT32 |GPT |
|gptntfs |No |Partial |Supported |Supported |NTFS |GPT |
|gpt+uefintfs|No |Supported|Supported |No |NTFS |GPT |
### BIOS Boot
BIOS Boot (Legacy Boot/UEFI-CSM) uses stock Windows 7 MBR and FAT32 bootloader, courtesy of [ms-sys](http://ms-sys.sourceforge.net/) project.
+23 -24
View File
@@ -4,7 +4,7 @@ set -f # noglob
set +o braceexpand # disable braceexpand
shopt -s nocasematch # for "if labeltype"
export LANG=C
export LANG=C.utf8
bold="$(tput bold)"
normal="$(tput sgr0)"
@@ -52,6 +52,7 @@ function format_drive() {
if [[ "$1" == "dos" ]] || [[ "$1" == "gpt" ]];
then
echo "label: $1" | sfdisk "$2"
sleep 3
else
echo "${bold} == format_drive: INTERNAL ERROR ==${normal}"
exit 101
@@ -63,7 +64,7 @@ function get_iso_name() {
}
function check_installwim_gt4gib() {
7z l "$1" | awk '($6 ~ /install.wim/) {if ($4 > 4294967296) {exit 0}; exit 1}'
7z l "$1" | awk 'BEGIN {doend=1} ($6 ~ /install.wim/) {if ($4 > 4294967296) {doend=0; exit 0}; doend=0; exit 1} END {if (doend) {exit 1}}'
}
function create_partitions() {
@@ -94,6 +95,9 @@ function create_partitions() {
echo "${bold} == create_partitions: INTERNAL ERROR ==${normal}"
exit 102
fi
# Wait 1 second to settle new partition table
# See bug #24
sleep 1
}
function get_dev_partition_num() {
@@ -147,10 +151,16 @@ function split_wim() {
}
function extract_bootmgfw_from_installwim() {
# $1 - install.wim path
# $2 - destdir
# $1 - isopath
# $2 - isomountpath
# $3 - destdir
7z e "$1" -o"$2" 1/Windows/Boot/EFI/bootmgfw.efi
local fpath="$2/sources/install.wim"
[ ! -a "$fpath" ] && fpath="$2/sources/install.esd"
mount -o ro "$1" "$2"
7z e "$fpath" -o"$3/efi/boot/" '?/Windows/Boot/EFI/bootmgfw.efi'
umount "$2"
}
function umount_rm_path() {
@@ -169,14 +179,14 @@ function sigint_handler() {
umount_rm_path "$partpath" "$isomountpath"
}
if [[ ! "$3" ]];
if [[ ! "$2" ]];
then
echo "${bold}Windows 7/8/8.1/10/11 ISO to Flash Drive burning utility"
echo "WARNING: this program will delete all existing data on your drive!${normal}"
echo
echo "$(basename "$0")" "<device> <windows iso> <mbr/gpt/gptntfs/gpt+uefintfs>"
echo "$(basename "$0")" "<device> <windows iso> [mbr/gpt/gptntfs/gpt+uefintfs]"
echo
echo "mbr mode: the most universal, RECOMMENDED method."
echo "mbr mode: the most universal, RECOMMENDED and DEFAULT method."
echo " This mode creates MBR partition table with FAT32 partition,"
echo " installs BIOS and UEFI bootloaders, supports Secure Boot."
echo " install.wim file larger than 4 GiB will be split."
@@ -208,6 +218,7 @@ then
isopath="$2"
isolabel=""
labeltype="$3"
[[ ! "$labeltype" ]] && labeltype="mbr"
mountntfs_cmd="mount.ntfs-3g"
if ! command -v "$mountntfs_cmd" > /dev/null;
then
@@ -236,19 +247,16 @@ then
echo "${bold} == Creating new MBR-formatted partition table ==${normal}"
format_drive "dos" "$dev"
echo "${bold} == Waiting 3 seconds to settle new partition layout ==${normal}"
sleep 3
echo "${bold} == Creating FAT partition ==${normal}"
create_partitions "dos" "$dev"
mkfs.vfat -n "${isolabel:0:11}" "$(get_dev_partition_num "${dev}" "1")"
echo "${bold} == Writing bootloader ==${normal}"
ms-sys -7 "${dev}"
ms-sys -7 -f "${dev}"
ms-sys -e "$(get_dev_partition_num "${dev}" "1")"
echo "${bold} == Mounting data partition ==${normal}"
mount "$(get_dev_partition_num "${dev}" "1")" "$partpath"
mount -o utf8=true "$(get_dev_partition_num "${dev}" "1")" "$partpath"
# GPT FAT32
elif [[ "$labeltype" == "gpt" ]];
@@ -256,15 +264,12 @@ then
echo "${bold} == Creating new GPT-formatted partition table ==${normal}"
format_drive "gpt" "$dev"
echo "${bold} == Waiting 3 seconds to settle new partition layout ==${normal}"
sleep 3
echo "${bold} == Creating FAT partition ==${normal}"
create_partitions "gpt" "$dev"
mkfs.vfat -n "${isolabel:0:11}" "$(get_dev_partition_num "${dev}" "1")"
echo "${bold} == Mounting data partition ==${normal}"
mount "$(get_dev_partition_num "${dev}" "1")" "$partpath"
mount -o utf8=true "$(get_dev_partition_num "${dev}" "1")" "$partpath"
# GPT NTFS
elif [[ "$labeltype" == "gptntfs" ]];
@@ -274,9 +279,6 @@ then
echo "${bold} == Creating new GPT-formatted partition table ==${normal}"
format_drive "gpt" "$dev"
echo "${bold} == Waiting 3 seconds to settle new partition layout ==${normal}"
sleep 3
echo "${bold} == Creating Microsoft NTFS partition ==${normal}"
create_partitions "gptntfs" "$dev"
mkfs.ntfs -L "$isolabel" -f "$(get_dev_partition_num "${dev}" "1")"
@@ -292,9 +294,6 @@ then
echo "${bold} == Creating new GPT-formatted partition table ==${normal}"
format_drive "gpt" "$dev"
echo "${bold} == Waiting 3 seconds to settle new partition layout ==${normal}"
sleep 3
echo "${bold} == Creating UEFI FAT and Microsoft NTFS partitions ==${normal}"
create_partitions "gpt+uefintfs" "$dev"
write_uefintfs "$(get_dev_partition_num "${dev}" "1")"
@@ -325,7 +324,7 @@ then
then
echo "${bold} == Extracting UEFI bootloader from install.wim ==${normal}"
mkdir -p "$partpath/efi/boot/" || true
extract_bootmgfw_from_installwim "$partpath/sources/install.wim" "$partpath/efi/boot/"
extract_bootmgfw_from_installwim "$isopath" "$isomountpath" "$partpath"
mv "$partpath/efi/boot/bootmgfw.efi" "$partpath/efi/boot/bootx64.efi"
cp "$partpath/efi/boot/bootx64.efi" "$partpath/efi/boot/bootia32.efi"
fi