The Need
Once you’ve created the drive, now you can boot up into your Linux Live USB. Reboot your Mac with the USB drive plugged in. Hold down the “Option/Alt” key while the computer reboots. This will launch the Startup Manager which allows the user to select a startup disk. Select your USB drive from the menu and boot. Select the created USB bootable virtual machine from the right side panel and click on Start button given in the VirtualBox menu and that’s it. If you are using MacOS or Linux like Ubuntu then from step 6 to step 9 will be the same, the only difference is the method to create a.VDMK Raw file.
I was recently using multiple machines for work (Lab machines, friend’s laptop, etc) and I needed Linux. I own a 128GB MacBook Air I could’nt install Linux on it as storage was tiny. I did have a USB 3.0 flash drive which had speeds comparable to some(not-so-fast) harddrives. It struck me that if I install Linux on my flash drive it would make my life a hell lot easier. It was later that I realised it wasn’t so straight forward mainly because of EFI boot and Mac ‘quirks’. I did a lot of googling but could’nt find anything that worked. After reading multiple sources I deduced what was the problem. Since I got it figured out I decided to write this post so that other people can benefit from it.
The problem
- Modern Macs boot using EFI and their bootloader expects boot partition to be HFS+ or APFS(High Sierra) not EXT4.
- Ubuntu installer is buggy and always installs bootloader in EFI partition of internal HDD despite being instructed to install it on EFI partition of flash drive.
- This makes the flash drive only bootable on the mac it was made on
The Solution
Step 1: Preparing live USB for installation
Download https://unetbootin.github.io/
Download your favourite Ubuntu flavor, Im using Ubuntu Mate
Burn the iso to a USB drive(not on your installation flash drive) using UNetbootin
Step 2: Boot using live installation drive
Plug both drives and press
option+power button
Choose
EFI boot
optionChoose
Try Ubuntu without Installing
Step 3: Install Linux on target flash drive
- Once into the live session, open terminal and run
ubuquity —no-bootloader
, this will start installation wizard in a mode that wont install a bootloader (Dont worry we will take care of it later)
- Keep going next untill an option comes as shown in below image. Choose
Something else
- On your target drive, create a 200MB
EFI System Partition
as the first partition (Primary) - Create a reasonable sized
ext4
partition, withmount point = '
(Primary)
- Click on
Install
- Reboot into Mac after installation finishes
Step 4: Setting up Boot manager
We will be using a super awesome 3rd party boot manager rEFInd. It can detect any operating systems installed in EFI mode and boot them.
- Download rEFInd zip and extract it
- Open Terminal and navigate to rEFInd directory
- Run
diskutil list
and find the name of your flash drive’s EFI partition. (In my case /dev/disk2s1) - Run
./refind-install --usedefault /dev/diskXXX
(replace XXX with appropriate name)
Now your flash drive is ready to boot on any Mac or EFI compatible PC. Moreover, if you ever mess up your bootloader and are unable to boot rEFInd can help you boot into your OS (if it exists :p)
Testing on Mac and PC
MacBook Air (Early 2015)
- Press
option+power
and selectEFI Boot
Centos Usb Drive
- Select your apropriate Linux to boot
Asus X550LD (PC)
- Boot from flash drive in
UEFI Mode
- Select your apropriate Linux to boot
If you did not migrate your account yet, visit https://idp-portal-info.suse.com/
There is a dedicated article about how to Create a Live USB stick using Linux and how to Create a Live USB stick using Windows
Version: 12.2+This applies to openSUSE 12.2 and above.
- 2Using Command Lines
Using Etcher
- Download the current ISO image of openSUSE Leap or Tumbleweed. The filename ends with '.iso'.
- Download, install and start Etcher
- Select the OpenSuse .iso file you just downloaded using the 'Select Image' button.
- Plug a USB drive into you computer, if it's the only drive connected to your computer, it will be automatically selected. If not, select it. Warning: All data on the drive will be destroyed. The drive can be reformatted and used as a normal drive again after the setup is finished.
- Click 'Flash'. The process of burning can last from 1 to up to 30 minutes depending on your drive and on the iso file.
- Unplug the USB drive. It now contains a bootable openSUSE installation media.
Using Command Lines
Find Block Device
Plug-in your USB stick and find what '/dev/diskN' it is mapped to by opening Terminal (where 'N' stands for 'disk0', 'disk1', 'disk2' etc). To do so, please execute:
This will print out the list of currently mapped devices/partitions. Find the USB using 'NAME' column. Then note the corresponding /dev/diskN, where 'N' is for index of your disk. For example:
In this case '/dev/disk2' is the one we want.
Install Centos On Usb
Unmount USB Stick
Unmount the USB stick
Where /dev/diskN is the one you have found in previous step as per our example it would be '/dev/disk2'.
Write ISO to USB
Centos 8 Usb Install
Write the content of the ISO file:
/dev/rdiskN is the same disk you have found previously, with an r in front. r is for raw disk, as writing to /dev/rdisk2 is much faster than writing to /dev/disk2. You will be prompted for the administrator's password.