How to try Ubuntu Linux without risking your Mac

By

Ubuntu running on my Macbook Pro -- beautiful.
Ubuntu running on my Macbook Pro -- beautiful.
Photo: Rob LeFebvre/Cult of Mac

Have you ever wanted to try out a different operating system on your Mac? Ever since Apple started using Intel chips in their computers, it’s been super simple to run Windows and even popular Linux distributions via Boot Camp, virtual environments like Parallels and VMWare Fusion, and the like.

The problem is that you need to use up precious system resources to run these things on your Mac. Even virtual machines take up disk space, as does running Boot Camp and partitioning your main Hard drive. What if you just want to test something out on your Mac before fully committing?

Turns out it’s fairly easy to run Linux on your Mac without using up any bit of your hard drive. Using a flash drive and some Terminal commands, you can check out a distribution like Ubuntu running right on your Mac without having to sacrifice a thing. Here’s how.

Prep your flash drive

Format the drive in Disk Utility.
Format the drive in Disk Utility.
Photo: Rob LeFebvre/Cult of Mac

The first thing you need to do is to find a spare flash drive of at least 2 Gb. I used a 4 Gb one, and you can probably use as large a drive as you want.

Plug the flash drive into your Mac and then launch Disk Utility. Once in there, click on the flash drive in the pane to the left, and then click on the Erase button at the top. If you’re using a utility like Clean My Drive 2, you’ll want to quit it before you start the Erase.

Let OS X do its thing and remount your flash drive. Now launch Terminal.

Get Ubuntu

Make sure you grab the 64-bit version.
Make sure you grab the 64-bit version.
Photo: Rob LeFebvre/Cult of Mac

Now you’ll want to download Linux. I’ve chosen Ubuntu since it’s my favorite Linux distribution, so these instructions will assume you are using the same. If not, be sure to see how the distro you choose will work on a flash drive.

Head over to Ubuntu’s web site and download the 64-bit version of the latest stable version (Ubuntu 14.04.3 LTS as of now). You can totally try the cutting-edge version (15.10 as of this post), but can’t count on it to be as stale as possible. Use it at your own (very minor) risk.

You’ll be asked to donate to Ubuntu–feel free to do so; the team is pretty great–but you can also just click the “Not now, take me to the download” button and the .iso file will come to your Mac.

Now it’s time to drop into Terminal.

Change file formats

From .iso to .img.dmg.
From .iso to .img.dmg.
Photo: Rob LeFebvre/Cult of Mac

First off, you want to change the .iso file to a more Mac-friendly .img format. Launch Terminal and type or paste the following command in.

hdiutil convert -format UDRW -o ~/path/to/target.img ~/path/to/ubuntu.iso

The ~/path/to/target.img ~/path/to/ubuntu.iso part will need to be your own path to the file you just downloaded. For example, I downloaded it to my Downloads folder, so my path is ~/Downloads/ubuntu-14.04.3-desktop-amd64.iso. The command I used, then, is:

hdiutil convert -format UDRW -o ~/Downloads/ubuntu-14.04.3-desktop-amd64.img ~/Downloads/ubuntu-14.04.3-desktop-amd64.iso

OS X may add the file extension .dmg to the file you’re creating, so you could end up with ubuntu-14.04-desktop-i386.img.dmg. Don’t worry about it, either way. If successful, Terminal will print some dots across the window and you’ll get a result message similar to the above.

Find your device node

Make sure you note the correct flash drive.
Make sure you note the correct flash drive.
Photo: Rob LeFebvre/Cult of Mac

You’ll want to make note of what OS X calls the flash drive you’re using. Run the following command in Terminal while the flash drive is plugged in still.

diskutil list

Take note of your flash drive’s identifier. Mine says /dev/disk2. You can tell it’s the flash drive by it’s size – make sure you don’t note down your main hard drive, which typically has more than 2 Gb on it. Once you have the identifier, you’ll want to unmount the flash drive in Terminal with the following command:

diskutil unmountDisk /dev/disk2 (or whatever disk_ yours is identified as)

If it works, you should see the message, “Unmount of all volumes on disk2 was successful” in Terminal.

Copy Ubuntu to your flash drive

Now you want to get the Ubuntu .img (or .dmg) files copied to the flash drive. You can’t just drag and drop, so you’ll need to run another Terminal command. You’ll need to double check you’re entering the right disk info here, as you could kill your main hard drive if you’re not careful. Here it is:

sudo dd if=/path/to/ubuntu-14.04-desktop-amd64+mac.img.dmg of=/dev/rdiskN bs=1m

Notice that /path/to/ubuntu-14.04-desktop-amd64+mac.img.dmg part? That’s where you saved the Mac-friendly version of the .iso file you downloaded back in the earlier step. You’ll want to replace it with your own special path. The last part of the command, of=/dev/rdiskN, needs a number in place of the N, which is your own disk identifier that you found above. My disk identifier is /dev/disk2 and my path to the file is /Users/myusername/Downloads/ubuntu-14.04.3-desktop-amd64.img.dmg, so my command looked like this:

sudo dd if=/Users/myusername/Downloads/ubuntu-14.04.3-desktop-amd64.img.dmg of=/dev/rdisk2 bs=1m

Once you’ve put it in and made sure it’s the correct path and disk identifier (careful!), hit Return on your keyboard, type in your admin password (you won’t see it as you type, so go slow) and be ready to wait a bit. Terminal won’t let you know what’s going on until it’s all over. When it’s done, you’ll see something like the following to let you know stuff copied:


1006+0 records in
1006+0 records out
1054867456 bytes transferred in 187.479383 secs (5626578 bytes/sec)

You may also see a dialog box saying, “The disk you inserted was not readable by this computer.” This is good, which means it’s now a Ubuntu bootable disk. Ignore the dialog for a moment and head back into Terminal. Type or past the following code:

diskutil eject /dev/disk2

The /disk2 part needs to match your flash drive identifier as above.

Now you can click Ignore on that dialog box and get ready to boot into Ubuntu Linux for the first time. You can pull the flash drive out or just leave it in your Mac.

Reboot into Linux

Now for the moment of truth. If all the steps above have gone well, all you need to do is restart your Mac, holding the Option key down as you do so. I held the power button down on my Macbook Pro until it shut off completely, then pressed the power button again while holding the Option key down.

Boot into Ubuntu with the Option key.
Boot into Ubuntu with the Option key.
Photo: Rob LeFebvre/Cult of Mac

You’ll get a screen with all the bootable drives on it. The one to the far right, named EFI boot, should be your flash drive. Click on it and begin the booting process into Ubuntu.

You’ll get a back screen and tiny text which is hard to read. Use the arrow keys on your keyboard to select “Test Ubuntu” so you can try it out without installing over your Mac OS X system. hit Return and let Ubuntu fill up your Mac’s screen. Enjoy!

Via: Tuts+

Newsletters

Daily round-ups or a weekly refresher, straight from Cult of Mac to your inbox.

  • The Weekender

    The week's best Apple news, reviews and how-tos from Cult of Mac, every Saturday morning. Our readers say: "Thank you guys for always posting cool stuff" -- Vaughn Nevins. "Very informative" -- Kenly Xavier.