When you are taking your first steps or playing around with Slackware, you might not want to risk hosing your entire system. I was able
to install and run some distributions, ie Fedora and Ubuntu, direct from a USB drive without messing around. This didn't work on Slack,
and the system failed to boot after the initial install, with a VFS Kernel Panic.
This is how to set the system up to boot from an external usb drive using an initrd, which loads the correct usb drivers in time for
the root filesystem to get mounted.
1. Partition and install Slack to your USB drive, noting they appear as SCSI (/sdx) devices in Linux.
My drive showed as /dev/sda, an
80 gb drive partitioned as follows: /dev/sda1 - 10gb for /, /dev/sda2 - 50gb for /home, and finally /dev/sda3 - set to appropriate swap
size.
2. Boot to the Slack install cd, and press through until invited to type 'setup' to enter setup, and you find yourself sitting at
the root # command prompt.
3. Mount the USB drive partitions - this may vary for your partition configuration, with the setup mentioned before, I run the below:
mount /dev/sda1 /mnt [Mounting the root partition here]
mount /dev/sda2 /mnt/home [Here we mount the home partition...]
swapon /dev/sda3 [Setting up Swap]
mount -o bind /proc /mnt/proc [And proc]
Now we need to chroot into the system installed on the usb drive.
chroot /mnt /bin/bash
4. Run uname -r, and record the kernel version - At the time of writing I have `2.6.21.5-smp`.
5. You now need to create the first version of your initrd, which will load the usb and filesystem modules enabling booting from
the generic kernel (which does not have these built-in as standard). See the readme in /boot for further details and a few examples.
The following assumes you use the ext3 filesystem, and your root mount is /dev/sda1:
mkinitrd -c -k 2.6.21.5-smp -m usbcore:ehci-hcd:uhci-hcd:ohci-hcd:usb-storage:ext3 -f ext3 -r /dev/sda1
-k specifies the kernel version we obtained above, -m the modules we want to load at boottime (swap out ext3 if needed), -f the
filesystem (again, swap out if needed), and -r specifies the location of the root.
6. We now have an initrd in /boot/initrd.gz, but you will find your system still fails to load. Oh no! This is due to the fact the
system tries to mount and boot from USB before the modules have complete initialising - to fix this-, edit the file
/boot/initrd-tree/init.
Find the line '# Initialize LVM:' in it, and above this, but after the previous block, add these lines:
echo "Sleeping to allow USB Init."
sleep 10
7. Now run 'mkinitrd' with no arguments, to regenerate the initrd file with this change included.
8. All that is left now is to modify your /etc/lilo.conf (my preferred editor is nano), and add the line
'initrd=/boot/initrd.gz'
to the boot line of your new
slackware install.
9. Commit these changes - save the file, run 'lilo -v -t', check for *errors*, then run 'lilo -v' to finalise.
10. The system *should* now boot.
An important note is to ensure that your system is configured in the BIOS to boot from your usb hard-disk, however doing that is
beyond the scope of this article. I had to leave 'hard disk' as my first boot device, and modified a seperate 'Hard Disks' menu
inside of the BIOS options, and put the USB drive first.
An alternative to making an initrd is to compile usb, ext3, etc support directly into your kernel. This is covered very well elsewhere
on the internet, so I won't be covering it here.
More information: See /boot/README.initrd |