Kjetil's Information Center: A Blog About My Projects

Slackware on a USB-stick

I present here the steps I used to get Slackware Linux installed on a USB-stick. These are the steps that worked for me, and I cannot guarantee that they will work for everyone, but it will give some pointers that may be helpful anyway. Also, I assume the reader has some familiarity with Linux already, so the steps described may be somewhat high-level. The motivation behind this was to get Slackware running on a laptop without touching the contents of the original hard drive in it.

Also note that this particular procedure ties the USB-stick to a specific machine, or at least a specific device layout. It is necessary to know (beforehand) what device identifier will be assigned for the root partition on the particular machine where the USB-stick will be used. In my case this was /dev/sdb1, so this will be used in description below.

I divided the procedure into three major steps with some sub-steps each, here we go:

1. Install Slackware the usual way, but with the USB-stick as the root file system.
1.1. Boot a host machine with the original Slackware DVD.
1.2. Insert the USB-stick into the host machine and use fdisk to create a large single Linux (0x83) partition on it.
1.3. Run the Slackware setup program and choose the newly created USB-stick partition as the target, with an ext2 file system.
1.4. Near the end of the setup process, skip the step involving installation of the LILO boot loader!

2. Install the special "extlinux" boot loader on the USB-stick.
2.1. Insert the USB-stick into a host machine running the necessary Linux software, and mount it. (In my case this was /dev/sdc1 mounted on /mnt/usb.)
2.2. Modify /etc/fstab on the USB-stick and make sure that the root filesystem uses the correct partition device on the target machine. (e.g. /dev/sdb1)
2.3. Create the file /boot/extlinux.conf on the USB-stick and input contents similar to this:

default Linux
prompt 1
timeout 100
label Linux
  kernel vmlinuz
  append root=/dev/sdb1 rootdelay=10 vga=normal vt.default_utf8=0

The crucial configuration here is the "rootdelay" parameter to the kernel!
2.4. Install the boot loader on the USB-stick with the "extlinux" command like this example: "extlinux -i /mnt/usb/boot". (Replace /mnt/usb with correct mount point if necessary.)
2.5. Unmount the USB-stick and overwrite the master boot record on it with a command like this: "cat /usr/lib/syslinux/mbr.bin > /dev/sdc". (Replace /dev/sdc with correct device if necessary.)

3. Boot the target machine with the USB-stick.
3.1. For some reason I got a lot of "ext2_lookup" error messages while booting, and I am not really sure what these where caused by. But they can be fixed by running "e2fsck -y -v /dev/sdb1" in system recovery mode on the target machine.

Topic: Configuration, by Kjetil @ 12/02-2012, Article Link