Testing GRUB 2 on your GPT-partitioned flash drive


I did a quick test, and you can, too.  I'll explore this some more after GRUB 2 and 9.10 are finalized.

Here's my summary.

OS:   Kubuntu 9.10 alpha 6 (which uses the latest version of GRUB 2 (1.97x).
Bootloader:  GRUB 2 (beta)
Disk device:  1 GB Kingston USB flash drive
Motherboard:  Intel DG33FBC; Intel D915GAVL
Disk partition utility:   GParted Live CD, current version

Steps:

1   Boot into Kubuntu

2   Open Konsole (Terminal program)

3   Optional:  Zero-out your flash drive
THIS WILL DESTROY ALL DATA ON THE FLASH DRIVE.
This writes zeros to the entire flash drive and restores it to factory-new condition.
Find out how Kubuntu sees your flash drive:
sudo fdisk -lu
Let's say, for this example, it is /dev/sdc.
Use the dd command to write zeros to the entire flash drive:
sudo dd if=/dev/zero  of=/dev/sdc
(You will not see any progress meter or output until it finishes.  It took approximately 7 minutes on my system.)

4  Partition the flash drive using GParted Live CD
You can also do this using an installed gparted (Partition Editor).
Tip:  While in GParted Live CD, remember that you have access to a terminal if you need one (for dd, or sudo fdisk -lu): double-click Terminal icon at top.  For root, simply use sudo in front of commands.

I partitioned as follows:

Plug in the flash drive, click Devices > Refresh (you may have do it more than once until the flash drive appears in the drop-down list of drives at the upper right or under GParted > Devices).
You'll get a message that a Disklabel must be set on the disk and asked if you want the (default) msdos  Disklabel.  (You will also get this message if you highlight unallocated space and click Partition > New).  You don't want msdos, so click the Advanced button and select gpt, then Create.

Partitions:

Partition 1:  BIOS Boot partition
8 MB (the minimum size offered), FAT32, for the BIOS Boot partition (embedding core.img).
Set a flag:  Partition > Manage flags, then check the bios_grub box (as the tag).
Set a Label on the partition to remind you what it is:
Partition > Label, and I typed BIOS_BOOT as the label.

Partition 2:  For setting up the GRUB 2 files in /boot/grub
10 MB, ext2
Also, set the boot flag on this partition to make it the active partition:
Partition > Manage flags > check the boot box.
Set a label on the partition to remind you what it is:
Partition > Label, and type GRUB_FILES as the label.

Partition 3:  A for-fun extra test partition for the heck of it.  (In another test, I also tested creating 10 partitions, and it went well under GPT.)
200 GB, ext2

5  Install GRUB 2 to the flash drive
Exit GParted Live CD, remove the CD and the flash drive, reboot into your regular Kubuntu.
Plug in the flash drive.  See how it is mounted (or go into Dolphin and click on the second partition GRUB_FILES to mount it).  Open Konsole. install GRUB 2 to the flash drive, setting up the GRUB 2 files in the second partition (GRUB_FILES) and installing the bootloader (boot.img = 512 bytes) to the MBR of the flash drive.
Example:
Suppose the second partition is mounted as /media/GRUB_FILES and suppose the flash drive is seen as /dev/sdc in Kubuntu (use sudo fdisk -lu to find out).  Then install GRUB 2 to it as follows:
sudo grub-install --root-directory=/media/GRUB_FILES  /dev/sdc
If it doesn't go, do it again with --recheck:
sudo grub-install --recheck --root-directory=/media/GRUB_FILES /dev/sdc

6  Re-booting from the flash drive:
Make sure your BIOS is set to boot from USB and configure BIOS to boot from your flash drive.
If you re-boot starting from your Kubuntu session, keep the flash drive plugged in (but click Safely Remove to unmount it), reboot the PC, enter BIOS setup, configure BIOS to boot from USB and put the flash drive at the top of the drive list, F10 to Save & Exit, and re-boot from the flash drive.  After the POST, you should see the GRUB 2 prompt (coming from the GRUB 2 on the flash drive): grub>.  (You get the GRUB prompt grub>  since there is no boot menu  (/boot/grub/grub.cfg) configured.)  You can use this grub prompt to boot into one of your OSs; or simply shutdown the PC (grub>halt) and remove the flash drive; or re-boot (grub>reboot), enter BIOS setup, remove the flash drive, set BIOS to boot from your regular drive, F10 to save this change and exit to reboot from your regular drive.

虹光大成就-密教灌頂(一)