December 6, 2013

How To Put a LiveCD/DVD To USB

Scientific Linux Forum.org

In this how to I will describe 4 methods that I use to put a livecd/dvd to USB. All of these methods will delete/destroy any data that is on your USB stick!

1. Using dd (IMMO this is the simplest, most reliable and my favorite)
2. By mounting a cd/dvd in a loop and copying the contents and installing grub
3. Using livecd-iso-to-disk (This method also works for install DVD's)
4. Using liveusb-creator

The USB stick I will be using throughout this how to has a device location of /dev/sdc . It is very important that you determine the correct location of your USB stick and change /dev/sdc to the device location of your USB stick in each of the commands in this how to. Do not just copy past the commands in this how to as that could result in the wiping/overwriting/erasing of your hard drive/s. YOU HAVE BEEN WARNED! rolleyes.gif

HOW TO DETERMINE THE DEVICE LOCATION OF YOUR USB STICK:
There are several ways to determine the device location of your USB stick. I will describe a few here. Use the method that you are comfortable with:

To determine the location of your USB stick from the command line use one of the following:
The lsblk command returns a easy to read summery of the installed drives, there size, there device location and there mount locations if mounted, etc.
CODE
lsblk


Fdisk is also able to list lots of disk info but requires root privileges:
CODE
su -c 'fdisk -l'


The command blkid will list disk info along with the UUID number.
CODE
blkid


To determine the location of your USB stick using the disk utility palimpsest:
Go Applications >> System Tools >> Disk Utility On the left hand side of the disk utility window there is a list of storage devices, locate the one that represents your USB stick and click on it. This will display the info for your USB stick on the right hand side of the disk utility window. The device location of the USB stick is displayed on the top right hand side of the disk utility window. Look for the line resembling “ Device: /dev/sdc “ . From this computer the USB device is located at /dev/sdc. Yours may be different and you will have to adjust the commands accordingly by replacing /dev/sdc with the location of your USB stick as shown by the info following the line “Device: in the disk utility window. Failing to do so may result in you wiping/overwriting/erasing your hard drive/s.



1. THE DD METHOD:
This method works on just about all the available livecd/dvds. I have found this method to be the most reliable method. I have used this method with many different distros including SL, Debian, Fedora, Centos, opensuse, Ubuntu ect.

Insert the USB stick,
determine the device location using one of the above methods
Unmount any mounted partitions that are mounted from the USB stick. (This can be achieved by right mouse clicking on the mounted partition/s on your desktop and selecting umount or opening the disk utility, clicking on your usb stick on the left hand side. Then click on the mounted partition on the right hand side and then click the unmount button. Or use the umount command from the command line)

The nest step is to wipe the USB stick with the following command (make sure to change /dev/sdc to your usb stick's device location for all of the following commands):
CODE
su -
dd if=/dev/zero of=/dev/sdc bs=512 count=1


Now to put the SL-62-i383-2012-02-16-LiveCD.iso to the usb stick. (Change path-to-iso to your real path to the iso file. ie. Something like /home/sluser/Downloads/SL-62-i383-2012-02-16-LiveCD.iso):
CODE
su -
dd if=/path-to-iso/SL-62-i383-2012-02-16-LiveCD.iso of=/dev/sdc


When the above command is finished you will have a bootable liveusb stick.


2. THE LOOP MOUNT, COPY AND INSTALL GRUB METHOD
This method allows for multiple partitions, allowing you to have 2 or more operating systems on one usb stick or use one partition for storage and one for the operating system. I am using a 4gb USB stick.

Insert the USB stick,
determine the device location using one of the above methods
Unmount any mounted partitions that are mounted from the USB stick.
Using the disk utility, format the usb stick
create a partition with the label “SL62” with the size equal to half the USB stick.
create a second partition with the label “Data” the size being the other half of the USB stick.
Mount the partition SL62 to the mount point /media/SL62 (you can just unplug and plugin the usb stick and it should mount both partitions for you in /media)
Create a mount point for the iso:
CODE
su -
mkdir /mnt/iso


Mount the livecd.iso and copy the data to the usb stick:
CODE
su -
mount -o loop /path-to-iso/ SL-62-i383-2012-02-16-LiveCD.iso /mnt/iso
cp -r /mnt/iso/* /media/SL62
unmount /mnt/iso


Install Grub on the USB stick:
CODE
su -
grub-install –root-directory=/media/SL62 /dev/sdc


Create a grub.conf file:
CODE
su -
gedit /media/SL62/boot/grub/grub.conf

and add the following stanza to the grub.conf file:
CODE
title SL62 i686
root (hd0,0)
kernel /isolinux/vmlinuz0 ro root=LABEL=SL62 rootfstype=auto liveimg
initrd /isolinux/initrd0.img


and click save and close. Unmount/eject the USB stick.

You now have a bootable usb stick with a data partition. Alternatively you could use the second partition for a second OS.



3. THE LIVECD-ISO-TO-DISK METHOD:
I use this method to put a install dvd to usb for computers without cd/dvd drives. With this method you can put livecd/dvds to usb as well.

Insert the USB stick,
determine the device location using one of the above methods
Unmount any mounted partitions that are mounted from the USB stick
CODE
su -
livecd-iso-to-disk –format –reset-mbr /path-to-iso/SL-62-i383-2012-02-16-LiveCD.iso /dev/sdc

Follow the onscreen instructions.

For more info on this method see: http://www.livecd.ethz.ch/usbdisk.html#livecd-iso-to-disk

4. THE LIVEUSB-CREATOR METHOD:
This method is also pretty easy and has built in functions to download a cd/dvd for you or use a iso that you have locally.

Insert the USB stick,
determine the device location using one of the above methods
CODE
su -
liveusb-creator –reset-mbr

Choose the target device, browse for a local iso or select one to download. Select persistent storage size if desired (this function does not always work)
Click the Create Live USB button and follow the instructions in the box.

For more info on this method see: http://www.livecd.ethz.ch/usbdisk.html https://fedorahosted.org/liveusb-creator/


Happy USB-ing cool.gif
©