Notice:
As of ms-sys 2.4.1, it can create suitable FAT32 PE boot records with the -e option, which makes this script obsolete.
For older versions of ms-sys, the script can of course still be used.
| #!/bin/bash | |
| ## | |
| ## bootsect.sh --- build bootable USB for Windows 7 install | |
| ## | |
| ## Copyright (c) 2014, Michael Schierl | |
| ## All rights reserved. | |
| ## | |
| ## Redistribution and use in source and binary forms, with or without | |
| ## modification, are permitted provided that the following conditions | |
| ## are met: | |
| ## | |
| ## 1. Redistributions of source code must retain the above copyright | |
| ## notice, this list of conditions and the following disclaimer. | |
| ## | |
| ## 2. Redistributions in binary form must reproduce the above | |
| ## copyright notice, this list of conditions and the following | |
| ## disclaimer in the documentation and/or other materials provided | |
| ## with the distribution. | |
| ## | |
| ## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| ## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| ## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | |
| ## FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | |
| ## COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | |
| ## INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
| ## (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
| ## SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
| ## HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
| ## STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
| ## ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | |
| ## OF THE POSSIBILITY OF SUCH DAMAGE. | |
| ## | |
| ## First parameter is device name (like /dev/sdb1); should be partition type 0x0B | |
| DEVICE=$1 | |
| ## Prepare your device like this: | |
| # | |
| # mkfs.vfat $DEVICE | |
| # mount $DEVICE /mnt | |
| # mkdir -p /mnt/sources | |
| # cp -R /media/cdrom/bootmgr /media/cdrom/boot /mnt | |
| # cp /media/cdrom/sources/boot.wim /mnt/sources | |
| # umount /mnt | |
| # | |
| ## Don't forget to write a bootable MBR to your drive if not already | |
| ## done (and you don't want to use a boot manager)! | |
| ## ms-sys is available at <http://ms-sys.sourceforge.net/> | |
| ms-sys -2 $DEVICE | |
| xxd -r - $DEVICE <<'EOF' | |
| 000006f: 41bb aa55 cd13 7210 81fb 55aa 750a f6c1 | |
| 000007f: 0174 05fe 4602 eb2d 8a56 40b4 08cd 1373 | |
| 000008f: 05b9 ffff 8af1 660f b6c6 4066 0fb6 d180 | |
| 000009f: e23f f7e2 86cd c0ed 0641 660f b7c9 66f7 | |
| 00000af: e166 8946 f883 7e16 0075 3883 7e2a 0077 | |
| 00000bf: 3266 8b46 1c66 83c0 0cbb 0080 b901 00e8 | |
| 00000cf: 2b00 e92c 03a0 fa7d b47d 8bf0 ac84 c074 | |
| 00000df: 173c ff74 09b4 0ebb 0700 cd10 ebee a0fb | |
| 00000ef: 7deb e5a0 f97d ebe0 98cd 16cd 1966 6080 | |
| 00000ff: 7e02 000f 8420 0066 6a00 6650 0653 6668 | |
| 000010f: 1000 0100 b442 8a56 408b f4cd 1366 5866 | |
| 000011f: 5866 5866 58eb 3366 3b46 f872 03f9 eb2a | |
| 000012f: 6633 d266 0fb7 4e18 66f7 f1fe c28a ca66 | |
| 000013f: 8bd0 66c1 ea10 f776 1a86 d68a 5640 8ae8 | |
| 000014f: c0e4 060a ccb8 0102 cd13 6661 0f82 75ff | |
| 000015f: 81c3 0002 6640 4975 94c3 424f 4f54 4d47 | |
| 000016f: 5220 2020 2000 0000 0000 0000 | |
| EOF | |
| xxd -r - $DEVICE <<'EOF' | |
| 00001ae: 424f 4f54 4d47 5220 6973 206d 6973 7369 | |
| 00001be: 6e67 ff0d 0a44 6973 6b20 6572 726f 72ff | |
| 00001ce: 0d0a 5072 6573 7320 616e 7920 6b65 7920 | |
| 00001de: 746f 2072 6573 7461 7274 0d0a | |
| EOF | |
| xxd -r - $DEVICE <<'EOF' | |
| 00001fa: c1ce | |
| EOF | |
| xxd -r - $DEVICE <<'EOF' | |
| 00003ec: 0200 | |
| EOF | |
| xxd -r - $DEVICE <<'EOF' | |
| 000182e: c2fc 663d f8ff ff0f 0f83 b8fc 6650 6683 | |
| 000183e: e802 660f b65e 0d8b f366 f7e3 6603 46fc | |
| 000184e: bb00 828b fbb9 0100 e8a3 fc38 2d74 1eb1 | |
| 000185e: 0b56 be69 7df3 a65e 741b 03f9 83c7 153b | |
| 000186e: fb72 e84e 75da 6658 e865 0072 bf83 c404 | |
| 000187e: e971 fc00 2083 c404 8b75 098b 7d0f 8bc6 | |
| 000188e: 66c1 e010 8bc7 6683 f802 0f82 56fc 663d | |
| 000189e: f8ff ff0f 0f83 4cfc 6650 6683 e802 660f | |
| 00018ae: b64e 0d66 f7e1 6603 46fc bb00 0006 8e06 | |
| 00018be: 8180 e839 fc07 6658 c1eb 0401 1e81 80e8 | |
| 00018ce: 0e00 0f83 0200 72d0 8a56 40ea 0000 0020 | |
| 00018de: 66c1 e002 e811 0026 668b 0166 25ff ffff | |
| 00018ee: 0f66 3df8 ffff 0fc3 bf00 7e66 0fb7 4e0b | |
| 00018fe: 6633 d266 f7f1 663b 46f4 743a 6689 46f4 | |
| 000190e: 6603 461c 660f b74e 0e66 03c1 660f b75e | |
| 000191e: 2883 e30f 7416 3a5e 100f 83c7 fb52 668b | |
| 000192e: c866 8b46 2466 f7e3 6603 c15a 528b dfb9 | |
| 000193e: 0100 e8b9 | |
| EOF |
Notice:
As of ms-sys 2.4.1, it can create suitable FAT32 PE boot records with the -e option, which makes this script obsolete.
For older versions of ms-sys, the script can of course still be used.