<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Litter Box of a Geek &#187; Uncategorized</title>
	<atom:link href="http://litterboxofageek.com/index.php/category/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://litterboxofageek.com</link>
	<description>ramblings on technology issues and the politics affecting them</description>
	<lastBuildDate>Fri, 22 Apr 2011 23:32:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Making USB Boot Keys</title>
		<link>http://litterboxofageek.com/index.php/2009/10/makingusbbootkeys/</link>
		<comments>http://litterboxofageek.com/index.php/2009/10/makingusbbootkeys/#comments</comments>
		<pubDate>Fri, 30 Oct 2009 00:22:32 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://litterboxofageek.com/?p=10</guid>
		<description><![CDATA[Okay, so one of the things I have been doing for a long time has been keeping a set of USB keys with me that could help me out of bad situations with computers. For the longest time, I did this using the tools available to me via the SYSLINUX project and Ultimate Boot CD. [...]]]></description>
			<content:encoded><![CDATA[<p>Okay, so one of the things I have been doing for a long time has been keeping a set of USB keys with me that could help me out of bad situations with computers.  For the longest time, I did this using the tools available to me via the <a href="http://syslinux.zytor.com">SYSLINUX project</a> and <a href="http://www.ultimatebootcd.com/">Ultimate Boot CD</a>.<br />
Why Ultimate Boot CD?  Because it had most of the utilities I would want in an emergency already in a collection, so I didn&#8221;t have to assemble much beyond it.  I did not make the UBCD work from the USB drive, though, I simply reused the images they had on the disk.<br />
And why SYSLINUX?  At the time, I was also running several network servers on a campus, and I needed to have tools available over the network.  Since PXELINUX is a derivation from the SYSLINUX Project, the configurations I developed for one would typically work with little modifications to the other, and, I could keep the interface the same for the other folks who might be using them.<br />
How did this work?</p>
<ol>
<li>Format a USB drive to FAT16/FAT32, depending on what is appropriate for size (I typically go FAT32 when I cross the 1GB threshold)Note: accomplishing this step is the real determinant of your success.  A lot of people find success with HP&#8221;s <a href="http://h20000.www2.hp.com/bizsupport/TechSupport/SoftwareDescription.jsp?swItem=MTX-UNITY-I23839">USB Key Utility</a>, which works in Windows. I&#8221;ve had the most reliable success using Linux (even just a Live-CD) and cfdisk.  The key things that need to be done are to have a primary FAT/FAT32 partition, and have it marked as bootable.  Then, obviously, the disk needs to be formatted.  Disk Management in Windows will only let you format.</li>
<li><a href="http://syslinux.zytor.com/wiki/index.php/Download">Download/install the syslinux utilities</a>.  There is a set for Windows (look for win32), and you just have to have them on your machine to use them.  For Linux boxes, often your package manager can get you these files.</li>
<li>run syslinux against the drive:
<ul>
<li>Windows: syslinux.exe X: (where X is the drive letter associated with the USB key)</li>
<li>Linux: syslinux /dev/DEVICE (where DEVICE is the name of your USB key)</li>
</ul>
</li>
<li>Copy desired disk images to USB drive. Generally, you should NOT have to open these images and copy the files inside over, simply copying them to the drive is good enough.</li>
<li>Copy MEMDISK from the SYSLINUX distribution to the USB drive. This utility allows you to boot floppy and hard drive images. It will not allow you to boot CD images.</li>
<li>Create a syslinux.cfg on the root of the USB that invokes the images you copied<br />
Example:</p>
<p><code><br />
default<br />
local<br />
timeout 600<br />
prompt 0<br />
</code></p>
<p>These first couple of lines set the default options, as in, which label to boot at time out, a timeout of 600 seconds, without a prompt.</p>
<p><code><br />
label local<br />
     localboot</code></p>
<p>Next comes the localboot option, which simply causes the machine to poll the next boot device for an OS.</p>
<p><code><br />
label rescue32<br />
        kernel /sysrescd/rescuecd<br />
        append initrd=/sysrescd/initram.igz<br />
</code></p>
<p>The third section define a linux kernel (in this case, a 32bit copy of the SystemRescueCD kernel), and an initial ramdisk to use as the filesystem as it boots.</p>
<p><code><br />
LABEL dos<br />
        KERNEL syslinux/memdisk<br />
        APPEND initrd=knoppix/balder.img<br />
</code></p>
<p>Finally, the fourth section invokes a FreeDOS disk image via MEMDISK, where the boot code and kernel are loaded from the image as if it was an attached disk.  The labels are the text you type in at the prompt to select the OS desired.</li>
</ol>
<p>This was my preferred setup at one institution as I had full control of our network boot environment as well, and since that used PXELINUX (related to SYSLINUX), the configuration files would almost always work with both systems and I could provide the same look and feel.<br />
You will note the use of forward slashes &#8220;/&#8221; in the configuration, even though the filesystem is FAT based (which usually uses backslashes &#8220;\\&#8221;.  SYSLINUX knows what to do regardless, and can process files in directories as you see here.<br />
But, at this time, I use something else for my boot needs: GRUB.</p>
<h5>Why I switched to GRUB</h5>
<p>First and foremost: USB flash storage is getting quite large, and frankly, if I don&#8221;t have to carry a drive for boots and a drive for file storage, but have these integrated together, then my pockets become less cluttered.<br />
In addition, I can use references to partition UIDs for my boot options so that I can keep my data files on one partition of the drive and my boot files on another, keeping the boot options &#8220;hidden&#8221; and keeping Windows happy: Windows LOVES to ask if you would like to format a USB drive if the first partition is not FAT/FAT32/NTFS. NO!  Bad Windows! Don&#8221;t help me destroy my data.<br />
Finally, SYSLINUX restricted my ability to boot to correctly defined parts of a configuration file.  GRUB allows me to 1) correct incorrectly defined parts and 2) create my own boot options with a command line.<br />
Flexibility is the name of the game here.<br />
Okay, so how to set this up. Note, I ONLY do this on Linux, because I&#8221;m doing a lot of things here.</p>
<ol>
<li>Partition your USB drive, using fdisk/cfdisk/sfdisk so that the FIRST primary partition is FAT32 (type 0b, likely what you want since FAT16 is good up to 2GB).  As I said, this keeps Windows from being format happy.  Make this as big as you think you&#8221;ll want to have for your data needs. Make this bootable EVEN IF you do not keep your boot stuff here.</li>
<li>Create other partitions as desired.  In my case, I wanted the bootable items to be editable on any system I might have around, so, I created this as FAT16 (type 06, I wanted about 2GB). I also created an ext2 (type 83) partition for later use as a pure linux installation that i could keep on my person for my particular needs/rescue operations for my laptop.</li>
<li>Format your partitions as necessary, include label options so that you have nice names for these when you use them wherever you may:
<ul>
<li><code>mke2fs -L MYLINUXPART /dev/DEVICEPARTID</code></li>
<li><code>dosfslabel /dev/DEVICEPARTIDofFAT32 MYDATAFILES</code></li>
</ul>
</li>
<li>Jot down the UUIDs for each partition:<code>vol_id /dev/PARTITIONID</code> #repeat as necessary</li>
<li>Install GRUB onto the drive, with the files on the second partition:<code>grub</code> # enter grub shell<code>root (hd1,1)</code> # my USB was recognized as disk 2 &amp; I wanted partition 2.  GRUB counts from zero.<code>setup (hd1)</code> # install GRUB on disk 2 (my USB). Note no partition mentioned.<code>quit</code> # exit GRUB shell</li>
<li>Copy bootable files/disk images to the partition for your boot stuff.  Also, copy over the MEMDISK utility from SYSLINUX because it can still help you out <img src='http://litterboxofageek.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </li>
<li>Edit/Create /boot/grub/menu.lst on the boot file partition.Example:<code>default 0timeout 60</code><code>title Rebootreboot</code><code>title System Rescue 32 bit     uuid     857D-BA75     kernel   /sysrescd/rescuecd     append   initrd=/sysrescd/initram.igz setkmap=us root=/dev/ram0</code><code>title FreeDOS Balder     uuid     857D-BA75     kernel  /syslinux/memdisk     append initrd=/bootdisk/freedos.img</code> Default boot entry is the first one (GRUB counts from zero!). Time out at 60 seconds.  The first entry obviously reboots the machine.  The second finds the partition on the system with UUID 857D-BA75 (which would be the second on my USB drive), and then loads the SystemRescueCD 32 bit kernel and initram.igz from that partition (with some additional options).  Finally, the last entry uses MEMDISK to load out FreeDOS entry, same as before.</li>
</ol>
<p>Booting from this drive will always find the correct partition for the files (if you took care to copy the UUID correctly), and you can even create options that look for other UUIDs (like, other USB partitions, or, your already installed OS if you want to pass it special options and your bootloader on your system is messed up).  Also, unlike SYSLINUX, you don&#8221;t have to type in the title/label line; GRUB generates a arrow key navigable menu to select your OS.</p>
]]></content:encoded>
			<wfw:commentRss>http://litterboxofageek.com/index.php/2009/10/makingusbbootkeys/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

