Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

If you are hurrying to reply, System → Administration → StartUp Disk Creator -- no, that's not what I'm talking about.

I want to try Ubuntu 11.04's Unity without touching my existing Ubuntu install.

To do this, I need to install the nVidia drivers first (sigh).

To do this, I need changes to persist a reboot.

To do this, I need to really install Ubuntu on a USB key.

How do you do that?


What I tried

  1. I tried to make a USB key from Testdrive, then boot from it, then choose "Install Ubuntu." The installer refused to install to the installation media itself.

  2. I tried, from my installed copy of Ubuntu:

    sudo kvm /dev/sdb --cdrom .cache/testdrive/iso/ubuntu_natty-desktop-i386.iso
    

    ...but the installer didn't detect the disk properly.

share|improve this question
    
Have you tried burning a LiveCD and installing Ubuntu onto the USB from that? That seems to me like the easiest solution. –  Frxstrem Dec 11 '10 at 19:22
1  
@Frxstrem I'm trying to do that via KVM without having to burn a nightly image on a CD. It sounds like a waste... –  badp Dec 11 '10 at 19:28
1  
Just wondering if it is possible to partition the USB key in to two partitions then use test drive then install on to the other partition just a suggestion. –  Allan Dec 11 '10 at 20:00
    
I've been looking into this, here's more info: ubuntuforums.org/showthread.php?t=1636650 and wiki.ubuntu.com/Unity/InstallUSBKey –  Jorge Castro Dec 11 '10 at 21:18
    
You may be interested in checking and adding your notes to superuser.com/q/681/263 –  nik Dec 18 '10 at 17:59

11 Answers 11

up vote 85 down vote accepted

Ubuntu/Linux solution

1. Obtain latest image

You should do this with testdrive Install testdrive.

TestDrive

Note. If your key is smaller than 4.4 GB (for Ubuntu 11.04), you must get the alternate installer. The Desktop installer refuses to continue if there is less than 4.4 GB of free disk space.

2. Format the USB disk.

This is important if you already have anything looking like a Linux install on your disk, or the installer will not want to touch that disk, for some reason. I failed earlier because I didn't perform this step, so skip at your own risk! You need a key that is at least 3GB in size.

You can do so from System → Administration → Disk Utility. Choose the destination USB key, unmount all partitions and select Format Drive.

Disk Utility

You need to make sure you select "Don't Partition" before it lets you format the disk.

Format drive window.

3. Start a virtual machine on the USB key

I made sure (with file) that my USB key was in /dev/sdb, then ran:

sudo qemu-system-x86_64 /dev/sdb -cdrom ~/.cache/testdrive/iso/ubuntu_natty-desktop-i386.iso

...to install the i386 ISO of Natty desktop -- the file name will vary if you download a different ISO.

Details for your virtualization solution of choice will vary, but you want to use the device file of your USB key as the VM's hard drive.

Append -boot order=dto the kvm command to make it boot from the image in case it tries to boot from the 'hard disk' and fails because it cannot find an operating system there.

4. Install normally.

At this point you are working on a virtual machine that sees your USB key as the only connected hard drive. From inside the "QEMU" window, install as you would normally do.

A few notes:

  • Partitioning. Avoid using the automatic partitioning system, as it will create a swap partition on your USB key. That's no good, as swapping becomes super slow (seconds-long system freezes slow) and quickly kills your drive's life. Simply allocate a single partition for /. If you're using the alternate installer, make sure you set the noatime flag to further reduce the amount of writes to the disk.

  • Updates. Skip the option to automatically download and install updates. It is not guaranteed that the repositories will be in a consistent state by the time you run the installer. Personally, I'd rather manage the upgrades manually with a tool such as aptitude (which does no longer ship with Ubuntu by default).

  • Alpha-quality software. Things are a little wonky -- it is alpha quality software, after all. I had dpkg exiting with error code 1 without being able to review the error - no packages were broken as a result, however. I tried to shutdown the virtual machine cleanly after the setup, but it hung. On a reboot, however, the system booted fine.

