Wednesday, July 16, 2014

Creating a live USB for openSUSE


               
There are multiple ways to create live USBs

In this article I will outline methods which I have tried and tested. Though this blog does have an OpenSUSE flavor, the advice mentioned below is appropriate for multiple distributions.

Things you will need :
  • A blank USB thumb drive with at least 2GB of capacity available. Please do not store any personal data on this, as all existing data will be wiped out by this process. 2GB is ideal you would not need any higher capacity than that. If you have an old one lying around that should do.
  • The OpenSuse ISO (disk image). This can  be downloaded from http://www.opensuse.org/en/ . Please note that the DVD version is not live, only the KDE/GNOME version.  

Creating a Live USB for first time users of Linux migrating from Windows:

I have tried and tested a wide variety of available options out there for creating live USBs for multiple distributions.

One very popular program that Windows users use is  Linux live usb creator (http://www.linuxliveusb.com/) . While this works well for most Linux distributions please do not use this for OpenSUSE.

On the other hand a much lesser known but open source utility which I have tested is universal-usb-installer .  It works like a charm.

The OpenSuse ISO (disk image) can  be downloaded from http://www.opensuse.org/en/  Please note that the DVD version is not live, only the KDE/Gnome version.

While both the 32 bit and the 64 bit ISO will work on a 64 bit system, it is better to get the 64 bit ISO for 64 bit systems. Most modern systems have the 64 bit architecture.

Also use the torrent download link if possible because that is more reliable than a direct download unless you have a really fast connection. ISOs are prone to corruption, being large files. But using a torrent solves that problem as error correction is performed by the protocol. (Always use the official torrent files they are trustworthy)

Once you have the ISO, install the universal-usb-installer and run through the wizard with your USB plugged in. Once it has finished you should have a bootable USB.

Creating a Live USB from linux:

This method is appropriate for people who:
1) Have already installed OpenSUSE/other linux distribution and want to create a live USB for emergencies
2) Want to switch distributions
3) Want to diagnose hardware/software issues and do troubleshooting.

In Linux I prefer to use methods which are non-distribution specific. I prefer to use utilities which are available in almost any Linux distribution.

One of the very powerful utilities available in linux is dd (disk-dump). This utility is a very powerful/dangerous utility and is to be used with great care. This utility could wipe out your whole internal disk if abused and therefore requires that you have root privileges.

Open a linux shell and type "lsblk" This is a command to list block devices. Below is sample output of the command


linux@linux:~> lsblk

NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda          8:0    0 298.1G  0 disk
├─sda1   8:5    0     2G  0 part [SWAP]
├─sda2   8:6    0  15.4G  0 part /
└─sda3   8:7    0  282.6G  0 part /home
sdb          8:16   1   3.7G  0 disk
└─sdb1   8:17   1   3.7G  0 part


In general most internal hardisks are mounted at the sda location. Look at the size column of the output to identify which block device your USB is. In the above same output you can see "sdb" has a size of 3.7GB and is 4GB USB device plugged in to my PC. It is safer to have only the USB you want to make a live USB plugged in so that it is easily recognizable.

If you look at the naming scheme you can understand that sdb1 is the partition and sdb is the disk itself. We are more interested in the disk and not the partitions.

So now that we have clearly identified the name of our USB device as viewed by the system it is time to dd in the ISO.

dd will completely erase everything on the USB thumb drive so it is important that there be no personal information whatsoever stored on the disk. There is no need to reformat the disk because the dd utility will do that for you.

Note: Because of the nature and power of the dd this utility needs root privileges (for the operation we are about to perform) to operate so please type "su" and enter into the root shell before executing the dd command. Also make sure you have the right block device; otherwise you may accidentally overwrite your internal hard disk.

the syntax is:

dd if=/path/to/iso_file.iso of=/dev/sdX bs=4M

Where sdX (X can be a,b,c,d,e,f,g,h etc. E.g. sdb,sdc) is the USB block device. bs=4M is used to speed up the write process.

So assuming the ISO is downloaded in ~/Downloads and the block device (USB) is the same as  we discovered by running the command lsblk  (i.e. sdb) the command becomes the following:

dd if=~/Downloads/openSUSE-13.1-KDE-Live-x86_64.iso of=/dev/sdb bs=4M

Notes about dd:
1) There is no space between "if" and "=" it is "if=path/to/iso" not "if = path/to/iso" Same applies for "of" and "bs"
2) It is "/dev/sdX" not "/dev/sdX1" we are concerned about the USB as a whole and not any partition.
3) As noted earlier too root priviledges are a must otherwise you will be able to write to /dev/sdb1 but not the USB itself the data will be transferred to the USB drive but the USB will be useless as it wont be bootable.

WARNING: Please double check everything is correct before executing the dd command as root one error can be a costly mistake specially double check the block device at "of=/dev/sdX" it should point to your USB thumb drive and not your internal hard disk drive or some other storage location like an external HDD. Failing to cross check may result in an accidental wipe of your entire internal hard disk.

Once you have executed the dd command, please wait patiently. dd does not display any output until the whole process is completed. You will see only a blinking cursor once the command has completed. At the end of the entire process it will tell you  the number of blocks read, the number of blocks written and the total amount of data written.

Since dd clones the ISO image directly to the USB and makes the partitions and sets the bootable flag, no other action needs to be done other than setting boot priority in your BIOS so that the USB boots first at boot time.


Additional notes:

What is a live distribution ?

Earlier on I mentioned that the DVD version of Suse is not live only the KDE/GNOME version. Then it struck me that some of you may wonder what is the real difference between a live and non-live distro; as a Windows user the concept of a live distribution does not exist.

A "live" distribution is a distribution/OS which you can try and sample without installing it on your host system. Live KDE/GNOME can be run straight off your thumb drive which you have created and can be tried out before actually installing it.

This feature also becomes very handy for troubleshooting and system repair in the event that something happens to your host PC and you cannot run the installed OS. So it is always handy to have a live linux USB lying around and at hand as it can be used to rescue important data and files in the event of a disaster depending upon its severity.