Thursday, January 19, 2006

Installing Ubuntu to an external USB drive - A Howto

Thru painful experience and sleepless nights, I finally figure out how to install Ubuntu or any kind of Lux distro to an external USB drive.
The key idea is to modify the mini ramdisk to start USB support module during the boot sequence.

Here it is:

1) Install from CD
2) After installation, leave CD in drive and reboot with the parameter rescue
3) Pick your language and country
4) Wait for hardware detection to complete(was quite long on my system, seemed stuck for a while)
5) hostname: Ubuntu
6) Device to mount as root file system: /dev/discs/disc1/part1 (this may be different on your system. I have a boot partition in part1)
7) My system appears stuck here with a blue screen saying "Ubuntu Installer rescue mode"
my system was not stuck but I still needed to type Ctrl-AltF2

From here it is slightly different for mkinitramfs (Breezy) as opposed to mkinitrd (Hoary):
A. edit /etc/mkinitramfs/modules to add the following:
ehci-hcd
usb-storage
scsi_mod
sd_mod

(nano didn't seem to come with Breezy, so use vim)

B. make the new image file:
mkinitramfs -o /boot/initrd_usb.img /lib/modules/

so for me that was
mkinitramfs -o /boot/initrd_usb.img /lib/modules/2.6.12-9-386

You will likely need to edit your grub.conf file.

title Ubuntu Breezy (2.6.12-9-386) USB
root (hd1,6)
kernel /vmlinuz-2.6.12-9-386 root=/dev/sda1 ro quiet splash
initrd /initrd_usb.img
savedefault

Restart and enjoy the fruit

I need to add some more info:
When you can't seem to boot th external USB because of the order of your USB drive is different from machine to machine, follow this step:
I installed linux on my laptop with the root HDD of GRUB set to hd1. This may not be the case if you switch to another machine. It could be hd0 or hd2 for example.
So when you get the error message from GRUB saying that it cannot find the boot sector, "Do not panic".
All you need to do is to press the "E" key to enter editor mode in GRUB and modify the "root" parameter from (hd1,0) to something like (hdx,0) where "x" is the actuall HDD contaning the boot partition.
I hope it helps solving you all's problems with different hardware structure.
Cheers.
Doug

27 comments:

Anonymous said...

ok, thats solve the external boot problem.

I have a new issue here: the OS doesn't recognize the hardware when I move to a different machine, i.e., it works only in a hardware similar the one I previously installed ...

My dream: a live-HD, a linux installed in a external HD which the hability to recognize the hardware during the boot process - just like a live-CD...

Anonymous said...

ok, thats solve the external boot problem.

I have a new issue here: the OS doesn't recognize the hardware when I move to a different machine, i.e., it works only in a hardware similar the one I previously installed ...

My dream: a live-HD, a linux installed in a external HD which the hability to recognize the hardware during the boot process - just like a live-CD...

Doug said...

Hi there,
The key thing here is if you installed your Lux to use in x86 arch, you will have to use it with a x86 box. I install Ubuntu on my IBM Thinkpad and then I can use it with other PCs of my friends as well. Ubuntu hardware autoconfig is very effective.
What particular hardware are you having trouble with? Is it related to X config?

Anonymous said...

I tried Feather Linux recently on a USB flash drive .. Worked good, even on older PCs. It enables you to save your configuration, and it offers you a wide array of apps, specially for security folks (namely nmap, ettercap, John the Ripper, dsniff, Captive NTFS and chntpw). Additionally, it gives you the option to install packages without the remastering process. I do not remember the URL, google for it and give it a shot !!!

Anonymous said...

How about using vmware player (vmplayer) and somethig like a livehd or livecd?

Ideas on the topic

Doug said...

The problem of using a liveCD is that you don't have that much freedom to install additional packages. Problem with using VmPlayer is that it is so slow and network config is a pain.
Once you install Ubuntu on an USb external drive, you actually bring the entire OS with you. You only have to borrow hardware power to run it on the go.
I had little problem with the X config when switching between my PC and my laptop. But it can be easily resolved by running dpkg-reconfigure xserver-xorg in Ubuntu (or Debian).

Anonymous said...

"I have a new issue here: the OS doesn't recognize the hardware when I move to a different machine, i.e., it works only in a hardware similar the one I previously installed ..."

Load uhci-hcd, ohci-hcd, and ehci-hcd rather than just one and you should be good. There are 2 differing usb 1.x implementations, plus the usb 2 driver.

Doug said...

Hi all,
I just added some additional info about the boot process of GRUB. Please refresh the blog to see the change.
Feel free to Ask any question you have.
Thanks and cheers

Kaustav said...

I have a very similar issue. I have installed Ubuntu on to my external Firewire 800 IDE hard disk. The BIOS does not recognise this disk during BIOS start up. It only gets recognised once Windows has loaded. I have windows XP on my c drive and I asked Ubuntu to install on the external drive and write grub to the MBR of my C: drive where windows is. Naturally I have a problem now because when I reboot I get the usual Error 21: which means Ubuntu cannot find my external drive. I'm neither able to boot in to XP or Ubuntu now. I know that I can load the XP recovery conside and do an fdisk c: /mbr to rewrite my MBR and probably get XP bootable again, but what I want to know is this. If I use partition magic to shrink my XP partition (without screwing up my XP installation hopefuly) to free up about 60 GB of disk space, can I then create a /boot partition on my C: drive and re-install GRUB on to /boot, thus allow me to boot in to XP or Ubuntu?

Right now as it stands Ubuntu's installer gets to the partition phase and gives me the following information:

SCSI1 (0,0,0)(sda) - 250.1GB ATA Maxtor 7Y250M0
#1 primary 250.0GB nfts /media/sda1
pri/log 8.2MB FREE SPACE

SCSI3 (0,0,0)(sdb) - 400.1GB Lacie BigDisk Extreme
#1 primary 393.9GB ext3 /media/sdb1
#5 logical 6.2GB swap swap

home remodeling help said...

Remodeling and Home Improvements. YEAH.. If you are like me it seems like there is never enough time in the day.. You get home late and leave early.. then the weekends thats another story by itself. My wife has found it easier to hire somebody if you we need help with home remodeling help. She fond a great site for home remodeling help at http://reliableconstructionservices.com and wanted to share it with you.. Im glad to find help when I need it.. I hope you have great luck remodeling your home...

NuevaInvencion said...

Hi to everybody,
im looking for install Ubuntu 5.10 in a Usb external hard disk, i have to do it working in my PowerBook G4 with OS X,
can anybody help to a really starter guy?
thanks

Doug said...

Then you only need to download the PowerPC Arch version and proceed the installation normally.
Hope it helps

NuevaInvencion said...

Yea, i know that part but, it is possible to install it directly to the external drive?without partitions(i have to mantein my entire OS X)
It is possible to boot from a usb esternal drive in Mac OS?
thanks

Anonymous said...

Kaustav, you may need to mount /boot to your main drive then if it won't recognize the firewire. then, when grub starts up, it'll see all of it's necessary files. it should work then if you followed the rest of the guide

Anonymous said...

This helped me a bit. www.usbuntu.com
It's got all the solutions for Breezy, but not so good for Dapper. Well, mostly. I've got a Sandisc Cruzer mini, and it won't work for that. Mostly, I think, because it shows up as a hard drive and not a floppy. Anyone got any clues on that?

e-sabbath

Anonymous said...

Hi,

I need help.

My problem is as follows:

Machine 1: AMD K6 533mhz and more than 100MB of memory and 15GB hard disk. There is a problem, that i cant install windows on it. I tried to run ubuntu live CD, it came up well and tried to install from it and got stuck at 14% when i tried to format and install it.

What i want to do is, i want to take that hard disk and connect it to machine 2 as a external hard disk, format it and install from that machine and put the HDD to machine 1.

Will this work? I'm a noob, so please no linux commands, if so pls give step-by-step commands.

Is it possible to install it in USB-key?

Thanks and waiting for reply.

Doug said...

no, i don't think it would work that way. The main reason is:
You install linux in an external USB drive, your partition will be SCSI interface. So if you bring that hard drive and plug it into the other PC as an internal drive, linux will not be able to find the boot image as it will be IDE drive.
What I would suggest you to do is to install Ubuntu using the text interface. Do not boot from the LiveCD(or DVD) then install from X-Window. I have tried that and it failed too. Please try installing from text interface and let me know.
BTW, I have setup KUbuntu 6.06 dapper Drake successfully to my laptop Vaio SZ120P/B
It works very well, everything appears to be functional as in windows. I'll try to post a blog about the experience when i got some time.
Hope it help you.

Anonymous said...

hi doug,

thanks for your reply. Could you help me with more specific instructions as i said i'm a total noob. So i need more help please

Anonymous said...

I would really like instructions to do this from windows, if possible

Anonymous said...

Hi,

I have a Xp system. I want to erase it and install ubuntu.
However, I don't have access to a cd burner. I have a rio carbon that acts like a hard disk on usb. Is it possible to copy the iso image to a usb device and install linux from that?

Thanks,
Manish

Dean said...

I didn't have any trouble getting Ubuntu 6.06 installed and booting on my USB drive, but I cannot get sleep to work. Basically, it wakes up with the filesystem unmounted, so everything starts failing. Any ideas what to do?
Thanks.

Anonymous said...

So Dean, have any install directions on this "easy" process? It doesn't seem trivial to do this!

Anonymous said...

Call me dumb and lazy, but hasn't anyone come up with a windows executable that will create a bootable linux (any flavor) USB key?

Anonymous said...

A much easier way, use grml2hd. A few clicks, and voila, Debian on USB with all the latest software.

http://grml.org
http://article.gmane.org/gmane.comp.t2.devel/2731
http://os.newsforge.com/os/06/02/22/2221258.shtml

Ubuntu doesn't do mobile usb very well. Linux needs a third user model for this, beyond desktop/server. Grml comes closest via grml2hd onto usb disk.

Anonymous said...

About this,

"You install linux in an external USB.....plug it into.....an internal drive, linux will not be able to find the boot image..."

You might try
root=UUID=xyzabc123 for the boot parameter.
http://grml.supersized.org/archives/233-grml2hd-supports-grub-and-rootUUID.html

As long as the drive/device is somewhere on the BIOS boot search, there is a chance this can work.

Feb. 23, 2007

Anonymous said...

> My dream: a live-HD,
> external HD
> recognize the hardware
> during the boot process

I have just what you want.
http://os.newsforge.com/os/06/02/22/2221258.shtml

But beware, v1.0 with kernel 2.6.20.11 has USB bugs (from CONFIG_USB_SUSPEND=y for laptops, same bug as in Ubuntu and everywhere else, the kernel.org code itself is bad). So you should use v0.9 for now.

Marc Donovan said...

I posted my hard earned experience with putting Ubuntu on a stick. I include the fix for persistence on here.

http://www.squidoo.com/ubuntu-usb