How to create a bootable, persistent Ubuntu USB stick for Mac

By Samuel Damon, Sat 05 September 2015, in category How-to

After searching for a while on this procedure with varying degrees of success, I decided to write a guide on how I managed to make a bootable, persistent Ubuntu USB drive for Mac. There are many different methods, but I will outline the one that worked for me. You'll need a Mac, access to sudo, and general knowledge of the terminal.

First, download the latest 64-bit Ubuntu Desktop ISO (or your preferred Ubuntu-flavored Linux distribution).

Then find a USB stick, preferably about or larger than 2GB and at least USB 2.0. Plug it into your computer and open the app Disk Utility. Select the drive and then click the Partition tab, and select 1 partition. Make sure it is set to MS-DOS (FAT) and that it uses MBR, not APT or GUID, and then apply the settings. This will wipe all your data.

Next, open Terminal and run:

diskutil list

Find your drive and take note of the number to the right. If it's the only thing inserted in the computer, it should be disk1. Then, unmount it with:

diskutil unmountDisk /dev/diskX

Make sure X is the number of your drive. Then you need to mark the disk active, by running:

sudo fdisk -e /dev/rdiskX

The program may display a warning that it is unable to open an MBR file. Ignore that, and then run these three commands consecutively:

f 1

After that, run the same command we used before to unmount the disk. Next, we need to download syslinux. Choose the latest archive, extract it, and cd to /bios/mbr inside. Make sure the file bios.mbr exists inside. Next, run:

sudo dd conv=notrunc bs=440 count=1 if=mbr.bin of=/dev/diskX

The program should take a few seconds to run and report writing around 440 bytes. If it returns an error about no access, try unmounting and remounting the USB drive. If the program cannot locate mbr.bin, you are probably in the wrong directory–double check you are in the mbr folder. The program may warn you that any changes will be inactive until the next reboot. You can ignore this and select "y".

Now install Unetbootin and create a live USB. Do not change the persistence settings; we will add that later. Simply select your downloaded ISO and continue. The program may take a while to complete, and when it does, it may warn you that the created USB cannot be booted on a Mac.

The USB stick should actually boot and run, but will not have persistence. To add a persistence file, run the following command:

dd if=/dev/zero of=/Volumes/USB/casper-rw bs=1m count=X

Replace /Volumes/USB/ with the appropriate path to your USB drive. Additionally, be sure to replace the X following count= with a value in megabytes to set the size of your persistent image. The more available space, the better–if the image is too small, you may not have enough room for your programs and files.

The command may run for several minutes. Once it is done, install e2fsprogs from Homebrew (recommended), MacPorts, or the provided link.

Once it is installed, run:

mke2fs -t ext4 /Volumes/USB/casper-rw

Remember to substitute the appropriate file path. Next on the same USB stick, navigate to /boot/grub/ and edit grub.cfg. Add the following text to the file above other menuentry items.

menuentry "Ubuntu persistent" {
    set gfxpayload=keep
    linux    /casper/vmlinuz.efi file=/cdrom/preseed/ubuntu.seed boot=casper persistent quiet splash --
    initrd    /casper/initrd.lz

If you are using the Linux distribution Linux Mint, add the nomodeset argument after splash.

Persistence should now be enabled. You may now boot your computer using the USB stick, selecting "EFI Boot" from the boot menu and then "Ubuntu persistent" from the following GRUB menu. Your files and changes are now persistent and will be saved, but the operating system will run slower than its non-persistent counterpart.

This guide was made possible thanks to Quackers from the Ubuntu forum, franz963's guide to using persistence with Mac Linux USB Loader, and the USB Ubuntu site.