Welcome to Eric Hameleers (Alien BOB)'s Wiki pages.

If you want to support my work, please consider a small donation:

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

slackware:usbboot [2006/09/28 15:43]
alien Created!
slackware:usbboot [2009/11/27 13:20] (current)
alien Use haX instead of hda to prevent disaster when copying/pasting
Line 1: Line 1:
 ====== Install Slackware using a bootable USB stick  ====== ====== Install Slackware using a bootable USB stick  ======
 +
 +<note>Please note that starting with Slackware 12.0 installing from USB stick or from the network (PXE boot) is supported out of the box!\\ You can find the USB bootable image file called ''usbboot.img'' in the **/usb-and-pxe-installers** directory. Also, Slackware contains modified versions of my Wiki pages in that same directory. They are called **README_USB.TXT** and **README_PXE.TXT**.\\ 
 +The remainder of this Wiki article is basically preserved here as a technical reference, but you are no longer required to follow all the instructions below. Check out the Slackware //README//s instead.
 +</note>
  
 ===== Introduction ===== ===== Introduction =====
Line 10: Line 14:
 The result of my experiments is documented in this Wiki page. I will show you two methods of using a bootable USB stick to install Slackware. The [[#boot_disk_on_a_mini_usb_image|first method]] - creating the USB equivalent of a boot/root floppy pair - is relatively easy to implement. The [[#a_complete_slackware_setup_on_usb_image|second method]] took quite a bit more research. It implements an image file containing two partitions. One (with a fat filesystem) contains the boot kernels and the root filesystem (initrd), while the other partition (fitted with a ext2 filesystem) contains packages to install. So, while the first method still needs a NFS server or another source of packages (such as a CDROM or a local hard disk partition), the second method is self-contained. If the USB stick is large enough (1 to 2 GB) you can carry the full Slackware install with you on your key chain! But even a small (256 MB) USB stick has room for the "''a''", "''ap''" and "''n''" package series, so you can install a functional network-capable and console-based Slackware environment off it. The result of my experiments is documented in this Wiki page. I will show you two methods of using a bootable USB stick to install Slackware. The [[#boot_disk_on_a_mini_usb_image|first method]] - creating the USB equivalent of a boot/root floppy pair - is relatively easy to implement. The [[#a_complete_slackware_setup_on_usb_image|second method]] took quite a bit more research. It implements an image file containing two partitions. One (with a fat filesystem) contains the boot kernels and the root filesystem (initrd), while the other partition (fitted with a ext2 filesystem) contains packages to install. So, while the first method still needs a NFS server or another source of packages (such as a CDROM or a local hard disk partition), the second method is self-contained. If the USB stick is large enough (1 to 2 GB) you can carry the full Slackware install with you on your key chain! But even a small (256 MB) USB stick has room for the "''a''", "''ap''" and "''n''" package series, so you can install a functional network-capable and console-based Slackware environment off it.
  
 +__Note:__\\ I am taking the convoluted path of first creating an image file and then copying that to a USB stick. It is easier to directly write to a USB stick and forget about the intermediate stage of creating the image file, and particularly much easier in the case of the multi-partition USB stick...\\
 +But USB Flash devices are not meant to be written an infinite amount of times, they have a limited lifetime regarding write operations. I wanted to keep my USB sticks out of harm's way, and also I should mention that writing to a file on hard disk is much faster than writing to the USB device. This sped up the development process considerably. Finally, it was a great learning experience in working with loop devices and image files.
  
 ===== Boot disk on a mini USB image ===== ===== Boot disk on a mini USB image =====
Line 48: Line 54:
  
   * Create a DOS formatted image file: <code>   * Create a DOS formatted image file: <code>
-mkfs.msdos -n USBSLACK -F 16 -C /tmp/slackboot/usbboot.img ${USBIMG)+mkfs.msdos -n USBSLACK -F 16 -C /tmp/slackboot/usbboot.img ${USBIMG}
 </code> You will notice that we use the switch "''-C''" and the variable ''${USBIMG}'' that we calculated in the previous step. With the ''mkfs.msdos'' commandline like that, we can omit the step where we would use the "''dd''" command to create the file prior to formatting it - ''mkfs.msdos'' will do that for us at no cost.\\ The command also labels the new FAT filesystem with the name //USBSLACK// (the "''-n USBSLACK''" option) but this is not required.\\ The important piece of information that is contained in the command is the fact that this FAT filesystem **must** be a FAT16 filesystem (''-F 16''). It is tempting to use FAT32 but the ''syslinux'' bootloader will fail to make the USB stick bootable if the filesystem is not FAT16.\\ \\ The file ''/tmp/slackboot/usbboot.img'' will eventually be the file to copy to the USB stick. </code> You will notice that we use the switch "''-C''" and the variable ''${USBIMG}'' that we calculated in the previous step. With the ''mkfs.msdos'' commandline like that, we can omit the step where we would use the "''dd''" command to create the file prior to formatting it - ''mkfs.msdos'' will do that for us at no cost.\\ The command also labels the new FAT filesystem with the name //USBSLACK// (the "''-n USBSLACK''" option) but this is not required.\\ The important piece of information that is contained in the command is the fact that this FAT filesystem **must** be a FAT16 filesystem (''-F 16''). It is tempting to use FAT32 but the ''syslinux'' bootloader will fail to make the USB stick bootable if the filesystem is not FAT16.\\ \\ The file ''/tmp/slackboot/usbboot.img'' will eventually be the file to copy to the USB stick.
  
Line 72: Line 78:
 umount /tmp/slackboot/usb umount /tmp/slackboot/usb
 syslinux -s /tmp/slackboot/usbboot.img syslinux -s /tmp/slackboot/usbboot.img
-</code> __Note:__\\ Open the file ''~/.mtoolsrc'' in an editor and add the line "mtools_skip_check=1" in case the ''syslinux'' command gives an error.+</code> This creates the file "''ldlinux.sys''" in the root of the partition; it contains the bootloader code. If you ever change the content of the ''syslinux.cfg'' file, you will have to run the command ''syslinux -s /tmp/slackboot/usbboot.img'' again, to update the bootloader. \\ \\ __Note:__\\ Open the file ''~/.mtoolsrc'' in an editor and add the line "mtools_skip_check=1" in case the ''syslinux'' command gives an error.
  
   * This concludes the steps needed to create our image file! All that's left is to copy the file to a USB stick: <code>   * This concludes the steps needed to create our image file! All that's left is to copy the file to a USB stick: <code>
Line 85: Line 91:
 <note>your computer BIOS must support booting from "USB HDD"</note> <note>your computer BIOS must support booting from "USB HDD"</note>
  
-Plug the stick into your computer's USB slot, and boot it up. Make sure you select "//boot from USB-HDD//" - how you  do this is very dependent on the type of computer you have.\\+Plug the stick into your computer's USB slot, and boot it up. Make sure you select "//boot from USB-HDD//" - how you should do this depends on the type of computer you have.\\
 Many computers will display a message during the initial stages of the booting that says something like "''Press [F12] for a boot device list''". Many computers will display a message during the initial stages of the booting that says something like "''Press [F12] for a boot device list''".
  
-The Slackware installer will start just like when you had booted from a CDROM Log in as "root". Start the install by partitioning your hard drive as usual, and running ''setup''.\\+The Slackware installer will start just like when you had booted from a CDROMLog in as "root". Start the install by partitioning your hard drive as usual, and running ''setup''.\\
 If you want to install from a NFS server, you should run the commands ''pcmcia'' (if your network card is PCMCIA) and/or ''network'' prior to running ''setup'' in order to load a driver for your network card. If you want to install from a NFS server, you should run the commands ''pcmcia'' (if your network card is PCMCIA) and/or ''network'' prior to running ''setup'' in order to load a driver for your network card.
  
-If you want to install Slackware using a local hard disk partition in case  you copied the Slackware tree there in advance, that is also an option. It would not make much sense to opt for the third install method "use a CDROM" since we just abandoned the use of a CDROM medium :-)+If you want to install Slackware using a local hard disk partition in case you copied the Slackware tree there in advance, that is also an option. It would not make much sense to opt for the third install method "use a CDROM" (or DVD) since we just abandoned the use of a CDROM medium :-) \\ On the other hand, I once dealt with an IBM server that was not able to boot off a DVD containing a distro that shall remain unnamed, but was able to boot from a USB stick. Remember, Slackware 11.0 is available on DVD, too! Many older servers are not equipped with a DVD drive, so a bootable USB stick will save the day.
  
 <note tip> <note tip>