5. Reboot and boot into your copy of Ubuntu

You may need to fiddle with your BIOS settings to make this work.


A nice (or annoying, based on your use case) thing about Ubuntu on a USB is that next time it'll refresh GRUB, it'll also detect and add to the list the kernels and operative systems on the HDD. This should let you boot straight into your HDD from your USB key's GRUB.

share|improve this answer
9  
Wow. Thanks for the very detailed list of instructions for doing this. –  Nathan Osman Dec 12 '10 at 0:03
    
Awesome, thanks for the explanation. To add, I find that adding some RAM to kvm with -m 2GB helps speed up the boot process. –  hasenj Jan 18 '11 at 12:06
    
Will I when using this solution always be working in a virtual machine or only while installing? –  Pit Jan 31 '11 at 13:33
1  
@BryanHead When memory runs out, the oom-killer (if enabled) will pick the "worst offender" and kill it. The alternative is a kernel panic (which afaik is the only last resort measure under Windows.) –  badp Nov 12 '12 at 17:42
2  
This is a very detailed answer, but unfortunately it does not work with Ubuntu 14.04. For some reason qemu fails and the installation process aborts. –  Luís de Sousa Aug 28 at 19:15

Installing Ubuntu to a removable USB drive with Virtual Box

In order to install Ubuntu to a portable external USB drive (either disk or stick) we may also use Virtual Box to install from a virtual environment. For USB 2.0 support the closed source but free PUEL-version of Virtual Box is needed.

Create a virtual machine for the installation live environment:

We create a virtual machine for a Linux/Ubuntu environment (32- or 64-bit, depending on the installation medium):

enter image description here

As we want to install to an USB drive we do not create a virtual harddisk (VDI) for this machine by unticking the box in the following window:

enter image description here

We then need to assign system memory (e.g. 1024 MB), graphics memory (e.g. 128MB), and adjust CPU settings according to our host hardware. Also we may want to create a bridged network in order to be able to download files during the installation.

Mount the installation CD to the virtual machine:

In the Storage menu from Virtual Box Manager we select the .iso image of our installation CD to mount as CD drive. Make sure the boot order of the virtual machine is set to boot from CD.

enter image description here

Mount the USB drive to the installation environment

After we started the virtual machine (USB support needs to have been set up first) to boot the installation CD we need to mount the USB drive either by clicking on the small icon in the bottom panel or by choosing from Devices -> USB Devices menu of Virtual Box Manager.

enter image description here This is when the USB drive needs to have been mounted before we proceed

Partition and format the USB drive

After having chosen Something else the graphical partition manager GParted will guide us through the partitioning process:

enter image description here

We need at least a partition with a mount point root (/). In the example above an additional /home partition was created. By unticking Format we keep the data that may already be there. A /swap partition may not be needed for an USB-stick or a portable drive.

  • At this point take extra care that the boot loader Grub indeed will be installed to the USB drive (/sda) and not to anywhere else

By selecting Install Now we start the installation to our USB drive. Consider that this installation may take a bit longer than we are used to.

After the installation has finished we may unmount our drive eith the brand new operating system and boot from any other machine to customized it to our needs.

  • Do not forget to enable booting from USB in this computer's BIOS.
share|improve this answer
    
Do this apply to Mac's? –  Braiam Jan 10 at 2:39
    
I "successfully" created a bootable USB following this guide, but at boot I get the following message error: file '/boot/grub/i386-pc/normal.mod' not found. And then I get the grub rescue prompt. Any ideas on what might have gone wrong? –  Luís de Sousa Aug 29 at 13:21
    
@LuísdeSousa: Somehow Grub can't find it's files. It may have accidentally installed in EFI mode, or your USB drive get's another drive association on boot. See this answer for some insights. –  Takkat Aug 29 at 13:31
    
