You can install GRUB and use UUID as identifier for each hard disk partition to ensure the PC will start always the correct partition despite the HDDs chaning its boot order in BIOS.
First of all, just grab a LiveCD (anyone should do, I usually use SystemRescueCd. Once booted in console mode (default option), run the following command to get the UUID:
ls -l /dev/disk/by-uuid/
That will give you something like the following:
localhost ~ # ls -l /dev/disk/by-uuid/ total 0 lrwxrwxrwx 1 root root 10 Feb 22 09:25 0adb57d3-e475-4825-8ff9-32bd82fbd210 -> ../../sda3 lrwxrwxrwx 1 root root 10 Feb 22 09:25 9fb9d595-77b3-458a-b082-80a77d1d2b50 -> ../../sda1 lrwxrwxrwx 1 root root 10 Feb 22 09:25 d1a2c45f-b8dc-4312-a195-853e9364b398 -> ../../sda2
-> ../../sdaX equals to /dev/sdaX. This way you can get all the UUIDs of your HDDs partition. The example above are Linux partitions, Windows partitions might display a different UUID, but they're always unique.
Now you should insert the USB pendrive you want to start the OS from and mount it: mount /dev/sdd1 /mnt/pendrive
Then you can install GRUB to your pendrive with the following command:
grub-install --no-floppy --root-directory=/mnt/pendrive /dev/sdd1
To get the device the USB key is located in you can run fdisk -l
.
Once installed, you should edit the grub.conf
file and use UUID to select the right partition:
root (hd0,0) kernel /<kernel_file> root=UUID=4a2464b4-c865-4681-b9d9-5d8aef1e2215
Another easier method could be to use SuperGrubDisk and let it find the boot partitions and let you select which one to boot.