Line 107: Line 113:
  Partition 1 does not end on cylinder boundary.  Partition 1 does not end on cylinder boundary.
 </code> ... and so on, for partitions 2, 3 and 4 as well.\\  </code> ... and so on, for partitions 2, 3 and 4 as well.\\ 
-This is actually harmless. The usbboot.img uses the "raw" device, it did not create partitions at all. Fdisk reads the information in the first sector and incorrectly interprets that.+This is actually harmless. The usbboot.img uses the "raw" device, it did not create partitions at all. Fdisk reads the information in the first sector and incorrectly interprets that as a screwed-up partition table. Just ignore the warnings.
 </note> </note>
  
Line 122: Line 128:
 We will end up with a single file that we can transfer to a USB stick. We will end up with a single file that we can transfer to a USB stick.
  
-It all depends on the size of your USB stick whether you can copy the packages from the Slackware CDROMs onto it (so you can install KDE and a 2.6 kernel) or add only the basic packages to the image (take at least the "a" "ap" and "n" package sets). For all the packages that make a full Slackware install you'll need more than 1GB USB stick... +It all depends on the size of your USB stick whether you can copy all packages from the Slackware CDROMs onto it (so you can install KDE and a 2.6 kernel) or add only the basic packages to the image (take at least the "a" "ap" and "n" package sets). To contain all the packages that make a full Slackware install you'll need a USB stick that is larger than 1GB ... 
  
