Here are my goals:

  • There should be only one partition.
  • This partition should be bootable from both old-style BIOS-based systems and new-generation EFI systems.
  • The boot-loader should use the French keyboard, and provide access to some diagnosis and recovery tools.
  • The Linux OS should be hidden from Windows.
  • The Windows applications should be hidden from Linux.
  • All non-data folders should be hidden from both Linux and Windows, including the boot-loader folder.
  • However, the folder for the Windows applications must of course be visible from Windows (but not Linux).
  • No closed-source nor paid software.

First the boot-loader. A search among the boot-loaders let me see that the preferred boot-loader for my purpose is Grub2; it will accept to be installed inside any folder, and it proves to be a nice bridge between BIOS and EFI systems. For Grub2 to work on BIOS systems though, I will have to make sure there are at least 63 sectors of unused space before the partition on the flash drive.

Now the partitions. There is no choice here. An EFI system will boot a disk only if its EFI system partition (“ESP”) has a FAT filesystem and is of type EFI (read on, there’s an exception…). But if I partition my drive this way, Windows simply considers the ESP to be hidden :-( Thankfully, at least for USB drives, plain FAT32 partitions (with type FAT32 in a DOS-style partition table) are accepted too, as long as the EFI folder is present; and Windows does not hide the partition in this case :-) So FAT32 it is. This also means that I will not be allowed bigger-than-4GB files, which does not matter that much…

Conclusion: the flash drive will be ready after a single FAT32 partition is created in a DOS-style partition table, starting at least 63 sectors from the start of the drive, and set with the “bootable” flag.

For the partitioning, use whatever tools you like. I usually use fdisk or gparted. When creating the FAT32 partition, be sure to select a label! Let us say the label is “FLASH” for the remainder of this series. For example (you obviously have to adapt the following to your actual flash drive’s path; also, be advised that the following commands will wipe the flash drive):

# fdisk /dev/sdb
create a new empty DOS partition table: o
add a new partition : n
primary partition : p
partition number one : 1
start from the default (start+1MB) : ⏎
end at the default (end of drive) : ⏎
toggle a bootable flag : a
change a partition type : t
partition type (W95 FAT32) : b
write table to disk and exit : w
# mkfs.vfat -n FLASH /dev/sdb1

Next blog post will deal with the installation of Grub2.