Booting Slackware Linux From an External USB Without BIOS USB Boot Support
August 8th, 2007 Pekk Posted in Linux |
The Prelude
Today’s computer article is about my Linux escapade at work. Soon I will be giving up my Macbook Pro for a few days for repairs (sad, I know). So I am in desperate need of a backup workstation for my programming needs. And I need unix. So here comes Linux to the rescue! … I hope.
Here’s the situation at hand: I have an external USB drive with Slackware 11 installed. The goal here is to boot this piece on my machine at home, which does not have a bios supportive for booting from a USB device directly. (If I could just set my bios to boot the USB device first, it will go straight to that drive, load my Linux bootloader, LILO, and let me in nice and easy… But this is computers we’re talking about. Nothing is ever easy).
Here I’ve a guide which, without building any custom kernels or boot CDs or anything, will aid you through booting to Linux on an external USB drive.
Before we begin, to make sure you know exactly what I’m talking about, here’s a list of things we’ll need to get the show on the road:
- Slackware 11 install CD/DVD or Rescue Disk/Disc
- An external USB drive with Slackware Linux installed. (Presumably this will work with any distro but I tested this with a Slack11 DVD and a Slack11 install on my drive)
- Patience. At least half a cup.
And now for the magic:
Booting Your External Drive Without BIOS Support
- Insert your Slackware CD/DVD into your drive. Your bios may not support booting to the USB device directly, but Lord have mercy on your soul if you can’t even set it to boot from a CD/DVD drive.
- The Slackware CD/DVD should take over your screen with lots of text when you put up, and it will ask you to pick a kernel. Originally, I thought I had to use the huge26.s kernel to make this work, but as it turns out I tested it later on with the default (sata.i) and it works just fine. So if you don’t have any preference, we’ll be using that kernel for now. So type sata.i or just hit enter and it will default to sata.i.
- Your computer should start loading the kernel now. After a bit of work, the CD will tell you that you can now start your Slackware install and hit enter to log in. Hit Enter, and then hit Enter again at the slackware login: prompt. This CD has no root password so you will default to root with full access… To nothing! Alright!!! Well, as it turns out, this is actually very useful for getting into your computer when you get stuck, that’s why it’s called a rescue cd!
- Now you are brought to a prompt, if you’re using the Slackware install disc it will tell you to setup your partitions and stuff. Now that we’ve got a kernel and a bash shell we’re making pretty good business here… All that’s left is to mount our external USB device and change the root (/) to the mount destination. The problem I had here was making my computer detect my USB drive! Typically these are listed as scsi (so sd(letter)(number)… i.e., sda1). I checked my dmesg and saw that my computer was detecting my “USB Mass Storage” and assigning it to sda2 and sda5 (sda2 being the main partition and sda5 being my swap). I tried the following:
mount /dev/sda2 /mnt
but it did not work. After fiddling with it for a bit I’ve found a pretty reliable trick which was the key to my success. If you’re having this same problem try issuing the following command:
fdisk /dev/sda
A message displays. “Unable to open /dev/sda”
type the same command again and it should give you the fdisk prompt:
Command (m for help):
[enter q to quit]
Command (m for help): q
root@slackware:/#
The same trick works with cfdisk as well. I’m not sure why. I guess invoking these programs causes the computer to probe for devices, so when you invoke it the second time (c)fdisk finds the device… - Now that we magically woke our external device up, let’s mount it. If you’re not sure of he device name to mount, open cfdisk and it will show you graphically the device names (i.e., sda2, sda5) and how big each partition is. This should make it relatively easy for you. Mine was sda2, so we’ll continue by mounting /dev/sda2 to /mnt:
mount /dev/sda2 /mnt - Finish the deed by chrooting your /mnt directory:
chroot /mnt - And to top it off and make sure we have everything set right:
source /etc/profile
and, ironically at this point I receive a random message from slackware:
Piece of cake!
-- G.S. Koblas
That’s pretty much all there is to it. There are, however, some drawbacks. I’ve been unable to find a way to connect to the internet, for one. More than likely this has something to do with the kernel. Before chrooting I was able to load my ethernet module via modprobe (modprobe tulip for me) but once I performed my chroot that connection was lost. I tested this connection by sending a friendly ping to google.com. The address was resolved and I received data from them so I know I had a connection.
There is an alternative to this method, which I have yet to explore and requires a bit more work: Creating a custom kernel and putting it on a custom slack boot cd, or you could also make a custom bootable Slax live CD, where you could leave all of your necessary installed files and configuration on the boot CD and just mount your external drive as storage space.
Much thanks to Nikolay Darakev and Dan O’Brien who both helped me getting this running. I’ve tested this method on two machines so it seems pretty reliable.
August 10th, 2007 at 10:01 am
>> If you’re having this same problem try issuing the following command:
>> fdisk /dev/sda
>> A message displays. “Unable to open /dev/sdaâ€
As it turns out I’ve just discovered that typing this only once fixes the problem as well. So assuming you want to cfdisk to install your Slackware:
fdisk /dev/sda
cfdisk /dev/sda
or if you want to mount:
fdisk /dev/sda
mount /dev/sda2 /mnt
Also I’ve noticed that when I mount and chroot some commands may be unavailable (such as ps) when I tried to use ps though, it gave me an error. It looked something like this:
Error: Do this: mount -t proc none /proc
Best error EVER.
So type that after you chroot at some point, this will make it so that you can use a lot of commands like ps and ifconfig. And anything else that uses /proc I guess.
September 24th, 2007 at 10:55 pm
okay, when mounting proc manually like I proposed above,
I noticed that you will get problems if you exit out to
the top level prompt and try to unmount the /mnt directory,
you’ll get problems saying the device is in use, this is
because you forgot to umount proc.
So don’t forget to unmount ANY devices you mount before
exiting out to the top level.
Don’t forget you can always chroot back to /mnt if you are
getting the device in use errors, and then unmount them.