-The reason for needing two partitions is that our bootloader //syslinux// requires the filesystem on which it is installed to be FAT16. This limits the filesystem to 2 GB and I wanted to be able to use the new 4 GB USB pen drives that are on the market. So, I kept the FAT partition to a minimum and crammed all the packages and other stuff into a ext2 partition.+The reason for needing two partitions is that our bootloader //syslinux// requires the filesystem on which it is installed to be **FAT16**. This limits the filesystem to 2 GB and I wanted to be able to use the new 4 GB USB pen drives that are on the market. So, I kept the FAT partition to a minimum and crammed all the packages and other stuff into a ext2 partition.
  
  
 FIXME __This part remains to be written__ FIXME FIXME __This part remains to be written__ FIXME
- 
- 
  
 ===== Restoring a USB stick to its original state ===== ===== Restoring a USB stick to its original state =====
Line 137: Line 141:
  
 <note warning> <note warning>
-Take care about which device actually is your USB stick !!! The next command will render all data on ''/dev/sda'' inaccessible !!!+Take care about which device actually is your USB stick !!! The next command will render all present data on ''/dev/sdX'' inaccessible by deleting it's partition table!!!
 </note> </note>
  
   * First, wipe the bootsector of the USB stick: <code>   * First, wipe the bootsector of the USB stick: <code>
-dd if=/dev/zero of=/dev/sda bs=512 count=1+dd if=/dev/zero of=/dev/sdX bs=512 count=1
 </code> </code>
  
-  * Then, create a new FAT32 partition on the stick and write a FAT32 filesystem on it (vfat or //type 'b'// in fdisk terminology): <code> +  * Then, create a new FAT16 partition (//type '6'// in fdisk terminology) on the stick and write a FAT32 (vfat) filesystem on it: <code> 
-fdisk /dev/sda <<EOF+fdisk /dev/sdX <<EOF
 n n
 p p
Line 152: Line 156:
  
 t t
-b+6
 w w
 EOF EOF
-mkdosfs -F32 /dev/sda1 +mkdosfs -F32 /dev/sdX1 
-</code> The 10 lines starting with "''fdisk /dev/sda <<EOF''" and ending with the single word "''EOF''" is actually one command spread over ten lines, //including// the two empty lines. This format is called a [[wp>heredoc|here-document]]. It allows us to use a command which expects interactive input non-interactively. If you're uncomfortable with it you can just run <code>fdisk /dev/sda</code> and create a partition interactively :-)+</code> The 10 lines starting with "''fdisk /dev/sdX <<EOF''" and ending with the single word "''EOF''" are actually one single command spread over ten lines, //including// the two empty lines. This format is called a [[wp>heredoc|here-document]]. It allows us to use a command which expects interactive input (fdisk) non-interactively, in a shell script for instance. If you're uncomfortable with it you can just run <code>fdisk /dev/sdX</code> and create a partition interactively :-)
  

Personal Tools
sponsoring