How to Make a Bootable Linux Thumb Drive via Command Line

This is another one of those things where I always have to consult my own notes because it never sticks in my head. Part of the reason for this is the fact that I am old fashioned and still insist on doing this the non-graphical way.

Why? Because graphical tools for such things often fail or provide unpredictable results at random, or don’t offer enough of the right options.

Also, because I really like the command line. Weird, I know. But use it enough, and you might like it too. You’ve been warned.

So… Beware, there is command line ahead. Don’t be afraid of it. Sometimes that’s the only reliable way to get something done when other tools break and fail.

And yes, for the Linux gurus who might be reading this, the post you’re about to read is kind of aimed at newbies. That’s okay, because people gotta learn somehow, right?

Have your ISO handy

The easiest way to make a bootable Linux thumb drive is starting with an ISO of your favorite distro’s live disc. People keep giving me grief about not bothering with the MATE version of LMDE, since I prefer Cinnamon, so I decided to download the ISO for that as subject matter for today’s post.

lmde_download_info_highlightedA brief public service announcement

When downloading an ISO from a distro like Mint, be easy on their bandwidth, folks. Download the torrent and get the image that way, rather than just downloading via the main link in your browser. Now, back to the howto you were reading…

 

Also, always be sure to verify the ISO. Remember when the Mint site was pwned and a backdoored version of the OS was substituted? Yeah. Pay attention to this and make sure what you download is the real article, and has not been compromised.

As a side note, at 1.5 GB, yes, one could just as easily burn a DVD of this ISO using whatever DVD burning application one prefers. But that’s a waste of a DVD, and people don’t always have those lying around these days.

But thumb drives are still pretty ubiquitous, so let’s give it a try. Make sure it’s a big enough thumb drive to handle the ISO.

Have your USB thumb drive handy

Insert the target thumb drive into one of the USB ports on your PC. I probably shouldn’t have to tell you that if you have anything important on it, you need to make a backup copy of it NOW, because if you proceed past this point and don’t, that stuff will be gone. This process wipes out anything you may have on that thumb drive, and replaces it with a new filesystem and contents of the ISO in question.

Once you insert your thumb drive, open a terminal window and type the following, so you can see what your machine thinks it is:

dmesg | tail

On my laptop, that outputs something like this:

dmesg output

The only part of all of that I really care about is the part where it starts listing sdb partitions. That tells me that Linux is seeing USB devices as /dev/sdb.

What does that mean? That’s probably a topic for a different post at some point; suffice to say that in Linux, every piece of hardware is a file in /dev. If a USB drive is identified as /dev/sdb then the partitions are designated as a number after that device — /dev/sdb1, /dev/sdb2, et cetera.

For our purposes, we don’t care about any partitions on this thumb drive — we only care what the drive itself is called, and now we know.

You’re not done with that terminal yet, buddy

The next step, now that you have your ISO file and you know what your machine is calling your USB thumb drive, is to actually write the image to the drive in a way that extracts it and makes it bootable. We’re going to do this with the venerable dd utility.

Some of this may seem hard to follow at first if you’re new to this kind of thing, but bear with me… there is some order to it.

Let’s dissect how dd will work for us here.

We’re going to put the command together like this:

sudo — So that whatever you type after this runs with elevated permissions. This requires it.

dd — What we’re running…

if=/path/to/iso-file.iso — Our “input file”. This is the ISO you torrented earlier, and the full path to it.

of=/dev/sdX — Our “output file”, where “X” is whatever letter your computer is calling that thumb drive you inserted. For me, it’s /dev/sdb. Whatever you do, don’t put a number after that, or else this won’t work.

bs=1048576 — Specify the blocksize. I’m not going to go into the detail of blocksize performance, and you don’t really have to delve into it much either (though if you want to, there’s a great writeup here on the subject).

Putting it all together, using specifics from my own running of this:

sudo dd if=/home/trent/files/iso/lmde-2-201503-mate-64bit.iso of=/dev/sdb bs=1048576

Which, when I run it, does this:

dd_output

Success!

What next?

Well, if you’re already running Linux and following this process, you’ve already got a good idea what to do with this. I keep a thumb drive with LMDE on it in my bag to use as a rescue booter, and it is of course also handy to do an install on a machine that needs some Linux on it.

As a bonus, things tend to install faster from USB than they do from an optical drive anyway, and since most machines don’t even have optical drives these days, you’ll go a lot farther with a thumb drive.

And now you know your way around dd, at least in the basic sense (and most people don’t need to mess around with it more than that).

Never fear the command line! Most commands work a lot like this one, and when in doubt, consult the man page!

Advertisement

9 thoughts on “How to Make a Bootable Linux Thumb Drive via Command Line

  1. Boo! All you did was to copy the instructions from latest mint releases, and used that to fish readers.
    BEWARE! Not all distros can be put on USB like this. Besides, like author states, this wipes all contents, and besides it leaves no extra space available – so if you have a 2 GB stick, then this might be ok, but you really don’t want to waste a 8, 16 or even 32 GB stick like this!!

    Why I came here and what I expected to see was a guide that mounts the stick and the ISO file, copy files like unetbootin does, and additionally perform whatever rest is it that it does, like creating up to 4GB of persistent storage for Ubuntu based live sticks. Now that guide would’ve had some merit!!

        • Well to be quite honest, I use antiX, the distributors of which made a program to enable the writing of USB sticks a couple of years ago.

          And of course, they also support the use of Fluxbox

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s