MacOS – Persistent Ubuntu boot USB: macOS Sierra

bootable-diskmacosusb

Short of figuring out how to achieve a dual boot configuration for my mid-2012 2GHz i7 MacBook Air to boot to a Linux OS, I've made a "live" boot USB with Ubuntu 16.04.2 LTS using UNetbootin. I would, however, like a "persistent" boot USB. Can this be done? So far I have tried the following to modify the "live" USB but would I be better off making a persistent USB on Windows and hoping it runs on Sierra?


  1. Per these Enterprise Installation instructions (from version 0.4.0), this seems like it might be an option:

6) OPTIONAL! If you're going to be booting Ubuntu, you can create a persistence file on the root of your USB to save changes. You can do that with the following commands (assuming that your USB is named usb and is mounted under /media/user… obviously, set these to the correct paths):

 dd if=/dev/zero of=/media/user/usb/casper-rw bs=1M count=128
 yes | mkfs.ext3 /media/user/usb/casper-rw

These commands create a 128 MB persistence file. You can change the size of the persistence file in megabytes by adjusting the count parameter. All values should be a power of two (e.g 2, 4, 8, 16, 32, 64, 128 … 1024, 2056). Then, to activate persistence, when you boot your USB drive, select option 2 to go to the advanced options screen, highlight option 1 and make sure it activates, and then press 0 to boot the drive. You must repeat this process each time you wish to boot with persistence.

  1. The "instructions" were written December 23, 2016… and there are a few things I notice which are different:

    • casper exists on the USB, is casper-rw where the persistent data gets written, or should I modify the command to casper?
  2. Presuming casper-rw, this throws an error:

    $ dd if=/dev/zero of=/Volumes/UBUNTU/casper-rw bs=1M count=128
    dd: bs: illegal numeric value

…to which man dd offers no clarification regarding block size numerical values, except this (from 1994):

Where sizes are specified, a decimal, octal, or hexadecimal number of bytes
is expected.  If the number ends with a ``b'', ``k'', ``m'', ``g'', or ``w'',
the number is multiplied by 512, 1024 (1K), 1048576 (1M), 1073741824 (1G)
or the number of bytes in an integer, respectively.  Two or more numbers
may be separated by an ``x'' to indicate a product.
  1. So… I tried this on a lark:

    $ dd if=/dev/zero of=/Volumes/UBUNTU/casper-rw bs=1m count=128
    128+0 records in
    128+0 records out
    134217728 bytes transferred in 29.537984 secs (4543903 bytes/sec)

  2. …but now:

    $ yes | mkfs.ext3 /Volumes/UBUNTU/casper-rw
    -bash: mkfs.ext3: command not found

  3. …to which I invoked brew install e2fsprogs and

    $ yes | sudo $(brew –prefix e2fsprogs)/sbin/mkfs.ext3 /Volumes/UBUNTU/casper-rw
    mke2fs 1.43.4 (31-Jan-2017)
    Creating filesystem with 131072 1k blocks and 32768 inodes
    Filesystem UUID: 4217a6de-e267-4cec-b4e7-f70acb9adb0c
    Superblock backups stored on blocks:
    8193, 24577, 40961, 57345, 73729

    Allocating group tables: done
    Writing inode tables: done
    Creating journal (4096 blocks): done
    Writing superblocks and filesystem accounting information: done

  4. but still no persistence :\

  5. per the SETUP section of the instructions, I also tried dropping these files into the live USB's /efi/boot/ directory to no avail…

    • boot.efi
    • bootX64.efi

Any known exits from this rabbit hole with macOS Sierra?

Best Answer

This following method installed a persistent boot USB with Ubuntu 16.04.2 LTS on my mid 2012 2GHz i7 MacBook Air running macOS Sierra:

They offer it for like $5US, but I am a cheap S.O.B., so from their GitHub repo...

  1. Download Mac Linux USB Loader from the good folks at SevenBits.

  2. Install Cocoapods (gem install cocoapods).

  3. cd into the GitHub directory and pod install.

  4. Launch "Mac Linux USB Loader.xcworkspace" in XCode (require XCode 8+ and registration as a Developer) and run the app. in the sandbox.

  5. Insert and mount a USB drive & use Disk Utility to Erase to MS-DOS(FAT) and GUID Partition Map Master Boot Record.

  6. In the "Persistence Manager" set the allocation of storage for the persistent memory (this creates the casper-rw file).

Mac Linux USB Loader GUI
(source: sevenbits.io)

  1. In the "Create Live USB" menu, point the "Create Live USB" to the Ubuntu ISO...

Skip

  1. Deselect the "Skip the boot selection menu" option and let 'er rip!

  2. Once finished, restart and hold the alt/option button, then select the EFI boot disk. Note the boot procedure here: https://github.com/SevenBits/Mac-Linux-USB-Loader/wiki/Using-Persistence-with-Mac-Linux-USB-Loader and after the drive is selected, boot to persistent by selecting from the menu options: 2, then 1, then 0.

  3. Of note: once booted into Ubuntu, I created an admin user account, changed the desktop, then ran touch test.txt and sudo apt install valgrind to see if the changes would stick. When I logged out and logged back in, the b.g. reset to default, but the user account, text.txt file and valgrind install remained. When I rebooted, the changed desktop picture had stuck... A little funky, and it might not be a "dual boot OSX & Linux" lappy, but so far it's persistent Ubuntu on a stick!


NOTE: I reconfigured the persistent USB by formatting the USB using Master Boot Record instead of GUID. It feels like the startup is snappier. Both USB drive formats result in the console displaying the the command "applesetos" is not found. Not sure what this means. Per the maker, "The applesetos message is an oversight from me, but won’t affect the boot process." Similarly, with Master Boot Record I had to first create an admin account, and restart before system changes started taking hold.