A much easier way to install Ubuntu on a USB device (Stick or HD)!
Sponsored Link
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
root (hd1,0)
kernel /boot/vmlinuz.........
initrd /boot/initrd.......
quiet
(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.
Regards,
SUre, but it’s not a “Live USB” ubuntu. It’s a simple install on an “usb drive”. So it will only work well when you boot your usb disk in the computer which has generated it.
If you plug your usb in another computer : it will be corrupt …
Because, during the process installation : it will only install drivers which are needed in this context/computer. So when you will try with another computer : it should not work well.
The other/old method is a lot better, because it really transform your usb drive in a real “usb live”. The “live” ubuntu is different. During the boot process it will instanciate the required drivers according the computer where you boot.
It’s not reaaly the same thing ! no ? am i mad ?
@Manatlan:
You are right. In such case we’re not comparing apples to apples (to name a brand…;-)
But for anyone seeking to install Ubuntu without affecting his/her internal harddrive this is a practical solution.
Question still: Is the Live USB Ubuntu capable of installing updates (I really have no idea, didn’t try this at all)?
Regards,
Arnoud
I just recently did this (on a desktop, not a laptop) – perhaps a little info on how to get boot the internal drives from the external bootloader could be helpful to finish off the tutorial? Just an idea.
@Arnoud:
since you’re booting up the installation, not the livecd, you can install updates as usual. this is a standard-out-of-the-box ubuntu installation, except it is on an external hdd, you can install whatever you want.
@Kevin:
shouldn’t it be more interesting how to boot the external drive from the internal bootloader? so you don’t have to set the usbboot every time.
btw i think it is not possible, because grub misses some usb functionality here, but i hope someone corrects me because i would like to know this.
@Arnoud
> Question still: Is the Live USB Ubuntu capable of
> installing updates (I really have no idea, didn’t
> try this at all)?
Yes ! of course !
I’d an “USB Hard drive” where I’d installed a “Live Ubuntu” (which can virtually boot on any computer). And I’d tested in the past : upgrade works ! (so I did’nt test dist-upgrade)
@Manatlan
That would be nice. I will definitely try it soon. You just followed the notes outlined here on ubuntugeek.com? Or did you follow other instructions? I have seen a few going around (all rather similar, but on some areas really different).
@Kendon
I will try to fix my internal bootloader to be able to start from USB. Let me try, I will come back on this.
Regards,
Arnoud
@Kendon: I just booted from my USB HDD (I am typing this comment from my USB Ubuntu installation) using my internal bootloader.
It is fairly easy to do: I just copied the entries from my USB disk’s /boot/grub/menu.lst and put them into the /boot/grub/menu.lst on my internal HDD Ubuntu installation, changed hd0,0 to hd1,0 for all of these entries and was able to boot from USB using the original bootloader…
Arnoud
You might want to check out these two links:
http://unetbootin.sourceforge.net/
https://launchpad.net/liveusb
THAT’S an easy way 😉
//MadsRH
Sorry, but this is a misleading title. The earlier post referred to (compared to which this is supposed to be easier) is about making a live usb. This is a simple plain installation to disk, using the usb drive instead of the hard drive. It is much easier to make a live usb (for example, using some automated scripts like isotostick.sh) and it is more flexible to use since you can run it on any computer.
You can still use this install as a mobile install to boot other computers. The main thing you will have to do is change the graphics driver to VESA. You will loose all of the fancy 3D eye-candy, but it will boot to a usable interface that way. Most, if not all, of the other drivers will be there, or will update themselves.
What is ultimately needed is a standard type of installation that has the option of combining the dynamic capability of hardware detection of a LiveCD. It could be slower to boot, but hay, it is a good compromise to get the options to update, upgrade, and run it on any computer with supported hardware.
You might want to reconsidering using this on a day to day basis. As a regular Ubuntu install is set up to happily log away and access the disks when necessary it will quickly wear out a USB stick. You’ll either need to do a fair bit of tweaking to turn all of this off or you can bite the bullet and install a distro that’s specifically made for running off of flash media. Have a look on distrowatch for plenty of options….
ABCC
@ABCC: I kind of think you (and a lot of others, probably) are missing the point here.
Suppose you have a working installation of Ubuntu 8.04 (running fine, thank you), but you want to try out and see whether this new KDE4 is all they report it to be, so install Kubuntu experimental.
Or, you might be a user of that other os, and you’re contemplating a switch.
You have that spare USB toughdrive or whatever…
The method mentioned by arnoud may be just what you need. Non-disruptive but a full environment on /your/ hardware.
Haven’t tried this before, but now I will!
I have written a script:
http://people.ofset.org/~ckhung/p/mk-boot-usb/
It’s not the easiest way to create a bootable usb,
but it gives you instant gratification — it installs ttylinux
and therefore boots immiediately without any further installation.
It then takes only copying files from ubuntu cd to an empty partition of the
usb stick that it creates for it to be useful. The part I love
it most is: once you get a perfect live usb (e.g. put persistent
features into it), it takes a single command to clone many more
bootable usb sticks.
How about this?
http://people.ofset.org/~ckhung/p/mk-boot-usb/
Not the easiest way to create the first bootable usb.
But once you are satisfied with your first one
(such as enabling persistent on it), you can
clone it using one command. I do this for my audience
whenever I give talks (with the help of my student).
Try out the Fedora 9 Live install on USB stick.
This now supports “persistence”. I just did it
and have used yum to install/update all sorts of
additional software. (Can’t figure out how to
utilize updated kernels – doesn’t use grub.)
I have multimedia stuff (mplayer,xine, …),
OpenOffice, LaTeX, VMware server with virtual
LoseDoze eXPee and M$ Orifice, Octave, lots of
scientific packages, data and added user accounts.
All on a 16GB Corsair stick. It was really simple
to do, and I had never done it before. Have tested
this x86_64 setup on numerous computers and it
works on all.
Dr. Stu
whenever I’ve done this before the two other tweaks I’ve done is turn of atime during the partitioning step (helps reduce wear) and I use manual partitioning to remove the swap space. Unless your using this on old computers most should have enough ram that the swap wont matter much. I’d also recommend openbox instead of gnome for a usb install, it seems a little snappier.
I am interested in what Eric says about turning off the swap space. I have been cloning hard drives, using the Vesa driver to avoid the graphics card problem, which is easily reset once the drive is installed in a new machine. (In a CTRL-ALT-F2 terminal, login and do sudo init 1. This will (eventually) bring up a menu where you can automatically reconfigure the X server)
HAL recognises all the other hardware OK. The only problem is the hard drive labels in fstab. The root drive was recognised, but swap wasn’t. Even though these P4 2.4GHz machines had 1GB RAM, the missing swap file made significant speed differences. I solved the problem by removing the labels in fstab in the source drive and used the /dev/sda numbers instead.
Obviously we are talking about USB devices here, but I’d like to see some performance stats before I remove the swap space on the USB. On my personal hard drive AMD64 system running 32bit Heron with 1GB RAM, about 30MB of swap is regularly used just for GP computing.
Thanx for the tutorial, but I have a big problrm. The install went well, but when I want to boot from the usb all I get is this: GRUB Loading stage1.5.
GRUB loading, please wait…
Error 21
I know 21 means no such disk, but….
Any ideas?
Gopo:
You have destroyed your MBR. Google “mbr” and “error 15” or “error 21”.
Check this:
http://skss.learnfree.eu/archives/234
There is a tool named live-usb-install developed by me, which can install easily liveusb ubuntu on a usb stick, or remaster your current real ubuntu installation and install it in liveusb mode. Tested with 7.04, 7.10 and 8.04.
The site is in Bulgarian language, buth the GUI of the program is in English by default.
Nice tutorial. I’ve installed and everything went fine, except one huge problem.
I boot from the usb, I get the usual login screen, I log in and then all I get is the ubuntu’s brownish desktop background and nothing else. I can’t see panels, only the mouse, which does not react on right click. Very strange. If I hit the Home key from my keyboard I do get Firefox in the left upper corner, but not its address bar or the top and I cannot do anything. Any ideas? I’ve installed Ubuntu on a 4GB flash usb.
HELP!
I followed the steps and have a wonderful installation on my USB…
Issue: If the USB is not in, GRUB gives me:
GRUB loading, please wait…
Error 21
I was expecting to boot into Windows. (Which I need for VPN access and a number of other things.)
Should have read a bit further on to see that this was not a Live CD installation but I didn’t. My Bad.
Question: Am I irreparably screwed or is there a way back?
Will be madly googling tonight, but hoping someone has a relatively easy answer.
ok, it’s not as painful as all that:
http://users.bigpond.net.au/hermanzone/SuperGrubDiskPage.html saved the day.
(watch the mirrors, one of them (sorry can’t remember which one) started popping up ads all over the place. the original download site is fine, and mirror 0 is fine…)
In short:
SuperGrubDisk was written for people like me who a) don’t read all the way to the end, and b) don’t have a good working knowledge of GRUB. Simple menus to do what you need to get done.
(ok, no it wasn’t and i’m oversimplifying the heck out of a very powerful tool… but you get the picture.)
I got the same problem as Kapris. Before that I installed Ubuntu on a 10GB USB hard disk and everything is ok. But after I’ve installed Ubuntu on my 4GB USB flash, I boot from the usb, I got the usual login screen, after I log in and then all I got nothing but the ubuntu’s brownish desktop background . Any ideas?
Hi arnoud.roth,
Thanks you very very much. This guide just works.
Before that, I tried to install ubuntu 8.04 using dual boot, not realising that my laptop is using SafeBoot account. So, the laptop is screwed and MBR corrupted. I was getting Error 17 and Error 21 all the time. and this can not be repaired using fixmbr as well 🙁
I then purchased external USB HDD and tried to install ubuntu on that, but it did not work. Then I followed this guidelines and I can now boot ubuntu from USB HDD.. A very happy Linux newbee.
Thanks,
Kamal.
THANK YOU!
I exactly followed your steps and got Grub Hard Disc Error.
FYI, I am using a mac on which I used to run Mac OS and Vista with no problem until I installed Ubuntu 8 on an external HD.
Any help on this, please?
Thanks,
-H
Exactly what I needed. Works great, I now have a fully customizable Ubuntu server running on my laptop… if I boot from the USB that is. If I’m not quick enough on the keys my required for work Vista boots right up grub free. Perfect! Thanks.
I have just followed this steps for installing Ubuntu 8.10, and they work just fine. I only wanted to point out that the second part of the installation process is not needed, because the Intrepid installation already does it for you!
Even when this process does not give you a Live USB installation, is very useful for those (like me) that have an encrypted HD (my work laptop is encrypted has a corporate rule here in HP), and can’t have a full installation on their hard drive. This is the perfect solution.
Thank you very much for making me a happy Ubuntu user again.