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
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.
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.
Ubuntu/Linux solution
1. Obtain latest image
You should do this with testdrive .
Note. If your key is smaller than 4.4 GB (for Ubuntu 11.04 (Natty Narwhal)), 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 3 GB in size.
You can do so from System → Administration → Disk Utility. Choose the destination USB key, unmount all partitions, and select Format Drive.
You need to make sure you select "Don't Partition" before it lets you format the disk.
3. Start a virtual machine on the USB key
I made sure (with
file
) that my USB key was in/dev/sdb
, then ran:...to install the i386 ISO of the Natty Narwhal desktop -- the file name will vary if you download a different ISO image.
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=d
to 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 thenoatime
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.
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):
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:
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.
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.
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:
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.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.
Have a look at this guide and video on my website on installing Ubuntu to a USB drive. It will help you do exactly what you want and it's very simple.
How to Install Ubuntu To USB Drives
Installing Ubuntu to an external hard drive or USB memory stick is a very safe way to install Ubuntu. If you are worried about changes being made to your computer, this is the method for you. Your computer will remain unchanged and without the Usb inserted, it will load your operating system as normal. When you connect and boot from the USB drive you will be given the choice to load Ubuntu or your usual operating system.
What we need to install Ubuntu to a USB drive is a computer, an Ubuntu live CD/USB, and a USB drive. 8 GB is the minimum recommended size for a functional and useable system (although 4 GB is the minimum). We recommend an external hard disk and at least 20 GB.
It is recommended to partition your USB drive, but not necessary, assuming you have 2GB RAM or more. Partitioning can be done from the Ubuntu live CD/DVD using 'disk utility', or from the installation partitioning menu.
We recommend using a Live CD/DVD and unplugging any other USB drives as this makes life easier. We will assume that you are using an unpartitioned USB drive and CD/DVD for this guide.
How To Install Ubuntu To A USB Drive
Insert the Ubuntu Live CD/DVD, switch on the computer and tell it to boot from CD/DVD using your 'BIOS'. It will take a couple of minutes to load and you will be presented with two choices. 'Try Ubuntu' or 'Install Ubuntu', you should select 'Install Ubuntu' You will then be presented with a number of options. You need to select the bottom option 'Something Else'.
This will bring you to the partitioning menu. Your Primary hard drive will be listed as 'Sda' followed by any partitions that are on it like Sda1 or Sda2. Below this will be your usb drive, it will be listed as 'Sdb'. Click on 'Sdb1' which is the only partition on the drive and select 'change'.
You need to select 'use this partition as Ext4 File System' (some distributions such as Mint reqiure you to manually select 'format' at this point). Then you need to set the 'mount point' as '/' which is the root file system and click OK. You will be taken back to the previous menu and that partition will have a tick next to it. Now click on 'Sdb' just above that partition, this selects it as the device to install to.
Now just below is an option for where the bootloader is to be installed. It is VERY IMPORTANT that you CHANGE THIS OPTION. THE BOOTLOADER MUST BE INSTALLED TO YOUR DEVICE listed as '/dev/Sdb'. If you do not do this the bootloader will be installed to your internal drive. You are now ready to install to your external device, simply click 'Install'.
You will need to answer a few simple questions like 'name' and 'create password', then you can sit back and relax.
Additional Information
You will need to tell your BIOS to boot from the USB device each time you want to use it. You can easily set USB as your first boot device in the bios, and your normal system will load if the device is not connected. Do not be surprised if your Usb installation takes 3 or 4 minutes to fully boot, especially when using a cheap Usb memory stick. If you choose to install from a usb drive instead of CD/DVD, or you have multiple hard drives and Usb drives connected you need to make sure you are installing to the correct device, as it may not be sdb.
The easiest way to ensure that you are installing to the correct device is to use disk utility. Open disk utility before connecting the device and note the devices on the left. Then connect your device and it should appear at the bottom of the list. Click on that device and look at the top right of the window for 'Device'. It will say something like 'Device : dev/sdc' and so 'sdc' would be the device you need to install to.
Step-wise instructions for installed system in a USB drive
Introduction
The main part of this step-wise instruction is borrowed from the iso testing tracker and this link,
and I have added some extra steps necessary for the installation to an external drive.
Please notice that you will install a system, that works in the current boot mode,
It is more complicated to create an installed system, that will work both in UEFI and BIOS mode, but it is possible according to the following link and links from it,
A portable installed system, that boots both in UEFI and BIOS mode
If you intend to install into a USB pendrive or memory card, choose a fast USB 3 pendrive or a high-speed card. See this link and links from it,
help.ubuntu.com/community/Installation/FromUSBStick#Notes_about_speed
If you intend to use the external drive in new and middle-aged computers, I can recommend that you install from an Ubuntu 64-bit 'amd64' iso file.
If you intend to use the external drive in old computers (as well as newer computers), I can recommend that you install from a 32-bit 'i386' iso file with an Ubuntu family flavour with a lighter desktop environment than standard Ubuntu,
These 32-bit systems will work with 32-bit and 64-bit computers but only in BIOS mode, when installed according to the instructions [in this answer].
It is possible to create a persistent live system, that works in
If this is what you want, the following link may help you,
mkusb/persistent#Compressed_image_file_with_a_persistent_live_system
Instructions
When the computer is shut down and disconnected from the power grid, disconnect (and/or unplug) the internal drive(s). In some computers it is possible to disable the internal drive via a menu of the UEFI-BIOS system.
This makes the installer treat the external drive, where you want to install Ubuntu, like it were an internal drive (and the installer cannot tamper with the internal drive).
Plug in the Ubuntu boot/live/installer drive (DVD disk, USB drive, memory card) and boot the computer from it.
Proceed in your native language if you wish.
Boot up the image
The system boots properly and loads the installer displaying the Welcome dialog with language selection and 'Try Ubuntu' and 'Install Ubuntu' buttons
Connect the external drive (HDD, SSD, pendrive, memory card) where you want to install Ubuntu, the target drive. Plug in external power to this drive if possible. It might not be enough with the power from the computer's USB plug.
Click on the Install Ubuntu icon
The 'Preparing to install Ubuntu' screen is displayed
On the screen Preparing to install Ubuntu, note the availability of the following components
Available options should represent the state of your system accurately
Click on the continue button
The 'Installation type' screen is displayed
Select Erase disk and install Ubuntu
Installation screen expands to include encryption and LVM options
Wait a while! Are you sure that this is what you want? Maybe you want to keep something that is on the drive? In that case you should stop the installation and copy the important data to another drive. Maybe you want to select another alternative.
Click on the continue button (if there is only one hard disk in the system, the button should read 'Install now')
Write changes dialogue appears
Click continue
If there is only one hard disk, the installer skips to the "Where are you?' screen. Otherwise, the 'Installation type' screen is displayed
If there is only one hard disk, skip a couple of steps to the 'Where are you?' screen. Otherwise, on the 'Installation type' screen verify that the drive selected on the Select drive list corresponds to the drive on the chart (e.g /dev/sda). If you have removed the internal drive(s), there should be only one drive, that is available as a target, your external drive.
Selected drive is displayed on the chart
Verify that the full drive space is allocated
Full drive space is allocated for installation
Click on the Install Now button
The 'Where are you?' screen is displayed
If your system is connected to the network, note the preselected timezone correspond with your timezone and the city indicated in the text box
The timezone and city displayed match your timezone and the main city from your area
Select your timezone, and click on the continue button
Select your keyboard layout and click on continue
The 'Who are you?' screen appears
Input your initial user details and password.
admin
can not be used - it is a dedicated Linux UserName, username and password are accepted. Login options and home folder encryption choices shown
Continue button becomes available
Press continue
Wait for the installer to finish
An 'Installation Complete' dialog appears
Click the Restart now button
GUI is shut down, a prompt to remove media and press Enter appears
Remove the disc and press enter
The machine is rebooted
Allow the machine to reboot
The system boots properly and loads into Ubuntu showing the username that you selected
Shut down the computer, unplug the external drives and unplug it from the power grid. Re-connect (and/or plug in) the internal drive(s)
If the external drive is an HDD or SSD, it is ready to be used now.
If the external drive is a USB pendrive or memory card, it is a good idea to tweak the system to reduce wear. See the following link,
help.ubuntu.com/community/Installation/UEFI-and-BIOS#Final_system_tweaks
If you want a portable system (that works in most computers), you should think twice about proprietary drivers (typically for graphics and wifi). The classic advice is to avoid installing proprietary drivers, but it means that computers with certain hardware will not work well (or at all).
In Ubuntu 18.04.1 LTS you can install an nvidia proprietary driver, that makes your computer with a powerful nvidia card use the full power of that card. The system will still select an Intel or Radeon driver, when booted in a computer with such graphics. But there will be problems with nvidia chips, that do no work with the installed proprietary driver. See this link,
Install Nvidia drivers Full install USB flash drive
Edit:
If you cannot disconnect/remove an internal drive there are workarounds:
Disable the internal drive in an UEFI/BIOS menu. This works in several but far from all computers.
The flag method
a. Make a note on paper of the flags of the EFI partition in the internal drive
b. Remove the flags from the EFI partition in the internal drive (for example with
gparted
, when booted from a live drive)c. Perform the installation
d. Restore the flags to the EFI partition in the internal drive (with
gparted
booted from a live drive).This flag method is described in detail by @Tim Richardson in this answer to our common question.
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
What To Do
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...
Old answer, do not use it anymore !
I did it using the following method:
Insert live CD and plug in the USB key.
Select Install Ubuntu.
Chose Advanced when selecting drive partition.
Chose your USB key partition as the target.
CAUTION: Chose your USB partition for the GRUB bootloader.
After the installation process, boot on your USB key, not your hard drive.
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.
OP asks for "without touching my existing Ubuntu install." My answer describes how to get this working, with a real install, not a persistent live USB install. Persistent installs are pretty fragile, and updating the kernel is hard. A real install is better.
If you want to boot from your external device, not just install Ubuntu on it, you need to work around an installer bug which rewrites your boot partition on your internal drive and does not install an EFI boot partition on your external device, no matter what you tell the installer. If you don't do this, you will still end up with an install on your target usb stick, but it will only work on this computer, because it won't have its own boot partition. The EFI partition is part of the drive that the BIOS looks for when it is starting. If a drive has no EFI partition, it can't be a boot drive. If a USB stick or external drive does not have an EFI partition, you can still install Ubuntu to it, but it will need a "bootable" drive to actually launch. So if you want a USB stick or external drive that you can take from computer to computer and boot independently, that drive must have its own EFI partition.
Here's what works for me in Ubuntu as recently as 21.10.
Tested on various laptops. I have turned off legacy boot. UEFI is 100% in use (this will be the default setting on anything sold in the last five years).
I turn off secure boot in BIOS.
Installing onto a second drive is a pain because the ubuntu installer uses the first EFI partition it sees, which is the one on the internal hard drive, regardless of any attempt you make to specify an alternative location for the EFI partition. So when you try to set the bootload device to your target USB drive, you are ignored. It's a fairly old bug, but as of 21.10 release, still present.
The bug means you won't get an EFI partition on your USB stick even when you asked for it, so you can't boot from it.
https://bugs.launchpad.net/ubuntu/+source/ubiquity/+bug/1396379
Summary: To workaround it, disable the internal EFI partition by using gparted to edit its flags immediately before beginning your install. Then the installer won't find it, and the bug is not tripped. Later, re-enable the flags. This is a trivial step. It is almost the logical equivalent of physically disconnecting the internal drive, which for sure also works around the installer bug.
The steps I took:
Before you start the install: You'll need a standard ubuntu live USB device, and a target usb stick to install to.
Boot into Ubuntu live USB in the "try first" mode.
Using gparted (you may have to install it first, sometimes Ubuntu doesn't include it on the live disk,): ...
re-partition your target external drive with a GPT partition table. GPT partition tables are needed for a UEFI (modern) bootable drive.
Make a 500MB partition type FAT32. You may as well also set up the desired partition(s) for your Ubuntu install. You may find it handy to label the desired / partition because when you install you will have three drives: your internal drive, the live image installer drive, and your target drive.
After applying those updates, change the flags on the small 500MB partition you just created. Right click on the small partition, and Manage Flags. These changes are actioned immediately (but note, you must actually create the partition first by completing the previous step) Tick to turn on boot, esp and hidden.
Install
You have booted with a live-disk USB image, as per a normal ubuntu install. So you have two USB devices: your target device, and the live-disk USB drive.
Edit the EFI partition flags on your internal drive and untick those same three flags that you set on the target device EFI partition. This will stop the Ubuntu installer for using it as the boot partition.
Here is a short video doing the flag editing in gparted: https://youtu.be/sdgrmylH6pc
Now, when you install, the installer will see only one EFI partition, on your target device. This is the novel step which I haven't seen documented elsewhere.
Begin an ubuntu install. Proceed until you see the disk setup tab of the installer. You want the fully manual approach of course, "Something else" on the partitioning stage.
You specify the way the boot loader is installed when doing the install. If your target drive is mounted as sdc and the EFI partition you made is therefore sdc1 (the first partition), then you will be installing the boot loader onto device sdc, and the EFI partition will be sdc1.
Scroll to find that partition. It should say "efi" in the Type column. Click "change" to be sure: The installer should say "Use as: EFI System Partition". You won't actually be changing anything. No need to format it.
As you scroll through the partitions, review the Type column. There should be no EFI partition on your internal drive, since you turned off the partition flags on your internal drive EFI partition. Of course, the partition still shows up as a FAT32 partition. That's ok.
You will also see the EFI partition of the live disk you booted from to do the install, that's ok. The installer is smart enough to ignore that.
Choose your desired target partition for / (sdc2, perhaps,... whatever you already made above) and do a normal Ubuntu install.
After Install
Restore flags on your internal EFI partition
After the install, reboot to the new installation on the USB stick. You will need to use your BIOS "select boot device" option because the computer needs to use the boot partition you just made, which it has never seen before. On my Thinkpads, F12 is the shortcut to this part of the BIOS menu.
You should see several choices of boot drive in the boot menu, and one of them is the external drive. Some bios menus show the default label as 'ubuntu' so it's a bit confusing to see it more than once. Sometimes changing the boot device causes the BIOS boot to restart (it does on my Thinkpad), it looks like something bad happened, but it's ok.
Later when you boot without your USB stick, the bios should be smart enough to revert to the last known good EFI device (your internal device), but you may need to reselect an EFI boot choice manually.
Tip: How to re-label the USB boot entry to avoid duplicate 'ubuntu' entries
If you get duplicate EFI boot options labelled ubuntu, you can fix it. Relabelling EFI menu options is very handy, but a bit tricky. Do this once you are booting ok from your new install. This step is optional.
Make sure you boot into the installation on your external drive, then
sudo efibootmgr -v
You are booted from the first row in the list.
Note the name of the file used to boot, and note the number of the partition. my output for the first entry is:
HD(1,GPT,...) .... File(\EFI\ubuntu\shimx64.efi)
and then have a look at this thread: https://www.kubuntuforums.net/showthread.php/68851-Labels-on-UEFI-Boot-Entries-using-efibootmgr-L
I did this to relabel mine 'owcUbuntu':
efibootmgr -c -d /dev/sdb -p 1 -L owcUbuntu -l \\EFI\\ubuntu\\shimx64.efi
knowing that the boot drive in my case is sdb and since I made the EFI partition first, the value of the -p argument is 1. Note: please check what your actual boot disk is :) use gparted or df
USB 3 Recommendation: I have tried this on a range of USB 3 sticks. The best experience by far (very far) has been the Samsung USB 3 "Bar" sticks. They are really fast (for USB 3 sticks) in this use-case (random access, ext4 partitions with journalling) and quite robust.
The only way I have been able to do it, is
Not very elegant, but it works.
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:
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.