On a second try things went well, I guess the installer is itself prone to mess ups. In any case, this is possibly the easiest process to create a boot-able and persistent Ubuntu USB. And also possibly the safest, since at install time no HDD are available, only the mounted USB drive. –  Luís de Sousa Aug 29 at 17:19

If you are talking about an actual install, as in a full Ubuntu install rather than just a Live USB type then what you can do is use an external hard drive that plugs in via USB and install to that via the following method.

Please Note: The following steps were tested using Ubuntu Version 9.10, but has not been tested with the later versions. Use at your own risk & discretion.

What You Will Need

  1. A Computer with Internet access.
  2. A LiveCD or LiveUSB with Ubuntu.
  3. An external Hard Drive with USB capability.

What To Do

  1. Open up your computer and remove the Hard Drive.
  2. Plug in your external USB Hard Drive via the USB cable.
  3. Stick in your LiveUSB or LiveCD and then boot up your PC.
  4. Open up the boot menu, and choose to boot from the LiveCD/LiveUSB.
  5. During the installation process you should your external hard drive listed, install Ubuntu to that.
  6. Finish the installation process, turn off your PC, and put your other hard drive back into your computer.
  7. Reboot your computer, go to the boot menu and select your external hard drive and attempt to boot from it. If it does congratulations, you now have an external hard drive with a full fledged Operating System on it.
  8. Enjoy your external hard drive running Ubuntu/Linux! Please do let me know if this helps you! If not let me know about that too. :)

But if you're just wanting a Live USB then you can use the Universal USB Installer for that or the Ubuntu USB Startup Disk Creator...

share|improve this answer

1) Universal USB Installer:

Universal USB Installer is a Live Linux USB Creator that allows you to choose from a selection of Linux Distributions to put on your USB Flash Drive. The Universal USB Installer is easy to use. Simply choose a Live Linux Distribution, the ISO file, your Flash Drive and, Click Install. Other features include; Persistence (if available), and the ability to fat32 format the flash drive (recommended) to ensure a clean install. Upon completion, you should have a ready to run bootable USB Flash Drive with your select Linux version installed.

2) UNetbootin:

UNetbootin allows you to create bootable Live USB drives for Ubuntu, Fedora, and other Linux distributions without burning a CD. It runs on Windows, Linux, and Mac OS X. You can either let UNetbootin download one of the many distributions supported out-of-the-box for you, or supply your own Linux ISO file if you've already downloaded one or your preferred distribution isn't on the list.

3) LinuxLive USB Creator:

LiLi creates portable, bootable and virtualized USB stick running Linux. Are you sick of having to reboot your PC to try Linux ? No need with LiLi. It has a built-in virtualization feature that lets you run your Linux in Windows just out of the box.

All three programs above allow you to install any Linux operating system to a flash drive, but the persistence feature (allows you to save any changes made to a LiveOS installation permanent to be used even after reboot) is only available for Ubuntu and its many other flavors.

share|improve this answer
2  
Great post! I think he was asking more about having a full installation though. If not then your post hits his question dead on :P –  zkriesse Jul 11 '11 at 22:20

I did it using the following method :

  • insert liveCd and plug USB key.

  • select install ubuntu.

  • chose advanced when selecting drive partition.

  • chose your USB key partition as target.

  • CAUTION : chose your USB partition for the grub loader.

After installation process, boot on your USB key not your hard drive

share|improve this answer
    
Ubuntu 10.10 hangs for me before the installation is complete. IMHO Ubuntu has some very big bugs related to USB installation. –  iugamarian Dec 11 '10 at 21:51
    
