How to create a bootable USB on mac command line.steemCreated with Sketch.

in #linux6 years ago (edited)

First off, this is more of a personal article for myself since I am always having to search for the instructions to make sure I don't royally fuck things up for myself. So instead, I wanted to make this for myself. This assumes you have working knowledge of the command line, and basic unix skills to get around in your computer.

DO NOT USE THIS METHOD IF YOU DO NOT KNOW WHAT YOU ARE DOING!! This command can wipe your entire hard drive with a simple typo of a 1 instead of a 2.

To start you'll need an .iso image of your picked linux distro and a USB. Go to your chosen linux distro website and download the latest .iso file of their operating system. In addition, download the gpg signature file to verify your download.

Then open your favorite shell, I like bash.

Verify your download with gpg
gpg --verify ~/Downloads/my-chosen-linux.iso.sig ~/Downloads/my-chosen-linux.iso

You should see a "Good Signature" in the output.

After verifying the download, insert your USB and type.
diskutil list

This will list the disks connected to the machine. One of these disks is your computer's hard drive, and you do not want to overwrite that, so be careful and double and triple check your of= argument when running the dd command later that it matches the disk number of the USB.

In my case, the USB stick was shown like this:

/dev/disk3 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *31.4 GB    disk3
   1:               Windows_NTFS Keychain                31.4 GB    disk3s1

As you can see its located at /dev/disk3. I will refer to this in the command as /dev/diskN, replace the N with your USB's disk number below. Yours may and differ, so please know what you're doing.

First unmount the USB:
diskutil unmountDisk /dev/diskN

You will be formatting the USB, so make sure if there is any data on the USB, you back it up elsewhere, because the data will be erased. Be extremely careful that you are using the disk for your USB, and not your system hard drive or boot loader. That will brick your machine if you fuck it up.

The next command is the Big Kahuna Burger. There will be no status, and the command can take up to 30 min or more. So just be patient. Triple check your output file (of=) to make sure it is indeed the USB.
dd if=~/Downloads/my-chosen-linux.iso of=/dev/rdiskN bs=1m

Putting the r before your disk will prevent caching while writing and will increase the speed for the command to finish 10 fold. Adding bs=1m tells the script to write in 1megabyte block sizes, instead of the default 512kilobyte writing block size. Both will help speed up the command.

Your output should look something like this

2276319+0 records in
2276319+0 records out
1237849260 bytes transferred in 1386.705003 secs (893109 bytes/sec)

Once over, your usb is bootable. You can restart your machine and boot into the USB and perhaps install if that is your intention.

Go ahead and eject your disk, type:
diskutil eject /dev/diskN

Reboot your machine, press the option key when boot starts, and boot into your USB.

Further if you'd like to erase and format your USB (perhaps it's only 32 bit) you can type:

diskutil eraseDisk ExFAT DiskName /dev/diskN

Coin Marketplace

STEEM 0.26
TRX 0.12
JST 0.031
BTC 61258.08
ETH 2873.80
USDT 1.00
SBD 3.56