Difference between revisions of "Linux USB"

From Ever changing code
Jump to navigation Jump to search
Line 29: Line 29:
  mkdosfs -F 32 -I /dev/'''sdb1'''  #format device to fat32
  mkdosfs -F 32 -I /dev/'''sdb1'''  #format device to fat32


= Copy .iso on USB stick to make bootable =
= Make bootable USB from .iso image=
This works only with hybrid ISOs images. The resulting USB stick will act exactly like a liveCD/DVD. '''of=''' (output file) value needs to be a hard drive (eg. sdb) not a partition (eg. sdb1).  
 
  sudo umount /dev/sdb
== Copy image to USB ==
[http://en.wikipedia.org/wiki/Dd_%28Unix%29 DD] can copy a whole image to the desired device but only a hybrid ISOs image will boot. '''of=''' (output file) value needs pointing to USB drive (eg. sdb) not a partition (eg. sdb1).
  sudo umount /dev/'''sdb'''
  sudo dd if=image.iso of=/dev/'''sdb'''
  sudo dd if=image.iso of=/dev/'''sdb'''
  sync
  sync


;Convert .iso to hybrid image
== Convert .iso to hybrid image ==
Starting in version 3.72, ISOLINUX supports a "hybrid mode" which can be booted from either CD-ROM or from a device which BIOS considers a hard disk or ZIP disk, e.g. a USB key or similar. To enable this mode, the .iso image needs to be postprecessed with this utility. Hybrid images are special as in addition to the normal CD-based ISO9660 filesystem, they also contain a valid-looking DOS-style partition table.
Starting in version 3.72, [http://www.syslinux.org/wiki/index.php/ISOLINUX ISOLINUX] supports a "hybrid mode" which can be booted from either CD-ROM or from a device which BIOS considers a hard disk or ZIP disk, e.g. a USB key or similar. Hybrid images are special as in addition to the normal CD-based ISO9660 filesystem, they also contain a valid-looking DOS-style partition table. The '''isohybrid'' contains MBR code which has to match the version of the ISOLINUX file isolinux.bin. Therefore always use the program from the same SYSLINUX installation which .iso has been created by <tt>mkisofs, genisoimage, or xorriso</tt> and then treat it by:
Note that old .iso images prior the supported version will not work.
 
  isohybrid image.iso
apt-cache pkgnames syslinux | grep -A 1  Version        #check isolinux version
This will append necessary information to the image file therefore the check-sum will change.
  isohybrid isolinuximage.iso
 
It is worth to mention that the above operation will append necessary information to the image file therefore the check-sum will change.


= Mount .iso =
= Mount .iso =

Revision as of 11:41, 29 June 2014

Set bootable flag on USB drive

$ sudo fdisk /dev/sdb   #/dev device needs to be a hard drive(sdb) not a partition(sdb1)
Command (m for help): a
Partition number (1-4): 1
Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

$ sudo fdisk -l                                                                   
<--- output omitted ----->
Disk /dev/sdb: 2002 MB, 2002747392 bytes
255 heads, 63 sectors/track, 243 cylinders, total 3911616 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *          63     3911615     1955776+   c  W95 FAT32 (LBA)

Format USB stick

df -h                              #find your usb device
lsblk                              #another way to find your device
umount /dev/sdb1
mkfs.vfat /dev/sdb1          #create fat32
mkfs.ext3 /dev/sdb1          #create ext3
mkdosfs -F 32 -I /dev/sdb1   #format device to fat32

Make bootable USB from .iso image

Copy image to USB

DD can copy a whole image to the desired device but only a hybrid ISOs image will boot. of= (output file) value needs pointing to USB drive (eg. sdb) not a partition (eg. sdb1).

sudo umount /dev/sdb
sudo dd if=image.iso of=/dev/sdb
sync

Convert .iso to hybrid image

Starting in version 3.72, ISOLINUX supports a "hybrid mode" which can be booted from either CD-ROM or from a device which BIOS considers a hard disk or ZIP disk, e.g. a USB key or similar. Hybrid images are special as in addition to the normal CD-based ISO9660 filesystem, they also contain a valid-looking DOS-style partition table. The 'isohybrid contains MBR code which has to match the version of the ISOLINUX file isolinux.bin. Therefore always use the program from the same SYSLINUX installation which .iso has been created by mkisofs, genisoimage, or xorriso and then treat it by:

apt-cache pkgnames syslinux | grep -A 1  Version         #check isolinux version
isohybrid isolinuximage.iso

It is worth to mention that the above operation will append necessary information to the image file therefore the check-sum will change.

Mount .iso

sudo mkdir /mnt/isoimage
sudo mount -o loop -t iso9660 image.iso /mnt/isoimage/

Resources