-
Four Vista/Windows-7 installation DVDs in one flash drive
How to Transfer 4 versions of Vista and Windows-7 installation DVDs into a flash drive
Edited 18/6/10 --- I have discovered a method to put the installation DVDs and boot each one from a logical partition. This remove the limitation of 4 installation DVD. You can have as many as you want limited by only the flash drive capacity. More details shown in Post #5
Introduction
The recent versions of MS Windows of Vista and Windows 7 installers support booting from a USB device so it is possible to transfer the contents of the installation DVD to a flash drive and use it for booting.
A USB flash drive however is classified by M$ as a “Super floppy” that can only have one partition. This means one flash drive can store one MS Windows boot loader.
This tutorial shows how to use Grub, a Linux boot loader, to boot 4 Vista/Windows 7 installation in one flash drive.
Technical consideration
(1) I have checked to my satisfaction that none of the MS Windows of Win2k, Xp, Vista and Win7 can mount or see more than one partition in a flash drive. That doesn't mean the user can't have multiple partitions. It is just MS systems have been engineered to mount the first one it recognises and disregards the rest.
(2) MS Windows installers of Vista and Win7 do not like to be booted from a logical partition. As a flash drive with a Msdos partition table can have a maximum 4 primary partitions hence this tutorial describes 4 versions of MS Windows installers of Vista Home-32, Win7 Ultimate-32, Vista Home-64 and Win7 professional-64.
(3) Grub accomplishes the booting process by unhiding the partition it is asked to boot and hiding the remaining 3 primaries. The hiding only alter the partition Type number in fooling the installer thinking the hidden partitions being foreign. MS system command “diskpart” has a similar facility by “setid” doing exactly the same thing. Grub can do this during boot time whereas diskpart can only operate after an installer or a MS Windows has been booted up first.
(4) Every MS system, from Dos to Win7, has a boot sector code deposited in the reserved boot sector of the partition it resides in. Technically it become possible for another boot loader to load the boot sector code and hand over the control to the MS system. This is one boot loader booting another one, a technique called “chainloading" used by virtually all reputable boot loaders. MS Win2k/Xp's NTLDR and Vista/Win7's bootmgr boot other operating systems with the same technique. The scheme described here is install the boot sector code of bootmgr in each primary partition of the flash drive. Grub is fired up first and then asked to hand over the control to this boot sector code which responsible for loading the Vista/Win7 common boot loader bootmgr. It is bootmgr that fires up the installer program.
(5) Vista and Win7 has a program “bootsect.exe” stored in every \boot directory of the installation DVD. To generate a boot sector code for boomgr, say to the drive D: is simpy
Code:
bootsect.exe /nt60 d:
Outline of the scheme
(i) Format the flash drive into 4 primary partitions. This is done in Linux with a Live CD as Linux mount all partitions and has a far more powerful set of utilities.
(ii) Copy the contents of each MS Windows installation DVD into each partition of the flash drive. This can be done either in Linux (or MS Windows if using a USB hard disk as an interim storage with which all 4 primaries can be mounted, otherwise one partition at a time with a pen drive)
(iii) Write the boot sector code in each primary partition. This operation can only be done with an installation DVD or using an installed 64-bit MS Vista or Win7.
(iv) Arrange the booting process. This involves using Linux. Only the boot loader Grub is installed but its location can be in a floppy, with the flash drive, in a CD/DVD or any of the hard disk partition.
Essential steps or commands
I list all the essential commands with brief explanations.
(A) To create a Linux bootable CD. - to be done in MS Windows or any OS.
This requires a user to download an iso file free from an Internet site and burn the image file to a bootable CD. I suggest Mepis, downloadable from here from DistroWatch.com, as it has Grub1 inside. The most popular Linux is Ubuntu but it has moved to Grub2 which is more difficult to use. Ubuntu, if internet-able, can also be used if the user replace the Grub2 with Grub1 by adding it with the command
Code:
sudo apt-get install grub
(B) Boot up Mepis Live CD, claim the root privilege (equivalent to Admin rights in MS Windows)
Mepis will ask for the root password which for a Live CD is just “root”. If Ubuntu is used the "su" is replaced by "sudo su" and Ubuntu doesn't demand a password if it is a Live CD.
Then do a sanity check to show up all disks and partitions by command
The above displays the device names of every partition.
(C) Formatting the partitions - shown here done in Linux but can be done in Windows
There are many partitioning tools in Linux. I used a script, equivalent to a batch file in Dos, to do the partitioning. First I entered this line in terminal
Code:
echo ",393,7" >a2 ;echo ",393,7" >>a2 ;echo ",654,7" >>a2;echo ",523,7" >>a2
which produces a text file called “a2” representing the key strokes I would have to use with the program “sfdisk” in Linux. The 393, 393, 654 and 523 are the number of cylinders in the 4 primary partition which I specified with Type “7” signifying the NTFS filing type. The partitioning command is just
Code:
sfdisk /dev/sdc< a2
producing the following partition table
Code:
Disk /dev/sdc: 400.1 GB, 400088457216 bytes
255 heads, 63 sectors/track, 48641 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00017ff8
Device Boot Start End Blocks Id System
/dev/sdc1 1 393 3156741 7 HPFS/NTFS
/dev/sdc2 394 786 3156772+ 7 HPFS/NTFS
/dev/sdc3 787 1440 5253255 7 HPFS/NTFS
/dev/sdc4 1441 1963 4200997+ 7 HPFS/NTFS
on a 400Gb USB external hard disk temporarily. MS Windows mounts every partition if it is a hard disk in the USB connection. I was just make use this feature to accelerate the process. I shall show how the finish product can be copied to a USB flash drive in one operation.
The use of a USB hard disk as an interim storage is optional but it amkes life a lot easier.
The above partitions sizes, approximately 3.2Gb, 3.2Gb, 5.3Gb and 4.3Gb were selected to accommodate the 32-bit Vista, 32-bit Win7, 64-bit Vista and 64-bit Win7 respectively, after checking their DVD contents. One cylinder is 255 heads x 63 sectors x 512 bytes per sector giving 8.225Mb.
Linux separates the partition creation with formatting. The former is reversible but the latter is irreversible. The formatting in Linux is conducted on the device which cannot be mounted yet as it has no filing system yet.
Code:
mkfs.ntfs -f -L Vista-32 /dev/sdc1
mkfs.ntfs -f -L Win7-32 /dev/sdc2
mkfs.ntfs -f -L Vista-64 /dev/sdc3
mkfs.ntfs -f -L Win7-32 /dev/sdc4
In the above I opted for a “fast” format and added a “Label” to each partition to help me identify them.
Now with a filing system inside these blank partitions can be mounted for accepting the DVD data.
Linux uses the /mnt for the mounting purpose so I made 4 mounting points, one per partition, in the /mnt directory and mounted the appropriate devices or partitions.
Code:
mkdir /mnt/sdc1
mkdir /mnt/sdc2
mkdir /mnt/sdc3
mkdir /mnt/sdc4
mount /dev/sdc1 /mnt/sdc1
mount /dev/sdc2 /mnt/sdc2
mount /dev/sdc3 /mnt/sdc3
mount /dev/sdc4 /mnt/sdc4
(D)Transferring the content of the installation DVDs to the partitions - shown in Linux here but can be done in Windows
By placing one DVD after the other
Code:
cp -R /media/UDF\ Volume/* /mnt/sdc1
cp -R /media/UDF\ Volume/* /mnt/sdc2
cp -R /media/UDF\ Volume/* /mnt/sdc3
cp -R /media/UDF\ Volume/* /mnt/sdc4
In the above the terminal will not accept my command until the copying operation is complete. The CD/DVD drive has been mounted automatically by Linux under the name of “UDF Volume” in /media directory.
I have now transferred the 4 Vista and Win7 DVDs into the 4 primary partitions of a USB hard disk.
(E) Write boot sector code in each primary partition. - must be done in MS Windows
I need to run bootsect.exe with this Windows-only operation with the USB disk. It can be done inside a 64-bit Win7's Command Prompt or by booting up a 64-bit Win7 or Vista DVD, opt for “Repair” and select “Command Prompt”.
In a Vista/Win7 Command Prompt, which is equivalent to the terminal mode in Linux or Recovery Console in XP installation CD, one has to check the partition drive letters first. The labels I entered during the formatting enable me to identify them as drive j:, l:, m: and n: respectively. I then issued these commands to write each system's own boot sector code in its own partition. The 32-bit bootsect.exe does not work on 64 bit version so it pays to use each system's own bootsect.exe.
Code:
j:\boot\bootsect.exe /nt60 j:
l:\boot\bootsect.exe /nt60 l:
m:\boot\bootsect.exe /nt60 m:
n:\boot\bootsect.exe /nt60 n:
(F) Clone the USB hard disk into the flash drive. - can be done in any Linux but requires third party software if done in Windows
This has to be done easily in any Linux as it has a command called “dd” that could do a sector-to-sector copying. When booted up a Linux Live CD with my 400Gb USB hard disk and the 16Gb USB flash drive were identified as devices /dev/sdc and /dev/sdd. The cloning operation is just one line of command but it can only be issued after booting up Linux, opt for a terminal and claim root privilege.
Code:
dd if=/dev/sdc of=/dev/sdd bs=32256
The command “dd” here is instructed to read from an input file sdc, which is the 400Gb USB hard disk and write the data on an output file sdd, which is the 16Gb USB flash drive, using block size 32256 bytes. One complete track of 63 sectors times 512 bytes per sector is 32256 bytes I specified here as one record.
“dd” will attempt to read all 400Gb hard disk and put the same on the 16Gb flash drive but it has to stop with an error when the room for writing has been exhausted in the 16Gb device. The partitions I have created in the 400Gb hard disk is less than 16Gb so the rest is just empty space.
I used the above technique because it is simple. When the first record, which should be 63 sectors of 512 bytes, is cloned the MBR of the 400Gb hard is faithfully duplicated on the 16Gb flash drive. “dd” does not copy files. It copies the binary bits in the hard disk and so the boot sector codes are automatically transferred.
On completion I have a healthy and sound flash drive ready to boot up any of the 4 Vista and Win7 installation DVD. All I need now is how to boot it.
(G) To arrange booting arrangement - Only done in Linux and the reason of this thread
The easiest way to boot the fully populated flash drive is by a Grub floppy. This is because one does not have to bother with the Bios at all if the floppy is the first bootable device.
Here are the steps to make a bootable Grub floppy, involving copying just two files, called stage1 and stage2 normally residing in the /boot/grub directory of a Linux that has Grub1. In a terminal with root privilege and a spare 1.44Mb floppy in the drive the method published by GNU/Grub Manual is
Code:
dd if=/boot/grub/stage1 of=/dev/fd0 bs=512 count=1
dd if=/boot/grub/stage2 of=/dev/fd0 bs=512 seek=1
The GNU/Grub method produce a floppy without a filing system. So it is only usable for booting purpose. My own method involves the following steps but the floppy is formatted and can be used for storage.
Code:
mkdosfs -F12 /dev/fd0
mkdir /mnt/fd0
mount /dev/fd0 /mnt/fd0
mkdir /mnt/fd0/boot
mkdir /mnt/fd0/boot/grub
cp /boot/grub/stage* /mnt/fd0/boot/grub/
At this point the floppy isn't bootable yet. To make it bootable I need to put the boot sector code in the floppy by invoking a Grub shell at the Linux terminal and set up Grub, by these commands
Code:
grub
root (fd0)
setup (fd0)
quit
The above floppy can accept a booting menu which can be created by an text editor. The filename must be menu.lst and has to be stored in the /boot/grub directory of the floppy. It is very easy to create one. I have assumed my flash drive as the 4th disk in the PC but a user can adjust for his/her situation accordingly.
Grub1 counts disks and partitions from zero. First disk is (hd0), second disk is (hd1) etc. The second digit is attached denotes the partition number. Therefore the 1st partition of the first disk is (hd0,0) and the 2th partition of the 4th disk is (hd3,1). Since my flash drive is the 4th disk so my 4 choices of booting the 4 installation DVD will be like, using a Linux terminal editor like
Code:
nano /mnt/fd0/boot/grub/menu.lst
to have the following entries
Code:
title Vista 32-bit in first primary of 4th disk
unhide (hd3,0)
root (hd3,0)
chainloader +1
title Win7 32-bit in second primary of 4th disk
hide (hd3,0)
unhide (hd3,1)
root (hd3,1)
chainloader +1
title Vista 64-bit in third primary of 4th disk
hide (hd3,0)
hide (hd3,1)
unhide (hd3,2)
root (hd3,2)
chainloader +1
title Win7-64-bit in fourth primary of 4th disk
hide (hd3,0)
hide (hd3,1)
hide (hd3,2)
unhide (hd3,3)
root (hd3,3)
chainloader +1
In the menu there is no need to hide with the partitions after the one to be booted because Vista and Win7 would not mount them.
I provide the booting alternative with a Grub floppy because it is the most convenient method of booting. When Grub is loaded it will try to execute the menu.lst if it is available. If it is not found or defective then Grub defaults to a Grub prompt. In a Grub prompt one can boot up each MS Windows installer “manually”! The commands in the above menu.lst are actually the manual commands required by typing one line at a time, with the “title” statement omitted and the after “chainloader +1” add one more statement of “boot”.
As an example if a user in a Grub prompt can boot the second partition manually by
Code:
hide (hd3,0)
unhide (hd3,1)
root (hd3,1)
chainloader +1
boot
He/she can fire up a hard disk any time in a Grub prompt by loading its MBR by
Code:
root (hd0)
chainloader +1
boot
It is noteworthy to point out the simple process of booting here too. What Grub is doing here after being informed of the partition required to be booted by the “root” statement it is then instructed to chainload the boot sector of the partition at the “+1” position, meaning from the second sector onward as Grub itself occupies the first sector.
If a user has no floppy drive then it will be necessary to install Grub in the pen drive. A different thread has be written for this particular purpose. It is a cunning technique because the pen drive has 4 primary partitions and has no more room for Grub which needs a partition for installation. Grub cannot be place in a NTFS partition because it cannot read such filing system. However a newer version Grub2 may be able to read a NTFS partition but it may need the partition's boot sector for residence too. Please refer to this thread for details to place Grub in a fully populated flash drive. I have written this thread showing how Grub can be put inside a CD/DVD or a hard disk partition.
Discussuion of results
The 4 Vista and Win7 installation DVDs were successfully transferred and booted up as expected. However I found the MS installer has been written to fetch files from the first partition from the flash drive. Therefore partitions in front of the one you want to boot must be temporarily deleted. If this rule is not followed the installer can report an error asking a driver for the CD/DVD drive.
All 4 installation DVDs have been booted successfully and can be used for installation.
Example of deleting partitions in front of the one required to be booted.
I deleted the first primary and booted the second partition which is still known to Linux as sdc2 but the partition table now has no sdc1 entry. To my surprise my Win7-32 booted. I then deleted the second partition and the 3rd partition of Vista-64 booted up successfully. With the partition table looking like this
Code:
Disk /dev/sdb: 16.2 GB, 16173236224 bytes
255 heads, 63 sectors/track, 1966 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00017ff8
Device Boot Start End Blocks Id System
/dev/sdc3 787 1440 5253255 7 HPFS/NTFS
/dev/sdc4 1441 1963 4200997+ 7 HPFS/NTFS
Naturally I tried the last partition sdc4 by removing sdc3 and my Win7-64 fired up. So it all works as long as the Installation DVD is at the "first" partition of the hard disk with nothing ahead of it.
It is a bit of inconvenient I admit but remember I could restore my partition table any time with a script. So I went into the Internet, displayed this thread, copied the script in Section (C), activated it in a terminal and did
Code:
sfdisk /dev/sdc <a2
and have my full partition table back again.
In conclusion the above scheme can allow all 4 Vista/Win7 installation DVD installable from 4 primary partition of a flash drive. More can be accommodated if they are stored in the logical partitions. (see Post #5). However putting the installers in the primary partitions seems better and has less hassel with the installer during the boot time.
Conclusions
The simple booting of Vista/Win7 installer by a Linux boot loader Grub is demonstrated.
Grub in here has been made to interface with the Vista/Win7 boot loader bootmgr. The two work seamlessly.
Grub's ability to boot an operating system step by step manually is highlighted.
I was talked into working with a flash drive. Many restrictions disappear if a USB external hard disk is used.
Last edited by saikee; 06-22-2010 at 04:23 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|