tag:blogger.com,1999:blog-4090440253338421899.post-24311947609998220232007-03-12T12:28:00.001Z2007-04-02T14:25:34.903ZHow to Create a Bootable Linux Image on a USB stick<a href="http://bp0.blogger.com/_Pesr7JTKSxs/RgJcZRDD9aI/AAAAAAAAAAs/UHaM9fqZBlU/s1600-h/usbStickforweb.png"><img id="BLOGGER_PHOTO_ID_5044696121751106978" style="CURSOR: hand" alt="" src="http://bp0.blogger.com/_Pesr7JTKSxs/RgJcZRDD9aI/AAAAAAAAAAs/UHaM9fqZBlU/s400/usbStickforweb.png" border="0" /></a><br /><div><div><br /><div><span style="font-size:100%;"><strong>Create a Server Image on a usb stick ¶ </strong><br /><br />Plug in the usb stick and use dmesg or 'tail -f /var/log/messages' to find the device name assigned.<br /><br /><strong>Wipe the Device ¶ </strong><br /></span><strong><br /></strong><span style="font-size:100%;">Zero the entire disk (or usb pen) including the partition table and boot sectors as follows:-<br />dd if=/dev/zero of=/dev/sda<br />(Use /dev/random or /dev/urandom to write random data to the disk)<br /><br /><strong>Create the Partitions ¶ </strong><br /></span><strong><br /></strong><span style="font-size:100%;">To view disk contents and create partitions type:-<br />fdisk /dev/sda<br />(cfdisk - graphical version)<br />In fdisk do the following:-<br />Type 'n' (to create a new partition)<br />Type 'p' (to make the new partition a primary partition)<br />Type '1' (to set the partition number to one)<br />Type Return (to select the default start block)<br />Type Return (to select the default end block)<br />Type 'a' (to toggle on the boot flag which makes the partition bootable)<br />Type 't' (to change the type of the partition)<br />Type 'b' (selects W95 FAT32 as the partition type)<br />Type 'w' (to write your changes to the usb stick and exit fdisk)<br />fdisk -l /dev/sda - lists the partitions on the device<br /><br /><strong>Create the Boot Sector ¶ </strong><br /></span><strong><br /></strong><span style="font-size:100%;">dd if=/usr/lib/syslinux/mbr.bin of=/dev/sda<br /><br /><strong>Create the File System ¶ </strong><br /></span><strong><br /></strong><span style="font-size:100%;">mkfs vfat /dev/sda1<br /><br /><strong>Mount the file system ¶ </strong><br /></span><strong><br /></strong><span style="font-size:100%;">mount /dev/sda1 /mnt/usbstick<br /></span><br /><strong>Make the usb pen a bootable linux drive ¶ </strong><br /></span><strong><br /></strong><span style="font-size:100%;">Create an empty file called 'livecd' to enable Gentoo to find the bootable disk.<br />touch /mnt/usbstick/livecd<br />umount /dev/sda1<br />Run syslinux on the bootable partition to place ldlinux.sys where the master boot record points:-<br />syslinux /dev/sda1<br />mount /dev/sda1 /mnt/usbstick<br />ls -l /mnt/usbstick<br />-r-xr--r-- 1 root root 9436 Mar 1 16:57 ldlinux.sys<br />-rwxr--r-- 1 root root 0 Mar 1 13:17 livecd<br />umount /dev/sda1<br /><br /></span></div><a style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; BORDER-TOP-STYLE: none; PADDING-TOP: 0px; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BORDER-BOTTOM-STYLE: none" href="http://jupiter/trac/Rezap/attachment/wiki/LinuxCheatSheet/usbStick2.png"></a></div></div>Geoffrey Allenhttp://www.blogger.com/profile/02293874448369171553noreply@blogger.com