Creating a UEFI + BIOS multi-boot + Data flash drive
This post is slightly different - It is mainly to document the process of creating a flash drive that boots into Grub2 with both a BIOS and UEFI firmware that you can also store data on in Windows.
First of all, you need to make sure that your flash drive has a GPT (GUID Partition Table) and not an MBR. If you don't know, it is safe to assume that you are currently using a MBR (Master Boot Record).
Switching to a GPT
If you don't have a GPT, then you need to backup the contents of your flash drive because you will need to wipe it clean in order to switch it over.
Make sure you are in a linux environment (start a virtual machine and pass the flash drive in if you don't have one). Work out where your flash drive is (in this instance ours is at
/dev/sdx) and then execute the following commands:
sudo apt-get install gdisk sudo sgdisk --zap-all /dev/sdx
The above will wipe all partition tables from the device. Before continuing, you may need to remove and re-plug-in the flash drive you are working in. Run this pair of commands to add a "Microsoft basic data" partition, and format it with FAT32:
sudo sgdisk --new=1:0:0 --typecode=1:0700 /dev/sdx sudo mkfs.vfat -F32 -n GRUB2EFI /dev/sdx1
The type code
0700 is the bit that determines the type of partition that we are creating. In this case, we are creating a
Microsoft basic data partition. The tutorial I followed (see the source at the bottom) set the type
ef00, which is a
EFI System Partition. If you experience problems, try changing the type to this.
Next up, we need to mount the new partition. Do it like this:
sudo mount -t vfat /dev/sdb1 /mnt -o uid=1000,gid=1000,umask=022
The above will mount it to the directory
/mnt. next, you need to go to the first source below and download the zip that can be found under the text
pack with all necessary files for you to modify as you need. Extract this to the root of the flash drive (
/mnt in our case):
cd ~/Downloads/ unzip usb-pack_efi.zip rsync -auv usb-pack_efi/ /mnt
Next, we need to install grub2 in BIOS mode. It will complain horribly, but apparently it works :D
sudo grub-install --force --removable --boot-directory=/mnt/boot /dev/sdb
Now you should have a flash drive with Grub2 installed, that you can also see in Windows!
Credit to sysmatck of ubuntuforums.org sudodus for the guide.