[CentOS] Simplifying making a USB install key

Mon May 3 21:33:29 UTC 2010
m.roth at 5-cent.us <m.roth at 5-cent.us>

Phil wrote:
> m.roth at 5-cent.us wrote on 04/30/2010 11:03 AM:
>> Ok, where/how do I submit this to the CentOS project?
>>
>> Here's a complete script - anyone, *please* feel free to test it, and
>> let me know if I've missed anything.
>
> Variation on your theme.  Uses ext2 and extlinux with no FAT partition.
>    Remove "-n" from sfdisk so changes are written.  Adds some error

Duh, sorry, thanks for noticing the -n.

Here's a question, though: I was under the impression that
livecd-iso-to-disk *required* FAT. Also, if I were to make it ext2, would
that still be turned into an 8+M filesystem?

> checking.:
> ----------------------------------------------------------------------------
> #!/bin/bash
> # ###################################
> # Author: mark roth
> # Date: 30 Apr. 2010
> # Purpose: to create a working, bootable CentOS install on a USB key
> #####################################
>
> PATH=/sbin:/bin:/usr/sbin:/usr/bin
>
> if [[ $# < 2 ]]; then
>     echo "usage: $0 <devname> <path/to/install.iso>"
>     echo "  Example: $0 sdb /scratch/CentOS-5.4-bin-DVD.iso"
>     exit 1
> fi
>
> if [[ ! -f /usr/bin/livecd-iso-to-disk ]]; then
>     echo "You must install livecd-tools before running this."
>     echo "See: http://projects.centos.org/trac/livecd/wiki/GetToolset"
>     exit 2
> fi
>
> if [[ -f $2 ]]; then
>      if file $2 | grep -q "ISO 9660"; then
>          echo "Using ISO image $2 ..."
>      else
>          echo "$2 is not an ISO image!"
>          exit 3
>      fi
> else
>      echo "$2 ISO image file not found."
>      exit 4
> fi
>
> if [[ $EUID -ne 0 ]]; then
>      echo "This script must be run as root."
>      exit 5
> fi
>
> if sfdisk -l /dev/$1 >& /dev/null; then
>      echo "Current partitions for /dev/$1:"
>      sfdisk -l /dev/$1
>      echo -n "Press <Enter> to continue or ^C to abort: "
>      read aline
> else
>      echo "No such device /dev/$1"
>      exit 6
> fi
>
> sfdisk -uM /dev/$1 << EOF
> ,,83,*
> ;
> ;
> ;
> EOF
>
> echo    "Remove and reinsert the USB key."
> echo    "  Use Safely Remove first if in a GUI."
> echo    "  Do not mount in GUI after reinsertion."
> echo -n "  Press <Enter> to continue: "
>
> read aline
>
> mkfs /dev/${1}1
>
> /usr/bin/livecd-iso-to-disk --reset-mbr $2 /dev/${1}1
>
> echo "USB boot media of $2 done."
>
> # end
> ----------------------------------------------------------------------------
> Unfortunately the only system I have to test on at the moment boots the
> installer OK, then asks for the installation media, but doesn't see the
> USB device when Hard Disk is selected.  With the FAT partition and
> syslinux doesn't see the device as bootable at all.

Right. That's why I did it the way I did: once you get there, you tell it
h/d, then point it to the second partition, that has all the rest of the
USB key's space on it, and the whole .iso.

         mark