I made it with 10.04 & 10.10. Is your livecd ok ? –  teo96 Dec 11 '10 at 21:57
3  
I have made live-usb flash drives in the past using the usb-disk-creator tool. Then booted it and done a 'full normal install' from that flash drive #1 to a second flash drive. Same as one would do to a real hard drive. Never really had an issue other then needing to keep an eye on where grub gets installed to. –  dr_willis May 9 '11 at 1:46
1  
I second what Bubblegum said. Ive done normal installs to flash drives as if they were hard drives for the last several releases with no real issues, other then making VERY sure that grub is installing to the flash drive and not the hard drive. –  dr_willis May 9 '11 at 1:53

The only way I have been able to do it, is

  • to burn the CD iso,
  • disconnect my hard drive (physically remove cable(s)) and
  • install to the USB.

Not very elegant, but it works.

share|improve this answer
11  
That's... pretty radical. –  badp Dec 11 '10 at 20:02
    
Did you try to use the alternate cd (not the desktop cd) ? I've seen alternate work better for many things when installing. –  iugamarian Dec 11 '10 at 21:42
4  
You don't need to unplug your hard disk. You just need to be careful with partitions and use the advanced partitioner. Be sure to use the correct drive and set the bootloader to be installed on /dev/sdb or whatever block device your flash drive is(Don't use one of its partitions, or it won't boot). Then, you can boot by using your BIOS to use the flash drive MBR(Assuming your BIOS dues support that) –  hexafraction Jun 11 '12 at 12:00

You can, yes.

This process assumes you are installing from a live cd. While a live usb should work fine as well, the cd option is theoretically the safest, as there is no chance of overwriting the cd during the partitioning.

I recommend you start off by disabling your internal HDD in your BIOS first, as this makes sure there is no chance of accidentally overwriting your internal partitions. Also, the partitioning step of the Ubuntu setup will be much easier, since it will only detect the USB drive. With other words, it's best to make the USB drive the only storage device present on the machine during the installation.

Next, boot up the live cd and initiate the installation as usual. Make sure you choose "use whole disk" if you disabled all other storage devices, otherwise you will have to do manual partitioning. In the last case, create an ext4 partition on the USB stick (make a partition table if there isn't one) and, if necessary, a SWAP partition if you intend to run heavy applications. Set the mount point to /. don't touch the other storage devices and their partitions!

When the setup asks for the bootloader location, choose the device name of your USB drive. This can be /dev/sda, /dev/sdb, so on, but don't choose a partition (e.g. /dev/sda1).

Wait for the installation to complete, then reboot. Make sure your machine boots from the USB drive. This can be made sure either from the boot menu (usually esc or a function key) or from the bios, where the boot sequence can be altered.

If everything went okay, Ubuntu should boot from the USB drive. If GRUB shows up, choose the first option.

Lastly, run the following command from your freshly installed Ubuntu desktop:

sudo chmod -x /etc/grub.d/30_os-prober

This makes sure that update-grub does not detect any other OSes that may be present on the system, as they do not matter for your Ubuntu USB drive installation. Also, when you boot up your USB drive from a strange computer, the OSes on its internal drive will be included into GRUB when a kernel/grub update occurs. This is unwanted.

Also, make sure to turn back on your internal storage devices from your BIOS.

share|improve this answer
    
This looks promising, thanks. I'll be trying this out. One slight remark, you put the swap partition on the USB stick. Is this still a problem these days? I remember that not too long ago people were saying that flash storage lifetime is severely reduced when running a swap partition / page file on it (because of the number of read/writes). –  efdee Aug 8 '12 at 14:25
    
Using your tips, I installed Ubuntu on my USB stick, but it won't boot. However, when I use the USB stick as harddisk in VirtualBox, it comes up all right. Any idea what could be the problem ? –  efdee Aug 8 '12 at 18:54
    
Apparently I can boot from it, just not from the USB3 connector. It works fine when I plug the stick into a USB2 connector. I'm assuming my BIOS has native support for USB2 but not USB3 and hence, Linux (or grub, I don't know?) needs an additional USB3 driver. –  efdee Aug 8 '12 at 19:33

