mirror of
https://github.com/ValdikSS/windows2usb.git
synced 2023-08-10 21:13:16 +03:00
Use function to determine device partitions
This commit is contained in:
parent
e56ae29ad6
commit
5cc82bf38c
36
windows2usb
36
windows2usb
@ -68,6 +68,26 @@ function create_partitions() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_dev_partition_num() {
|
||||||
|
# $1 - device
|
||||||
|
# $2 - partition number
|
||||||
|
|
||||||
|
if [ -b "${1}${2}" ];
|
||||||
|
then
|
||||||
|
echo "${1}${2}"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -b "${1}p${2}" ];
|
||||||
|
then
|
||||||
|
echo "${1}p${2}"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "${bold} == get_dev_partition_num: INTERNAL ERROR ==${normal}"
|
||||||
|
exit 105
|
||||||
|
}
|
||||||
|
|
||||||
function write_uefintfs() {
|
function write_uefintfs() {
|
||||||
cat "$dirpath/uefi-ntfs.img" > "$1"
|
cat "$dirpath/uefi-ntfs.img" > "$1"
|
||||||
}
|
}
|
||||||
@ -122,14 +142,14 @@ then
|
|||||||
|
|
||||||
echo "${bold} == Creating NTFS partition ==${normal}"
|
echo "${bold} == Creating NTFS partition ==${normal}"
|
||||||
create_partitions "dos" "$dev"
|
create_partitions "dos" "$dev"
|
||||||
mkfs.ntfs -f "${dev}1"
|
mkfs.ntfs -f "$(get_dev_partition_num "${dev}" "1")"
|
||||||
|
|
||||||
echo "${bold} == Writing bootloader ==${normal}"
|
echo "${bold} == Writing bootloader ==${normal}"
|
||||||
ms-sys -7 "${dev}"
|
ms-sys -7 "${dev}"
|
||||||
ms-sys -n "${dev}1"
|
ms-sys -n "$(get_dev_partition_num "${dev}" "1")"
|
||||||
|
|
||||||
echo "${bold} == Mounting data partition ==${normal}"
|
echo "${bold} == Mounting data partition ==${normal}"
|
||||||
mount "${dev}1" "$partpath"
|
mount "$(get_dev_partition_num "${dev}" "1")" "$partpath"
|
||||||
|
|
||||||
# GPT
|
# GPT
|
||||||
elif [[ "$labeltype" == "gpt" ]];
|
elif [[ "$labeltype" == "gpt" ]];
|
||||||
@ -146,10 +166,10 @@ then
|
|||||||
|
|
||||||
echo "${bold} == Creating UEFI FAT partition ==${normal}"
|
echo "${bold} == Creating UEFI FAT partition ==${normal}"
|
||||||
create_partitions "gpt" "$dev"
|
create_partitions "gpt" "$dev"
|
||||||
mkfs.vfat "${dev}1"
|
mkfs.vfat "$(get_dev_partition_num "${dev}" "1")"
|
||||||
|
|
||||||
echo "${bold} == Mounting data partition ==${normal}"
|
echo "${bold} == Mounting data partition ==${normal}"
|
||||||
mount "${dev}1" "$partpath"
|
mount "$(get_dev_partition_num "${dev}" "1")" "$partpath"
|
||||||
|
|
||||||
# GPT FAT32 + NTFS
|
# GPT FAT32 + NTFS
|
||||||
elif [[ "$labeltype" == "gptntfs" ]];
|
elif [[ "$labeltype" == "gptntfs" ]];
|
||||||
@ -159,11 +179,11 @@ then
|
|||||||
|
|
||||||
echo "${bold} == Creating UEFI FAT and Microsoft NTFS partitions ==${normal}"
|
echo "${bold} == Creating UEFI FAT and Microsoft NTFS partitions ==${normal}"
|
||||||
create_partitions "gptntfs" "$dev"
|
create_partitions "gptntfs" "$dev"
|
||||||
write_uefintfs "${dev}1"
|
write_uefintfs "$(get_dev_partition_num "${dev}" "1")"
|
||||||
mkfs.ntfs -f "${dev}2"
|
mkfs.ntfs -f "$(get_dev_partition_num "${dev}" "2")"
|
||||||
|
|
||||||
echo "${bold} == Mounting data partition ==${normal}"
|
echo "${bold} == Mounting data partition ==${normal}"
|
||||||
mount "${dev}2" "$partpath"
|
mount "$(get_dev_partition_num "${dev}" "2")" "$partpath"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "${bold} == Extracting files from ISO to the partition ==${normal}"
|
echo "${bold} == Extracting files from ISO to the partition ==${normal}"
|
||||||
|
Loading…
Reference in New Issue
Block a user