home *** CD-ROM | disk | FTP | other *** search
/ host-198-236-40-254.wlwv.k12.or.us / host-198-236-40-254.wlwv.k12.or.us.tar / host-198-236-40-254.wlwv.k12.or.us / tsv / BareMetalInstall.iso / make_usb.sh < prev    next >
Linux/UNIX/POSIX Shell Script  |  2013-12-03  |  1KB  |  61 lines

  1. #!/bin/bash
  2. # make bootable USB flash drive. Adapted from
  3. # batch file to create bootable SLAX disk
  4. # usage: make_usb.sh /dev/sd? # (no partition)
  5. # WARNING! boot sector of the device will be OVERWRITTEN!
  6. # make_disk.sh author: Tomas M. <http://www.linux-live.org>
  7.  
  8. if [ "$1" = "" ]; then
  9.   echo "usage: $0 USB Flash drive"
  10.   echo "example: $0 /dev/sdh"
  11.   echo "Where /dev/sdh is your USB flash drive"
  12.   echo "WARNING! this command will overwrite the boot sector of whatever device you give it!"
  13.   exit 1
  14. fi
  15.  
  16. PART="$1"
  17.  
  18. if [ -f /proc/mounts ]; then
  19.   M=`grep -qw $PART /proc/mounts`
  20.   if [ $M = 0 ]; then
  21.     echo device $PART appears to be mounted
  22.     exit 1
  23.   fi
  24. fi
  25.  
  26. TMPDIR=/mnt/makedisk_mount$$
  27. echo "making VFAT filesystem on $PART"
  28. /sbin/mkfs.vfat -I $PART
  29. if [ $? -ne 0 ]; then 
  30. echo "/sbin/mkfs.vfat failed!!";exit 1; fi
  31.  
  32. echo "Mounting $PART to $TMPDIR..."
  33. mkdir -p $TMPDIR
  34. mount "$PART" $TMPDIR
  35. if [ $? -ne 0 ]; then exit 1; fi
  36.  
  37. echo "Copying files..."
  38. cp -a ./* "$TMPDIR"
  39. if [ $? -ne 0 ]; then exit 1; fi
  40. sync
  41.  
  42. echo "Setting up syslinux on $BOOT..."
  43. echo "prompt 1
  44. timeout 40
  45. default linux
  46.  
  47. label linux
  48. kernel boot/vmlinuz
  49. append max_loop=255 initrd=boot/initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=4444 root=/dev/ram0 rw enforcing=0
  50. " >$TMPDIR/syslinux.cfg
  51. syslinux $PART
  52. if [ $? -ne 0 ] 
  53. then 
  54. echo "syslinux $PART"
  55. exit 1
  56. fi
  57.  
  58. umount $TMPDIR
  59. rmdir $TMPDIR
  60.  
  61.