The process of doing a full installation of Ubuntu to a USB flash drive is identical to installing Ubuntu on a hard drive except for the installing the GRUB bootloader. All of the steps to follow in the Ubuntu installer are identical except for installing the GRUB bootloader. Installing the GRUB bootloader on the USB flash drive will replace the existing GRUB bootloader on the hard drive which you don't want to do, unless you disconnect the cables to your hard drive(s) first before you start the Ubuntu installer to do a full installation of Ubuntu on a USB flash drive. So disconnect the hard drives first, then you can install Ubuntu on a USB flash drive.

Additional information about a full installation of Ubuntu on a USB flash drive.

  • I recommend that the USB flash drive be at least 16GB.
  • A USB 3.0 flash drive is a lot faster than a USB 2.0 flash drive.
  • The advantage of using a USB flash drive lies in its portability, not in its performance. The performance of a full install of Ubuntu on a 16GB USB flash drive is nothing like what you would get from running Ubuntu in a virtual machine application such as VirtualBox.
share|improve this answer

Another way to start Ubuntu installation is to get to Grub console from Grub2 Boot Menu. It will fire up installation from Ubuntu ISO file on your HD.

Lets say you have your Ubuntu.iso on 3rd partition of your hard drive

Type c to get to Grub command promt and type the following:

loopback loop (hd0,3)/Ubuntu.iso

press "Enter"

linux (loop)/casper/vmlinuz.efi iso-scan/filename=/ubuntu.iso file=/preseed/ubuntu.seed boot=casper only-ubiquity quiet splash

press "Enter"

initrd (loop)/casper/initrd.lz

press "Enter"

boot

press "Enter"

note (hdx,y) - is the partition where your Ubuntu ISO file is

This will fire up normal Ubuntu installation process just like you see it when installing from Ubuntu CD. From there you can choose your USB Flash Drive to install Ubuntu on it.

share|improve this answer

I was able to do this using 2 usb's:

One created as a usb ubuntu installer the normal way (the installer usb) Another as the OS usb.

(I recommend to rm your hdd's first)

1) plug in the installer usb, boot into it's live desktop 2) run the installer, installing to the os usb

Worked a treat!

Now I've got an OS usb I can boot from anything! yay.

share|improve this answer

I followed the Ubuntu guide on their site.

Cononical recommend this program and I have uses it for every install of Linux to date and the program also writes Grub2 to the installation so all you need to do is select 'boot from USB' in your BIOS and go from there.

Here's the download link too:

To install to a USB

How do I install Ubuntu to a USB key?

share|improve this answer
    
Thanks. I saw this earlier, but I reckoned it was just for writing a live CD ISO to the USB stick. Where does the actual "installation" happen? Do I still get to pick how the partitions are laid out? From the little text on that page, it really looks like they just burn an image and then reserve some persistent storage space on top of that. –  efdee Aug 8 '12 at 12:13
    
No, this just burns the .iso to your USB drive, you then have two options in the boot menu: Install to hard drive or try out Ubuntu and boot from the USB. If you select 'try from usb' option you can install later on and write all the files to the HDD. The installation happens when you boot up. You can install Ubuntu from Windows, but it still requires you to reboot; was that what you wanted? –  TheBlueCat Aug 8 '12 at 12:41
    
This still sounds like it is writing a persistent live CD to the USB stick. This is not what I want, I want a full install running off the USB stick. Unless the "Install to hard drive" you mention also installs it to the USB stick, but I assume it doesn't. Ideally I just want to reboot now, boot from a Ubuntu install CD, then run through the installation as usual but install to the USB stick instead of to my laptop's hard disk. –  efdee Aug 8 '12 at 13:00
    
Look at this question, I'll update my original answer, if this helped you hit the accept button. askubuntu.com/questions/16988/… –  TheBlueCat Aug 8 '12 at 13:32

protected by Community Jun 24 at 7:24

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.