Booting Linux from a USB External Drive
I already have Fedora, Linux Mint, and openSUSE installed on my HP mini’s internal hard disk. The challenge was to install additional distros on an external drive, without have a CD/DVD drive. The external drive must be bootable, and only show the distros installed on that drive. It can be done. There were a few hurdles to overcome.
The selected Linux distros had to meet four requirements:
- The install media was a USB stick.
- They had to install to an external hard drive.
- They had to have a Live/Install edition of the distro.
- They had to support the HP mini’s Broadcom STA Wireless driver.
The whole project started because I needed examples for the on-line Basic Linux course that I am writing on Tell Me About Linux. I needed Ubuntu for its Unity desktop, and editions that used the XFCE, and LXDE desktops. The external drives used where an 8 gigabyte thumbdrive, and a 350 gigabyte WD Passport drive.
I wanted to use PCLinuxOS, but I could never get it to boot from a USB stick, and it does not work with MultiSystem. Knoppix Linux cannot be installed to other than the primary. I am so used to working with the distros that I have installed on my primary drive that I had forgotten how bad some install script are.
Just in case something went wrong, I installed Parted Magic on one USB stick, and Super Grub2 on another USB stick. I layed out the partitions on both drives in advance with Gparted on Parted Magic. Knoppix forced me to use Super Grub2, as it zeroed out the MBR on the external drive, after I had already installed two distros on the WD drive.
Since I wasn’t using the 8 gig thumbdrive, it was the guinea pig for the first install. Even though it is an old I/O Magic drive, I didn’t have a problem installing Ubuntu 11.10 on the drive, with a single ext4 partition. When I booted the the thumb drive, I discovered that os-prober had included the distos on my internal drive. While it was not a disaster, it is not what I wanted because:
- It makes no sense to boot a distro on an internal drive, from an external drive
- Kernel updates on the internal drive would require updating grub on the external drives
- The external drives may be used on other computers
With a single distro on this external drive, the Grub2 change was easy. The change only requires two commands:
sudo chmod -x /etc/grub.d/30_os-prober sudo update-grub
While Ubuntu, Xubuntu, and Lubuntu were already on my MultiSystem USB stick, I wanted to use other distros for examples of XFCE and LXDE. My first choice was PCLinuxOS XFCE. I tried to include on my MultiSystem USB stick, but MultiSystem does not support its Live/Install format. My attempts to install it on a USB stick met with failure. After considering other distros, I finally went with Xubuntu. At least, I knew it would install on an external hard disk, and that there was a Broadcom driver. The installation of Xubuntu was easy, and the required WiFi driver was already on the Live/Install media. One click, and I was connected via WiFi.
I thought Knoppix would be an interesting example of LXDE. I was able to install it onto my MultiSystem USB stick, and booted into live mode just fine. It even recognized my WiFi driver, without any intervention on my part. Alas, the install to hard disk script is terrible. The script requires a preformatted reiserfs partition, and only installs to the primary drive. Of course I didn’t know this until I tried the install. The price for this experiment was a zeroed out MBR on the external drive, and using Super Grub 2, so that I could boot Xubuntu and fix the problem. At that point, I was ready for something that I knew worked and with Lubuntu. Since Lubuntu automatically update the MBR to point to its grub.cfg, it became the new master. The problem with Xubuntu and Lubuntu is that they both appear in the Grub menu as Ubuntu. Now, I have another problem to solve.
Since their split from Mandriva, I watched the progress of the Mageia community. With the release of Mageia 1, I decided to give it a try. It wouldn’t install in MultiSystem, so I installed it on its own USB stick. While it ran fine in the live mode, it took three attempts to install it on the external drive. On the first two attempts, the install script would fail while copying files to its root directory. When I checked its /boot/grub directory, I only found an example menu.lst file, and no other files. For the fun of it, I booted to the drive again, and nothing had changed. I updated the grub.cfg file, and it found Mageia. I had to cable to Internet to install the Broadcom driver, but it works.
I now had a triple booted external drive, with slightly confusing Grub menu. Besides not being able to distinguish Xubuntu from Lubuntu, I had all the distros from the primary disk appearing in the menu. The Grub2 Title Tweaks Thread on the Ubuntu forum gave me the clues to solve both problems.
Since the MBR jumps to Lubuntu, I fixed its title with the following change to /etc/grub.d/10_linux:
if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
OS=GNU/Linux
else
OS=”Lubuntu” # Just change this line
CLASS=”–class $(echo ${GRUB_DISTRIBUTOR} | tr ‘A-Z’ ‘a-z’ | cut -d’ ‘ -f1) ${CLASS}”
fi
Since os-prober generates the menu entries for Xubunt and Mageia, I made the following changes to /etc/grub.d/30_os-prober:
for LINUX in ${LINUXPROBED} ; do
LROOT=”`echo ${LINUX} | cut -d ‘:’ -f 1`”
LBOOT=”`echo ${LINUX} | cut -d ‘:’ -f 2`”
LLABEL=”`echo ${LINUX} | cut -d ‘:’ -f 3 | tr ‘^’ ‘ ‘`”
LKERNEL=”`echo ${LINUX} | cut -d ‘:’ -f 4`”
LINITRD=”`echo ${LINUX} | cut -d ‘:’ -f 5`”
LPARAMS=”`echo ${LINUX} | cut -d ‘:’ -f 6- | tr ‘^’ ‘ ‘`”
if [ -z "${LLABEL}" ] ; then
LLABEL=”${LONGNAME}”
fi
# Change OS Label
LLABEL=”`echo ${LLABEL} | sed ‘s/Ubuntu/Xubuntu/’`“
# Ignore anything on /dev/sda
if echo ${DEVICE} | grep “sda” > /dev/null ; then
continue
fi
if [ "${LROOT}" != "${LBOOT}" ]; then
LKERNEL=”${LKERNEL#/boot}”
LINITRD=”${LINITRD#/boot}”
With these changes, I do not need to worry about hand editing grub.cfg. A new kernel in Lubuntu will automatically generate a new grub.cfg file. If Xubuntu or Mageia changes kernels, I just need to boot into Lubuntu and run update-grub to generate a new grub.cfg file.
I took a bit of work, but I can now run seven distros of Linux. Better yet, I was able to make it happen without using a CD/DVD drive.


Lubuntu is a Nice Clean Desktop — Low Cost Computing Said,
December 29, 2011 @ 5:51 pm
[...] For those who haven’t tracked the last series of posts, I am using an HP mini netbook that requires the Broadcom wireles driver. Like Xubuntu, I installed Lubuntu on a USB external hard drive from a USB stick. Since Xubuntu and Lubuntu appear as Ubuntu in the Grub menu, I had to do a little editing of the Grub2 configuration files in /etc/grub.d. I document these changes in my article Booting Linux from a USB External Drive. [...]
Sinbad Konick @Linux The Best Said,
December 31, 2011 @ 10:25 am
I want to install linux in my computer may this post help me so much. Really awesome post.