2015-10-25 02:26:34 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
2015-10-25 19:15:14 +01:00
|
|
|
# Source: http://admincloud.net/116/creer-une-cle-usb-bootable-de-windows-sous-linux/
|
|
|
|
|
2015-11-17 22:06:17 +01:00
|
|
|
WIN_USB="${1}"
|
2015-10-25 02:26:34 +01:00
|
|
|
WIN_USB_MNT_PATH=/mnt/USBW7/
|
2015-11-17 21:58:55 +01:00
|
|
|
WIN_ISO_FILE="${2}"
|
2015-10-25 02:26:34 +01:00
|
|
|
WIN_ISO_MNT_PATH=/mnt/WIN7/
|
2015-11-17 22:22:46 +01:00
|
|
|
MS_SYS_VERSION="2.5.1"
|
2015-10-25 02:26:34 +01:00
|
|
|
|
2015-11-17 22:06:17 +01:00
|
|
|
# Test if args exists
|
|
|
|
for file in "${WIN_USB}" "${WIN_ISO_FILE}"; do
|
|
|
|
if [ ! -e "${file}" ]; then
|
|
|
|
printf '%b' "${file} doesn't exists. Please check your args.\n"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2015-10-25 02:26:34 +01:00
|
|
|
# Empty MBR
|
2015-11-17 22:06:17 +01:00
|
|
|
sudo dd if=/dev/zero of=${WIN_USB} bs=446 count=1
|
2015-10-25 02:26:34 +01:00
|
|
|
|
|
|
|
# Ensure to have a MS-DOS partition table
|
2015-11-17 22:06:17 +01:00
|
|
|
sudo parted ${WIN_USB} mklabel msdos
|
2015-10-25 02:26:34 +01:00
|
|
|
|
|
|
|
# Create one big partition with "boot" flag then format in NFTS
|
2015-11-17 22:16:33 +01:00
|
|
|
sudo parted ${WIN_USB} mkpart primary 0% 100%
|
2015-11-17 22:06:17 +01:00
|
|
|
sudo parted ${WIN_USB} set 1 boot on
|
2015-11-18 00:30:19 +01:00
|
|
|
#sudo mkfs.ntfs ${WIN_USB}1 --fast --no-indexing
|
|
|
|
# Need a FAT32 partition to be able to install Windaube on UEFI system!
|
|
|
|
sudo mkfs.vfat ${WIN_USB}1
|
2015-10-25 02:26:34 +01:00
|
|
|
|
2015-11-17 22:12:43 +01:00
|
|
|
# Mount first partition of the USB key
|
2015-10-25 02:26:34 +01:00
|
|
|
sudo mkdir -p -- "${WIN_USB_MNT_PATH}"
|
2015-11-17 22:06:17 +01:00
|
|
|
sudo mount ${WIN_USB}1 "${WIN_USB_MNT_PATH}"
|
2015-10-25 02:26:34 +01:00
|
|
|
|
|
|
|
# Mount ISO file
|
|
|
|
sudo mkdir -p -- "${WIN_ISO_MNT_PATH}"
|
|
|
|
sudo mount "${WIN_ISO_FILE}" "${WIN_ISO_MNT_PATH}" -o loop,ro
|
|
|
|
|
|
|
|
# Copy all files from ISO to USB
|
2015-11-17 22:12:43 +01:00
|
|
|
sudo cp -rv -- "${WIN_ISO_MNT_PATH}"* "${WIN_USB_MNT_PATH}"
|
2015-10-25 02:26:34 +01:00
|
|
|
|
|
|
|
# Umount and remove mount path
|
|
|
|
sudo umount "${WIN_USB_MNT_PATH}"
|
|
|
|
sudo umount "${WIN_ISO_MNT_PATH}"
|
|
|
|
sudo rmdir -- "${WIN_USB_MNT_PATH}" "${WIN_ISO_MNT_PATH}"
|
|
|
|
|
|
|
|
## Make the key bootable
|
|
|
|
|
|
|
|
# Ensure gettext is available
|
|
|
|
sudo aptitude install -y gettext
|
|
|
|
|
|
|
|
# Ensure to download the last version of ms-sys
|
|
|
|
if [ ! $(command -v ms-sys) ]; then
|
|
|
|
# http://ms-sys.sourceforge.net/#Download
|
2015-11-17 22:22:46 +01:00
|
|
|
wget http://netix.dl.sourceforge.net/project/ms-sys/ms-sys%20development/"${MS_SYS_VERSION}"/ms-sys-"${MS_SYS_VERSION}".tar.gz -O /tmp/ms-sys-"${MS_SYS_VERSION}".tar.gz
|
2015-10-25 02:26:34 +01:00
|
|
|
|
|
|
|
# Extract and install ms-sys
|
|
|
|
cd /tmp
|
2015-11-17 22:22:46 +01:00
|
|
|
tar xzvf /tmp/ms-sys-"${MS_SYS_VERSION}".tar.gz
|
2015-11-17 22:31:57 +01:00
|
|
|
cd /tmp/ms-sys-"${MS_SYS_VERSION}"
|
2015-10-25 02:26:34 +01:00
|
|
|
sudo make
|
|
|
|
sudo make install
|
|
|
|
fi
|
|
|
|
|
|
|
|
# For Win 7/8
|
2015-11-17 22:06:17 +01:00
|
|
|
sudo ms-sys --mbr7 "${WIN_USB}"
|
2015-10-25 02:26:34 +01:00
|
|
|
|
2015-11-17 22:12:43 +01:00
|
|
|
# For Win XP/2000/2003
|
|
|
|
#sudo ms-sys --mbr "${WIN_USB}"
|
|
|
|
|
|
|
|
# For Win Vista
|
|
|
|
#sudo ms-sys --mbrvista "${WIN_USB}"
|
|
|
|
|
2015-10-25 02:26:34 +01:00
|
|
|
exit 0
|