A much easier way to install Ubuntu on a USB device (Stick or HD)!
There had to be a better way.
Together with a colleague of mine, I decided to figure out whether there could be an easier way to install Ubuntu on a USB device.
I found a way of doing it in a much simpler way... without creating the separate partition to store the LiveCD:
A couple of assumptions to take into account when going through this manual:
- My computer (Dell D820 laptop) has 1 internal disk, devided into 3 partitions (dell utility -- windows -- Ubuntu 8.04)
- Just one USB device (in my case a 250GB harddisk
- BIOS configured to enable boot from internal HDD, CD/DVD and USB Storage device
(I didn't take screenshots, so I will be explaining a lot about the screens... It looks like a lot of work, but trust me: it is not, and it really is easy:-)
- Insert the LiveCD into your computer;
- Connect your USB device;
- Boot your computer from the liveCD;
- Once Ubuntu is started, go to System -- Administration -- Partition Manager
This will open the Partion Editor. Select your USB device and delete all partitions on it. Click Apply and exit Partition Editor;
- Double Click the Install Icon. This will start the Installer;
- The Welcome Screen is shown. Choose your language and click Forward;
- Select your Time Zone and click Forward;
- Choose your Keyboard Layout and click Forward;
- The partitioner will be started, and you will be given the choice where to install Ubuntu. Choose Guided -- Use entire disk, selecting your USB device (this will most likely be /dev/sdb, don't choose /dev/sdb1!);
- The next sceen you will give your username/password information. Provide the required info and hit Forward;
- If there is anything to migrate from other installations on your computer (most likely not), do whatever you want, and click Forward;
- The next screen is important -- It is titled: "Ready to Install". Be careful here: before clicking on Forward, make sure you click on the "Advanced" Button!
This will open a new screen, giving you the option whether and where to install the bootloader. Select your USB device (in my case it was /dev/sdb) to install the bootloader to;
Exit this screen and click on Forward in the "Ready to Install" screen, which will be shown;
- The installation will be started now. Just be patient, grab a cup of coffee and come back 15 minutes later, your installation will be more or less finished by then.
So you have finished the installation. However, when you will be restarting your system from USB, you will find out that the partition you just installed Ubuntu to cannot be mounted.
Here comes the trick:
- Once the installation is finished, reboot your PC (this is the safest) from your LiveCD, with your USB device connected;
- Once started, open up a terminal (Applications -- Accessories -- Terminal);
- In the Terminal, type: sudo -i (which will give you root privileges, so be careful from now on!);
- Change directories to /media/disk/boot/grub -- This will take you to the "/boot/grub" directory on the USB device;
- open menu.lst with vi (make a backup first!)
- Go to line 130 (or somewhere in that area).
You will find a line looking like:
## ## End Default options ##
And underneath it you will find three entries pointing to your Ubuntu you just installed:
title Ubuntu 8.04, kernel 2.6.24-16-generic
(the above 5 lines repeat 3 times with slight differences)
- The magic trick is to change (hd1,0) into (hd0,0) for all these three entries.
Why? Booting from USB device makes your USB device hd0, in stead of hd1 at time of installation.
- Search for the line starting with "# groot=(hd1,0)" and change (hd1,0) to (hd0,0) -- Don't delete the # at te beginning of this line!
- Once you did this, you can optionally remove the remaining of the file
(everything underneath ### END DEBIAN AUTOMATIC KERNELS LIST);
- Save the file, make sure it is owned by root:ubuntu (chgrp ubuntu menu.* will do)
- Edit device.map (in the same directory) and change the mapping of hd0 to /dev/sdb.
- Reboot your machine, from USB, choose the Ubuntu installation from the Boot Loader and you are one happy person.
I guess that is it. If I missed something, please comment.
Great guide – I’ve searched the net high and low yours has proven to be the easiest to follow and understand. Simply put if you follow the directions given by the author this will work fine!
It works well as a stand alone Ubuntu desktop , however it is best to slim it down using either Gnome or KDE Desktop to save unecessary download updates. When Using the Ubuntu live CD ISO installer, mine was 8.04, do not tick any boxes for the transfer of other drives settings/ documents, it will then be independent of any computer system. It will update or upgrade as normal Ubuntu desktop albeit of course a little slower than a the normal hard drive installation.” To ease wear on the USB key in Terminal and avoid unnecessary writes ,edit the your /etc/fstab file , sudo gedit /etc/fstab edit the swap file by deleting it and type in the following :
tmpfs /tmp tmpfs nosuid,nodev 0 0″
Make a backup copy of the original fstab first to remind you what was there to begin with!
“tmpfs , otherwise known as as a RAM disc , should if you have enough RAM be able to do without swap entirely,which neatly sidesteps this problem .” Thanks to Linux Format Jan 09 page 42 for this helpful tweak to installing USB.
As an UBIE, it works out of the box, if you reduce the screen
resolution to the minimum then it loads on laptops no problems.
You may need to tweak your BIOS to allow a USB drive to boot.If you have problems with a particular PC, Google that OEM to see how other users have produced a work round for your PC.
I’m taking my Ubuntu USB with all systems go, to Santiago,Falkland Islands, New Zealand and Singapore for 6weeks. it will be a breeze to send anything via the net with this system!
Thank you Arnoud Roth, brilliant, I have tried 6 or 7 Distros but the permanent file partition did not always work and often crashed and had left creating USB distro for three months. This one works, it is a slimmed version of the hard CD drive ISO, using synaptic Package Manager to permanently remove unwanted packages. Regards Bill Cressey
I have just noticed that my quotes for Linux Format end on the line of the fstab insert , it needs to be deleted to avoid any problems.
Just to let you know I used these instructions to install eeebuntu (NBR) on a usb hard drive attached to an Aspire One. It just worked, straight out of the box. Didn’t even need the magic tricks from steps 7 to 12 at the end. I’ve changed the boot order to boot off the USB disk first. So now, if I have the USB disk plugged in, it gives me a menu to boot either eeebuntu or the standard linpus; if I don’t have it plugged in, it just boots normally. Great!
Same as martin benson, i installed easy peasy (eeebuntu) on a packerd bell easynote PB47R01086. Its based on ubuntu 8.10 (other than what was used in this tutorial) and doesnt use the root reference. It just has a UUID=r2329jf92-4f42f-g35gr-34tg5-4g4324ffdg name for the harddisk.
I get the following:
title easy peasy 1.0, kernel 2.6.27-8-eeepc
kernel /boot/vmlinuz-2.6.27-8-eeepc root=UUID=r2329jf92-4f42f-g35gr-34tg5-4g4324ffdg RO quiet single
im testing it out right now, i already installed it on my eeepc900 (where im typing this from) and i like it.
I followed everything quite good untill the 6th step. I don’t have a “root” line.
I am using Ubuntu 8.10 btw.
Dude! you are a freakin genius. I’ve been trying to figure this out for two days. I’ve tried evrybody on the internets hairbrained ideas. I knew I just needed to edit the grub config files. I just couldnt figure out exactly how. Now I can run Ubuntu 9.04 on my work laptop and bypass all their encryption, monitoring and protection bs, without changing one bit on the hard drive. Thanks
well tried on 2 keys a 16Gb and a 4Gb kinsgston traveller , 16G crashes in the setup (same on 2 diff keys of the same 16Gb model ) but is flawless on the 4Gb , not even a grub mod needed , setup was done with jaunty and intrepid
I installed Kubuntu Jaunty yesterday on a 320GB USB HD. In accordance with suggestions from other guides found on-line, before starting I physically removed the internal HD, in order not to risk anything on the existing Windows XP (that I can’t touch).
I just followed the normal installation steps as per your guide but in step 9 I deviated from your suggestion and selected manual partition (the disk was seen as /dev/sda). I partitioned in the following way:
A) 30GB ext4 for “/”
B) 160 GB ext4 for “/home” (I find very useful a separate /home partition)
C) 2GB for swap
D) 120 GB Fat32.
Please note that I went through step12 but the installer by itself proposed already Grub on /dev/sda. Very smart !!
Once the installation was complete I rebooted and all was perfect. No need of any manual editing of any file (no tricks necessary). Grub already perfect…
Finally I reinstalled the internal HD and verified that:
1. if boot without connecting the USB disk, Windows XP starts, untouched, exactly as before
2. if boot with the USB connected my Kubuntu starts perfectly.
Just installed Jaunty Jackalope and it happened without any hiccups. I didn’t get any Grub related issues on my first boot from my USB HDD.
This tutorial looks good, but it is not working for me, there’s no menu.lst file in the /grub/boot directory. Actually there’s no file menu.* there. Possibly because of this, the disk I formatted following this tutorial failed to boot.
Another thing I note is that line 11 on the second part will only work if there’s a single hdd beyond the usb disk.
I managed to install Ubuntu to an USB disk folloing this tutorial, but with Jakalope (9.04). This tutorial doesn’t work for Koala (9.10).
With Jakalope the menu.lst file doesn’t need to be updated, only the device.map, changing the hd0 entry to the usb disk (e.g. sdb or sdc).
This tutorial will also work if the instalation is made to a specific disk partition, without using the whole disk.
Thanks! I have been searching for this information all day now. My computer is not running like it should and I need to figure out how to fix it quickly. I have bookmarked your post so others can find it to on reddit.
So what to do now with Karmic Koala? Are there no solutions?
My internal hdd has been spoilt, and before I get new one I decided to install my ubuntu 9.10 on my toshiba 400gb external usb hdd. So, i have many information on that and diceded to make one additional ext4 partition and one swap partition(also there is main ntfs part of hdd). I have installed ubuntu like you are saying with one exception, I did it on the second free partition with ext4 file system. After rebooting it does not loads, while bios supports usb booting. so I am following next steps until i need to open menu.lst file and there is a problem, there is no such file at all. not in the cd and not on the hdd. what should I do? I am looking for solution for several days and nothing helps. please sugest something that might work?
If it has any minning(i do not know exactly) I have AMD triple-core proccesor.
I successfully installed Ubuntu 9.10 to my usb flash drive cd without changing anything afterwards by disconnecting my hard disk drive before booting from the live cd and starting the installation. I did manually made partitions in different sizes for boot, root, swap and home because my usb flash drive isn’t very large (16 GB). After the installation finished I just reconnected my HD drive. But, of course if you don’t want or can’t open/close your computer’s case and manually handle HD connections, this an excellent and simple tutorial.
I’m new to Linux and am trying Ubuntu, and I love it! I was able to install it to my USB, but only a trial version which doesn’t keep changes after rebooting. I’m also using an 8GB flash drive.
Is this tutorial explaining how to make a FULLY OPERATION Ubuntu on my flash drive? Because I need that.
Oh, and I’m also using Lucid Lynx (10.04)
Sorry but i’m new in Linux and i don’t understand how to open The menu.lst from The terminal… Thank you
May I ask some question? How to print your guide to a pdf file? I use Ubuntu and cuppdf.
The new versions of ubuntu uses the new GRUB2. you will not find menu.lst. GRUB2 changed everything around. i tried many fixes on the internet and none of them worked for my usb hdd..Tho..Pclinuxos worked the first time..go figure…Perhaps it can be added to the install progams so the installer will know its a usb hdd and configure it correctly…time will tell..very good info in usb hdd installs..works on older versions..thanks..
The location and manner of menu.lst has changed as far as I can tell.
The following documentation gives more info on how to set up a custom doc entry:
This looks just great. But we are now on Ubuntu Oneiric (11.10). Do you have an updated version of this, which takes acount of the foibles of this new distro?
The author of this article doesnt understand squashfs and that the startdisk maker USB is far more efficient than what is otherwise known as a full-install. THe author doesnt understand that full installs also limit the USB to that particular machine and its hardware, and is not designed to load anywhere on any machine. dont do full installs on USB. He doesnt understand theres reasons for the other method and its 4 GB persistence.
“…is not designed to load anywhere on any machine…”
I have never seen an ubuntu system fail to boot to a fully working system after moving it from one machine to another. Perhaps I’m just lucky in that respect. I have however seen how much longer a “persistant live CD” usb install takes to boot.
Thanks but I’ll risk the problems you describe. I promise not to cry if it breaks and I have to pull out my spare “persistant live CD” version I also have.
I am new to Linux and have tried various version over the years, starting with Red Hat about 10 years ago, but never bothered with it until now.
As someone who just wants a system that works without the use the terminal I am finding Ubuntu 12.04 excellent and I could not have done it without this easy to follow guide. My thanks to the author!
While Safron does have a point about a full installation limiting it to the particular machine, many might not mind that limitation. I am one! However, for those who want a portable Linux system, I guess a bootable CD is the way to go, but I have found them too limited.
Thanks again for this guide…EXCELLENT!
I tried this and could not find menu.lst or the device file…
My friend has a russian windows computer and we need an alternate boot in english.
The persistent live usb runns very slow with added software.
We have a 32 bit emty live usb for other machines.
On install..I chose ..other.. and did it on a kingston pre.partitioned 16gb. all reiser 3 parts… / home and swap mt pts.
I got a blank screen on boot…it takes 1.5 hrs to make.
The 2nd time ..I did ext 4 for / mount pt.
I put the boot on sd1 instaed of kingston choice …as I did on first try.
got a grub repair prompt with a no file sys.
If I do this more times..I.m bound to mess up my friend.s win7..
Nice idea about phys removing the internal hdd..but I have a laptop.
Am I dreaming that it will boot faster this way.?
Why cant ubuntu have the booter and stuff for the live usb integrated..seems easy on paper
ps…terminals are not fun.
I type sudo su
Then I can search and edit my files..if they existed.
I tried editing grub.cfg..but to no avail.
If you can help…I.d appreciate it.
I would like this article to be updated for 12.04
Someone posted about an atom…Pls make sure you have the bits 32 64 version to match your processor.
Hi there, the link was really helpful and I am glad I installed it without losing any data.
But the usb installation is not getting recognized. In 12.04 there’s neither menu.lst nor drive.map.. could you please mention how I can go about here? How do I modify grub.cfg
Thanks in advance.