Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
68de91778e | ||
|
|
8cd1b02b9d | ||
|
|
8dd14fc452 | ||
|
|
4abb52133f | ||
|
|
964443265f | ||
|
|
6249a7fc98 | ||
|
|
1de605529a | ||
|
|
2a8287455e | ||
|
|
5aab680e8f | ||
|
|
9f855faabd | ||
|
|
905f95ae7b | ||
|
|
2af0bed0df | ||
|
|
bcc7f08832 | ||
|
|
0ad90c7ef7 | ||
|
|
9361a3cd4b | ||
|
|
6fc6f0ad94 | ||
|
|
8354ffdc14 | ||
|
|
68b616a916 | ||
|
|
fd26a51536 | ||
|
|
00d4a7ea5a | ||
|
|
1786bd582d | ||
|
|
ed82962bae |
@@ -17,9 +17,9 @@ Features:
|
|||||||
Windows 7/8/8.1/10/11 ISO to Flash Drive burning utility
|
Windows 7/8/8.1/10/11 ISO to Flash Drive burning utility
|
||||||
WARNING: this program will delete all existing data on your drive!
|
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,
|
This mode creates MBR partition table with FAT32 partition,
|
||||||
installs BIOS and UEFI bootloaders, supports Secure Boot.
|
installs BIOS and UEFI bootloaders, supports Secure Boot.
|
||||||
install.wim file larger than 4 GiB will be split.
|
install.wim file larger than 4 GiB will be split.
|
||||||
@@ -36,7 +36,8 @@ gptntfs mode: all the same as 'gpt' but NTFS is used.
|
|||||||
|
|
||||||
gpt+uefintfs mode: alternative hacky installation method, not recommended.
|
gpt+uefintfs mode: alternative hacky installation method, not recommended.
|
||||||
This mode uses NTFS partition and third-party 'uefintfs' bootloader.
|
This mode uses NTFS partition and third-party 'uefintfs' bootloader.
|
||||||
GPT+NTFS(data)+FAT32(efi), UEFI only, NO Secure Boot support.
|
GPT+NTFS(data)+FAT32(efi), UEFI only, supports Secure Boot
|
||||||
|
(since uefintfs Oct 23, 2021 release).
|
||||||
Large install.wim file will not be split.
|
Large install.wim file will not be split.
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -44,12 +45,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.
|
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.
|
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.
|
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 |Supported |NTFS |GPT |
|
||||||
|
|
||||||
### BIOS Boot
|
### 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.
|
BIOS Boot (Legacy Boot/UEFI-CSM) uses stock Windows 7 MBR and FAT32 bootloader, courtesy of [ms-sys](http://ms-sys.sourceforge.net/) project.
|
||||||
@@ -76,7 +90,7 @@ A special 'gpt+uefintfs' mode uses [uefi-ntfs](https://github.com/pbatard/uefi-n
|
|||||||
|
|
||||||
This mode was included earlier to work with installation disks where install.wim file is greater than 4 GiB, but since then split WIM file functionality was introduced, and now this mode may be considered obsolete.
|
This mode was included earlier to work with installation disks where install.wim file is greater than 4 GiB, but since then split WIM file functionality was introduced, and now this mode may be considered obsolete.
|
||||||
|
|
||||||
This mode does not support Secure Boot (uefi-ntfs bootloader is not signed by Microsoft or other trusted party).
|
uefi-ntfs bootloader is signed by Microsoft since Oct 23, 2021 release and supports Secure Boot.
|
||||||
|
|
||||||
## Alternatives
|
## Alternatives
|
||||||
|
|
||||||
@@ -93,3 +107,4 @@ This script uses:
|
|||||||
* [**p7zip**](https://www.7-zip.org/) for ISO extraction
|
* [**p7zip**](https://www.7-zip.org/) for ISO extraction
|
||||||
* [**autofsync**](https://github.com/i-rinat/autofsync/) to prevent filesystem bufferbloat and properly show copying progress (AppImage only)
|
* [**autofsync**](https://github.com/i-rinat/autofsync/) to prevent filesystem bufferbloat and properly show copying progress (AppImage only)
|
||||||
* [**wimlib**](https://wimlib.net/) to split large install.wim files to fit FAT32 partition
|
* [**wimlib**](https://wimlib.net/) to split large install.wim files to fit FAT32 partition
|
||||||
|
* [**uefi-ntfs**](https://github.com/pbatard/uefi-ntfs/)
|
||||||
|
|||||||
+59
-32
@@ -4,16 +4,29 @@ set -f # noglob
|
|||||||
set +o braceexpand # disable braceexpand
|
set +o braceexpand # disable braceexpand
|
||||||
shopt -s nocasematch # for "if labeltype"
|
shopt -s nocasematch # for "if labeltype"
|
||||||
|
|
||||||
export LANG=C
|
export LANG=C.utf8
|
||||||
|
|
||||||
|
header='
|
||||||
|
| __ _____ _ _ ____ _ _ ____ ____ |
|
||||||
|
| \ \ / /_ _| \ | | |___ \ | | | / ___|| __ ) |
|
||||||
|
| \ \ /\ / / | || \| | __) | | | | \___ \| _ \ |
|
||||||
|
| \ V V / | || |\ | / __/ | |_| |___) | |_) | |
|
||||||
|
| \_/\_/ |___|_| \_(_) |_____| \___/|____/|____/ |
|
||||||
|
========================================================
|
||||||
|
. Windows 7+ ISO to Flash Drive burning utility .'
|
||||||
|
|
||||||
bold="$(tput bold)"
|
bold="$(tput bold)"
|
||||||
normal="$(tput sgr0)"
|
normal="$(tput sgr0)"
|
||||||
|
blink="$(tput blink)"
|
||||||
|
red="$(tput setaf 1)"
|
||||||
|
smso="$(tput smso)"
|
||||||
|
rmso="$(tput rmso)"
|
||||||
scriptpath="$(readlink -f -- "$0")"
|
scriptpath="$(readlink -f -- "$0")"
|
||||||
dirpath="$(dirname "$scriptpath")"
|
dirpath="$(dirname "$scriptpath")"
|
||||||
|
|
||||||
|
|
||||||
function check_requirements() {
|
function check_requirements() {
|
||||||
local reqs=(awk lsblk 7z mkfs.vfat mkfs.ntfs sfdisk ms-sys mktemp wimsplit)
|
local reqs=(awk lsblk 7z mkfs.vfat mkfs.ntfs sfdisk ms-sys mktemp wimsplit tr)
|
||||||
|
|
||||||
for req in ${reqs[*]}; do
|
for req in ${reqs[*]}; do
|
||||||
if ! command -v "$req" > /dev/null;
|
if ! command -v "$req" > /dev/null;
|
||||||
@@ -52,6 +65,7 @@ function format_drive() {
|
|||||||
if [[ "$1" == "dos" ]] || [[ "$1" == "gpt" ]];
|
if [[ "$1" == "dos" ]] || [[ "$1" == "gpt" ]];
|
||||||
then
|
then
|
||||||
echo "label: $1" | sfdisk "$2"
|
echo "label: $1" | sfdisk "$2"
|
||||||
|
sleep 3
|
||||||
else
|
else
|
||||||
echo "${bold} == format_drive: INTERNAL ERROR ==${normal}"
|
echo "${bold} == format_drive: INTERNAL ERROR ==${normal}"
|
||||||
exit 101
|
exit 101
|
||||||
@@ -62,8 +76,14 @@ function get_iso_name() {
|
|||||||
7z l "$1" | awk '/Comment = / {print $3; exit 0}'
|
7z l "$1" | awk '/Comment = / {print $3; exit 0}'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function sanitize_iso_name() {
|
||||||
|
# FAT32 does not allow certain characters in names, see
|
||||||
|
# https://github.com/dosfstools/dosfstools/blob/1da41f0e70dcbfb874e8191c639b91fa58205ea4/src/fatlabel.c#L96
|
||||||
|
echo "$1" | tr -d '*?.,;:/\\|+=<>[]"'
|
||||||
|
}
|
||||||
|
|
||||||
function check_installwim_gt4gib() {
|
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() {
|
function create_partitions() {
|
||||||
@@ -94,6 +114,9 @@ function create_partitions() {
|
|||||||
echo "${bold} == create_partitions: INTERNAL ERROR ==${normal}"
|
echo "${bold} == create_partitions: INTERNAL ERROR ==${normal}"
|
||||||
exit 102
|
exit 102
|
||||||
fi
|
fi
|
||||||
|
# Wait 1 second to settle new partition table
|
||||||
|
# See bug #24
|
||||||
|
sleep 1
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_dev_partition_num() {
|
function get_dev_partition_num() {
|
||||||
@@ -117,9 +140,9 @@ function get_dev_partition_num() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function write_uefintfs() {
|
function write_uefintfs() {
|
||||||
if [ -a "$dirpath/uefi-ntfs.img" ]; then
|
if [ -e "$dirpath/uefi-ntfs.img" ]; then
|
||||||
cat "$dirpath/uefi-ntfs.img" > "$1"
|
cat "$dirpath/uefi-ntfs.img" > "$1"
|
||||||
elif [ -a "/usr/share/windows2usb/uefi-ntfs.img" ]; then
|
elif [ -e "/usr/share/windows2usb/uefi-ntfs.img" ]; then
|
||||||
cat "/usr/share/windows2usb/uefi-ntfs.img" > "$1"
|
cat "/usr/share/windows2usb/uefi-ntfs.img" > "$1"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -147,10 +170,16 @@ function split_wim() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function extract_bootmgfw_from_installwim() {
|
function extract_bootmgfw_from_installwim() {
|
||||||
# $1 - install.wim path
|
# $1 - isopath
|
||||||
# $2 - destdir
|
# $2 - isomountpath
|
||||||
|
# $3 - destdir
|
||||||
|
|
||||||
7z e "$1" -o"$2" 1/Windows/Boot/EFI/bootmgfw.efi
|
mount -o ro "$1" "$2"
|
||||||
|
local fpath="$2/sources/install.wim"
|
||||||
|
[ ! -e "$fpath" ] && fpath="$2/sources/install.esd"
|
||||||
|
|
||||||
|
7z e "$fpath" -aoa -o"$3/efi/boot/" 'Windows/Boot/EFI/bootmgfw.efi' '?/Windows/Boot/EFI/bootmgfw.efi'
|
||||||
|
umount "$2"
|
||||||
}
|
}
|
||||||
|
|
||||||
function umount_rm_path() {
|
function umount_rm_path() {
|
||||||
@@ -169,14 +198,14 @@ function sigint_handler() {
|
|||||||
umount_rm_path "$partpath" "$isomountpath"
|
umount_rm_path "$partpath" "$isomountpath"
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ ! "$3" ]];
|
if [[ ! "$2" ]];
|
||||||
then
|
then
|
||||||
echo "${bold}Windows 7/8/8.1/10/11 ISO to Flash Drive burning utility"
|
echo "${bold}${smso}${header}${rmso}"
|
||||||
echo "WARNING: this program will delete all existing data on your drive!${normal}"
|
echo "${blink}${red}WARNING: this program will delete all existing data on your drive!${normal}"
|
||||||
echo
|
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
|
||||||
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 " This mode creates MBR partition table with FAT32 partition,"
|
||||||
echo " installs BIOS and UEFI bootloaders, supports Secure Boot."
|
echo " installs BIOS and UEFI bootloaders, supports Secure Boot."
|
||||||
echo " install.wim file larger than 4 GiB will be split."
|
echo " install.wim file larger than 4 GiB will be split."
|
||||||
@@ -193,7 +222,8 @@ then
|
|||||||
echo
|
echo
|
||||||
echo "gpt+uefintfs mode: alternative hacky installation method, not recommended."
|
echo "gpt+uefintfs mode: alternative hacky installation method, not recommended."
|
||||||
echo " This mode uses NTFS partition and third-party 'uefintfs' bootloader."
|
echo " This mode uses NTFS partition and third-party 'uefintfs' bootloader."
|
||||||
echo " GPT+NTFS(data)+FAT32(efi), UEFI only, NO Secure Boot support."
|
echo " GPT+NTFS(data)+FAT32(efi), UEFI only, supports Secure Boot"
|
||||||
|
echo " (since uefintfs Oct 23, 2021 release)."
|
||||||
echo " Large install.wim file will not be split."
|
echo " Large install.wim file will not be split."
|
||||||
echo
|
echo
|
||||||
echo "${bold} == Removable storage list ==${normal}"
|
echo "${bold} == Removable storage list ==${normal}"
|
||||||
@@ -208,6 +238,7 @@ then
|
|||||||
isopath="$2"
|
isopath="$2"
|
||||||
isolabel=""
|
isolabel=""
|
||||||
labeltype="$3"
|
labeltype="$3"
|
||||||
|
[[ ! "$labeltype" ]] && labeltype="mbr"
|
||||||
mountntfs_cmd="mount.ntfs-3g"
|
mountntfs_cmd="mount.ntfs-3g"
|
||||||
if ! command -v "$mountntfs_cmd" > /dev/null;
|
if ! command -v "$mountntfs_cmd" > /dev/null;
|
||||||
then
|
then
|
||||||
@@ -233,38 +264,36 @@ then
|
|||||||
# MBR FAT32
|
# MBR FAT32
|
||||||
if [[ "$labeltype" == "mbr" ]];
|
if [[ "$labeltype" == "mbr" ]];
|
||||||
then
|
then
|
||||||
|
isolabel="$(sanitize_iso_name "$isolabel")"
|
||||||
|
|
||||||
echo "${bold} == Creating new MBR-formatted partition table ==${normal}"
|
echo "${bold} == Creating new MBR-formatted partition table ==${normal}"
|
||||||
format_drive "dos" "$dev"
|
format_drive "dos" "$dev"
|
||||||
|
|
||||||
echo "${bold} == Waiting 3 seconds to settle new partition layout ==${normal}"
|
|
||||||
sleep 3
|
|
||||||
|
|
||||||
echo "${bold} == Creating FAT partition ==${normal}"
|
echo "${bold} == Creating FAT partition ==${normal}"
|
||||||
create_partitions "dos" "$dev"
|
create_partitions "dos" "$dev"
|
||||||
mkfs.vfat -n "${isolabel:0:11}" "$(get_dev_partition_num "${dev}" "1")"
|
mkfs.vfat -n "${isolabel:0:11}" "$(get_dev_partition_num "${dev}" "1")"
|
||||||
|
|
||||||
echo "${bold} == Writing bootloader ==${normal}"
|
echo "${bold} == Writing bootloader ==${normal}"
|
||||||
ms-sys -7 "${dev}"
|
ms-sys -7 -f "${dev}"
|
||||||
ms-sys -e "$(get_dev_partition_num "${dev}" "1")"
|
ms-sys -e "$(get_dev_partition_num "${dev}" "1")"
|
||||||
|
|
||||||
echo "${bold} == Mounting data partition ==${normal}"
|
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
|
# GPT FAT32
|
||||||
elif [[ "$labeltype" == "gpt" ]];
|
elif [[ "$labeltype" == "gpt" ]];
|
||||||
then
|
then
|
||||||
|
isolabel="$(sanitize_iso_name "$isolabel")"
|
||||||
|
|
||||||
echo "${bold} == Creating new GPT-formatted partition table ==${normal}"
|
echo "${bold} == Creating new GPT-formatted partition table ==${normal}"
|
||||||
format_drive "gpt" "$dev"
|
format_drive "gpt" "$dev"
|
||||||
|
|
||||||
echo "${bold} == Waiting 3 seconds to settle new partition layout ==${normal}"
|
|
||||||
sleep 3
|
|
||||||
|
|
||||||
echo "${bold} == Creating FAT partition ==${normal}"
|
echo "${bold} == Creating FAT partition ==${normal}"
|
||||||
create_partitions "gpt" "$dev"
|
create_partitions "gpt" "$dev"
|
||||||
mkfs.vfat -n "${isolabel:0:11}" "$(get_dev_partition_num "${dev}" "1")"
|
mkfs.vfat -n "${isolabel:0:11}" "$(get_dev_partition_num "${dev}" "1")"
|
||||||
|
|
||||||
echo "${bold} == Mounting data partition ==${normal}"
|
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
|
# GPT NTFS
|
||||||
elif [[ "$labeltype" == "gptntfs" ]];
|
elif [[ "$labeltype" == "gptntfs" ]];
|
||||||
@@ -274,9 +303,6 @@ then
|
|||||||
echo "${bold} == Creating new GPT-formatted partition table ==${normal}"
|
echo "${bold} == Creating new GPT-formatted partition table ==${normal}"
|
||||||
format_drive "gpt" "$dev"
|
format_drive "gpt" "$dev"
|
||||||
|
|
||||||
echo "${bold} == Waiting 3 seconds to settle new partition layout ==${normal}"
|
|
||||||
sleep 3
|
|
||||||
|
|
||||||
echo "${bold} == Creating Microsoft NTFS partition ==${normal}"
|
echo "${bold} == Creating Microsoft NTFS partition ==${normal}"
|
||||||
create_partitions "gptntfs" "$dev"
|
create_partitions "gptntfs" "$dev"
|
||||||
mkfs.ntfs -L "$isolabel" -f "$(get_dev_partition_num "${dev}" "1")"
|
mkfs.ntfs -L "$isolabel" -f "$(get_dev_partition_num "${dev}" "1")"
|
||||||
@@ -292,9 +318,6 @@ then
|
|||||||
echo "${bold} == Creating new GPT-formatted partition table ==${normal}"
|
echo "${bold} == Creating new GPT-formatted partition table ==${normal}"
|
||||||
format_drive "gpt" "$dev"
|
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}"
|
echo "${bold} == Creating UEFI FAT and Microsoft NTFS partitions ==${normal}"
|
||||||
create_partitions "gpt+uefintfs" "$dev"
|
create_partitions "gpt+uefintfs" "$dev"
|
||||||
write_uefintfs "$(get_dev_partition_num "${dev}" "1")"
|
write_uefintfs "$(get_dev_partition_num "${dev}" "1")"
|
||||||
@@ -325,9 +348,13 @@ then
|
|||||||
then
|
then
|
||||||
echo "${bold} == Extracting UEFI bootloader from install.wim ==${normal}"
|
echo "${bold} == Extracting UEFI bootloader from install.wim ==${normal}"
|
||||||
mkdir -p "$partpath/efi/boot/" || true
|
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"
|
if [ -e "$partpath/efi/boot/bootmgfw.efi" ]; then
|
||||||
cp "$partpath/efi/boot/bootx64.efi" "$partpath/efi/boot/bootia32.efi"
|
mv "$partpath/efi/boot/bootmgfw.efi" "$partpath/efi/boot/bootx64.efi"
|
||||||
|
cp "$partpath/efi/boot/bootx64.efi" "$partpath/efi/boot/bootia32.efi"
|
||||||
|
else
|
||||||
|
echo "NOTE: your ISO file does not have UEFI bootloader, UEFI boot would be unavailable!"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "${bold} == Unmounting partition ==${normal}"
|
echo "${bold} == Unmounting partition ==${normal}"
|
||||||
|
|||||||
Reference in New Issue
Block a user