Install Fedora to USB Drive

I have been looking for a notebook to run Fedora for a while. But due to certain personal limitations I haven’t been able to dedicate a notebook only to it. So the next best thing was to create a Fedora installation on a USB pendrive and boot off it. A USB stick is easy to carry around and is great for quickly booting a computer into your customized OS environment.

There are two ways to accomplish this. One is to create a Live USB with persistent storage and the other is to install to USB drive just like you would to a hard drive. After spending about two days trying out various ways to first install and then use it, I prefer to do a complete installation over a Live USB. In this post I’ll discuss how to do both.

Edit: See Felipe’s comment below for caveats when using a USB drive in this manner.

Things You’ll Need

I had either a Windows or a Mac available. My instructions were created and tested on a Windows machine.

  • VirtualBox
  • USB drive; mine was 32GB
  • Fedora Live CD; I used Fedora 18 KDE version
  • Computer capable of booting from USB drive

I used VirtualBox and a Fedora VM to install Fedora to my USB stick. The same setup can be used to install Live USB and a full installation.

Install Fedora in a VM. Make sure to assign at least 2 GB of memory to the VM. This is very important. If you assign less then during installation your VM may become unresponsive and your installation will remain incomplete.

Install gParted as it will help you to format and resize the USB drive quickly.

su -c 'yum install gparted'

Install as Live USB

Insert the USB drive in your machine. Start your VM and attach two things to it: the Fedora ISO file and the USB drive. Open gParted and unmount the USB drive (it was identified as /dev/sdb1 in my VM). Create a single partition and format it as ext4.

Install livecd-tools package on your VM. It’ll give you the livecd-iso-to-disk command we’ll use later.

su -c 'yum install livecd-tools'

Now you’re ready to install. But before you proceed, there are a few caveats with data persistence.

  • Any changes you make, either new data or updates, will increase the usage of the disk, with space eventually running out.
  • The size of the live-rw partition, on which / is mounted, may only be 3GB. You’ll need an overlay to add more space.
  • Even though I created a 25GB data persistence overlay, I ran out of space when I updated Fedora on the USB drive after installation. I don’t know why.
  • You should not upgrade your kernel on the USB stick, ever! Seriously, once you are done with everything and you are running your Live USB, DO NOT upgrade your kernel. To prevent kernel upgrades, add the line exclude=kernel* to /etc/yum.conf file.

Because of these issues I did a complete installation and not a Live USB. Nevertheless, the next step is to run the command on your VM to create Live USB.

su -c 'livecd-iso-to-disk --overlay-size-mb 25000 --unencrypted-home --delete-home Fedora-18-x86_64-Live-KDE.iso /dev/sdb1'

Here I created a 25GB overlay for data persistence. I specifically created an unencrypted home for ease of use. I also deleted any previous /home partition if there was any (although since we used gParted to create a single partition that shouldn’t be the case).

If you want a separate partition for /home, divide the 25GB between overlay and /home.

su -c 'livecd-iso-to-disk --overlay-size-mb 15000 --home-size-mb 10000 --unencrypted-home --delete-home Fedora-18-x86_64-Live-KDE.iso /dev/sdb1'

This will take some time to complete. When you are done, shutdown the VM and you are ready to boot from your USB drive.

Once you’re using your USB drive, the regular df -h will give you incorrect information about the space used by live-rw. Instead use dmsetup status live-rw to get more accurate information.

Install as Hard Drive

In this scenario you don’t need to install a Fedora VM. You just need the Fedora ISO and the USB stick attached to a VM. When you start the VM boot from the ISO and start the installer. Instead of installing to a virtual hard drive of your VM, choose the USB drive as your installation destination. Perform a regular install. Again, it’s important to assign at least 2GB memory to the VM for a successful install. Once the installation is complete shutdown the VM and you’re ready to boot from your USB.

You can use this installation just like you would on a hard drive. You can update Fedora as much as you like, although it took approximately 12 hours to run my first update. Yeah, it can be really slow. But if you run regular updates afterwards it shouldn’t be that long.

Hat Tip

The only resource you need for detailed information is How to create and use Live USB.

One Response to Install Fedora to USB Drive

  1. Felipe says:

    ” You can update Fedora as much as you like, although it took approximately 12 hours to run my first update.”

    The bottleneck is on the USB 2.0 connector. I guess using a USB 3.0 pendrive things will be much better … obiously you need a computer with a USB 3.0 socket.

    Appart from this, you can make a deep fine tunning ( file system, fstab, etc … ) to the pendrive-installed Fedora … and finally, as you know, flash memories ( those used by pendrives ) sport a limited amount of I/O writes per cell … finally … file system sectors will start getting unavaiable … and the pendrive will ‘die’. But it’s a very interesting experience … and, if you don’t use it very much, I mean, if you have the pendrive as a alternative/rescue resource it will last longer.


%d bloggers like this: