How to create a bootable USB stick with Linux and FAT32 from macOS

bootpartitionunixusb

I want to put 2 partitions on my USB stick: first one (so Windows can see it) with FAT32 (so also macOS can write to it) and a second one, bootable with system-rescue-cd on it.

I started looking how to partition the stick and I discovered that Disk Utility will not let me create partitions on the USB stick (the button is disabled), let alone configure the partition as bootable in the MBR.

There is plenty of ways to do that on GNU/Linux, other also works on Windows but I didn't find anything for macOS. Is there any free (as a beer) way to do that?

Best Answer

You need to use diskutil through Terminal to accomplish this.

The command you would use is

diskutil partitionDisk diskX 2 MBR fat32 "LINUX" 80% fat32 "RESCUE" 20%

A few notes:

  • diskX is the identifier of your USB stick (use diskutil list to get that info)
  • For this example, I am using a 1GB flash and dedicating 80% of it to the Linux partition and 20% to the Rescue. You can use actual size values like 800MB and 200MB rather than percentages.
  • You will need a boot loader (like GRUB2) installed. If your rescue CD already has one, just dd the image to the "Rescue" partition.
  • "Linux" and "Rescue" are the names of the partitions
  • The partitions will be created in the order listed.

Per the man page:

partitionDisk device [numberOfPartitions] [APM[Format] | MBR[Format] | GPT[Format]] [part1Format
                part1Name part1Size part2Format part2Name part2Size part3Format part3Name part3Size ...]