1.31.2012

How to create a Linux LiveUSB without Unetbootin

If you've been introduced to Linux by a hardcore fan, or just been adventuring yourself for a while now, chances are you've ran into a piece of software called UNetbootIn. It stands for "Universal Netboot Installer," but what it really does is create bootable USB drives from Linux CD images (.iso). It's a great program. Geza Kovacs (the developer) had a great idea in making it, and I personally still use it quite a lot. However, as with any program you can write, it has its own limitations. And today I will show you how to work around them, using a UNIX program called "dd."

To start off, these are the situations in which Unetbootin won't work (at least not straight away), so you'd have to find an alternative;

  1. Dealing with an .img file instead of an ISO.
  2. Dealing with an image that is not Linux (BSD, Windows Boot disk etc)
  3. Dealing with an unlisted distribution image, or one that reportedly has failed to produce a bootable USB, and the devs are not caring to fix it.
Number 3 has by far the highest occurrence rate. It's not uncommon to find a forum thread or bug file about Unetbootin being unable to produce a LiveCD of  distro X or Y. Most of the time the fix is to get the latest version of the program, but knowing which PPA to add in Ubuntu or compiling from source may be burdensome, or may not even fix it at all. So the other solution is to use "dd."

"dd" is a UNIX program specialized in the copying of raw data. What this means is that it won't do the old "copy and paste," but rather things like extract data from a packaged format and sort it out into a medium, or the other way around. And this is exactly what we need to do to "burn" an image. Before we begin, though, I'd like to put out a little disclaimer:

I HOLD NO RESPONSIBILITY WHATSOEVER FOR ANY DAMAGE YOU MAY CAUSE TO YOUR COMPUTER IN THIS PROCESS.
(even though I don't think you will)
YOU ARE DOING THIS AT YOUR OWN RISK.

Since dd is ubiquitous to Unix-like systems, the first thing you need is an expendable USB drive/SD card of size large enough to fit the distro you want. Mount it and format it (since you will lose all the data anyway, doing a manual format double checks that you're not throwing away anything important). With that done, it's time for a little command-line action. With the paths to your ISO and USB device in mind, enter the following:

sudo dd if=/path/to/your/ISO of=/your/usb/device bs=8M

External devices will almost always be labeled /dev/sdb. Not sure about the path to your device? Don't worry. Given that the USB is mounted, type in:

ls -l /dev/disk/by-id/usb*

And read out the output. Most likely you will have something like this...


See the sdb and sdb1 highlighted? The label sdb indicates the USB, while sdb1 is a partition within it. For dd, you want to use /dev/sdb AND NOT /dev/sdb1 for the path. So, for my case, the command is:

sudo dd if=/home/vman/whatevertheisois.iso of=/dev/sdb bs=8M

By the way, if you're wondering what is the "bs," it stands for "Byte Size." The size of the "sectors" that will be burned into your USB. 8M coincides with the sector size of optical media, so we use it to pretend the USB is a CD. This command also requires Root privileges because it tampers with external devices, and there is a possibility of destroying your own hard drive if you type the wrong path to the USB (hence the disclaimer). But the listing above will bring in a surefire way of identifying it.

Once you've entered the command, you won't notice anything happening in the terminal. This is a disadvantage of using it instead of unetbootin. The cursor will just sit there blinking, and until the copying is finished, you won't know how far are you. Once the command is done, your USB is as bootable as a CD. Enjoy carrying a portable OS in your pocket!

Jan 31st by K. Zimmermann

13 comments:

  1. Using the pv command will allow you to have a status bar.
    Man pv.

    ReplyDelete
  2. pv -tpreb /home/vman/whatevertheisois.iso | sudo dd of=/dev/sdX bs=8M

    ReplyDelete
  3. You may use 'Ctrl-T' during 'dd' execution. It will output current status.

    ReplyDelete
  4. Using pv command in this specific case is total mess!

    ReplyDelete
  5. unetbootin has the ability to place 'persistent space' on a LiveUSB. That is, a LiveUSB with persistance will give the LiveOS the ability to store some files which will be there again if you restart. How do I do this without using unetbootin?

    ReplyDelete
  6. You could do this as part of gparted afterwards, however you would need to get the live CD to mount the /dev/sdb2/ as ~/home/ (For pocket Operating Systems).

    ReplyDelete
    Replies
    1. Sorry I meant ~/

      not ~/home

      as that would be /home/user/home

      Delete