Is it possible/practical to install and run Linux on a USB flash drive?

11
2013-09
  • ThatGraemeGuy

    I'm going to replace my old 2004 vintage desktop PC soon and I have an idea of what I want to do, I'm just not sure if it's possible or realistic.

    In the time since I built the old PC it has slowly become less used as a PC and more as a file server, so I figured I'd build a small file server which could also function as a router/DHCP/DNS/whatever box.

    The idea is to base it on an Atom system. I have my eye on the Intel D510MO for the moment. This supports 2 SATA disks, and I'd prefer to dedicate those to data storage. I'd like to install Ubuntu Server or maybe Debian on a 8/16GB USB flash drive. I have seen plenty of tutorials on how to perform an installation from a USB drive, but I can't seem to find any info on actually booting and running the OS from USB flash. Is this even possible? Is it practical?

    This box will mostly be used for:

    • Making backups of mine and my wife's notebooks via LAN. Will use SMB or NFS for this.
    • Digital media storage, which will be accessed by a Mede8er box with no storage of its own. I will most likely use NFS for this.
  • Answers
  • quack quixote
    1. Yes, Linux on a USB flash drive is doable. @David Spillett discussed some of the options on another question today. The other question is Ubuntu-specific, but the general concepts ("LiveCD"-type installation versus "hard-drive"-type installation) are pretty much distribution-agnostic.

    2. Frankly, I'm not a fan of the Intel Atom D510 CPU. Check the Atom spec chart. The Atom 330 is practically the same CPU with 2/3rds the power consumption. You can find a variety of Mini-ITX Atom 330 boards (on Newegg or elsewhere) that provide more SATA ports or other configurations. I grabbed Zotac's IONITX-F-E Atom+ION board (3 SATA ports, Wifi PCIe) a few months ago and have been very pleased with it.

      I was building a desktop/HTPC though; if I were aiming for a network storage server, I'd be looking for more SATA ports. The 2 SATA ports on your D510 board is pretty limiting. Newegg lists a couple other Zotac boards with 4 SATA ports, and the NM10-B-E with 6 SATA ports. (The NM10-B-E is a Mini-DTX board, so it may not fit a Mini-ITX case. It uses the D510 CPU.)

      [*] I've only linked to Zotac boards because I have direct experience with one particular model and feel comfortable recommending it. There are other Atom boards from other manufacturers; research before you buy. My main point is that the board you've mentioned may not be the best choice.

  • Shiki

    Disable discs on the mainboard if there is any (just to be sure). Plug in your USB (choose a FAST/reliable one). Boot up the Ubuntu install disc and you can simply install it to the USB driver.

    About the USB stuff. USB drives are not reliable so you will be taking chances every day. If you want a reliable system , use Raid1 or simple one HDD as the system + data , the other one as data. (well, raid1 is needed if you want backup. However, Intel Atom boards won't support that as far as I know. (You can play with software raid.))


    I would go with a custom built small PC. Get a mainboard with good raid support, integrated vga, in-built 1gbps lan, get a low consumption cpu, and you only need to build/get a good case which supports fanless (or one fan) design, so you get almost a noiseless PC. (And you can hang up 4 HDDs in Raid5 for example.)


  • Related Question

    Booting Linux off USB pendrives
  • nik

    Booting a Linux system off USB Pendrives is one of my favorite things.

    On a laptop we have the following advantages,

    • The Harddisk can be shutdown and that reduces power consumption (hdparm)
    • The system heats lesser and the fans are triggered less frequently
    • The system can take more shocks (a bumpy backseat taxi ride)

    With old workstation hardware,

    • Can be used for quick testing of the hardware platforms
    • Linux (Ubuntu these days) works quite well with most hardware
    • One Downside: Many old motherboard BIOS do not support a USB boot

    I have preferred a USB "boot-stick" to a LiveCD in most cases.

    Questions.

    1. What other advantages and problems have you seen or anticipate with USB booted Linux?
    2. What is your choice of Linux for this purpose?
    3. Would you suggest ext4 or something more proven/stable for a linux usb-boot?
    4. Do you often find USB drives getting corrupted?
    5. Do you partition your USB drives?


    Recent install guide reference,
    Ubuntu Karmic Koala Encrypted Flash Memory Installation (edited July 22 2009).

    This install guide is for installing Ubuntu 'Karmic Koala' in a USB flash memory stick with
    the LUKS encrypted ext4 file system by running the Ubuntu Karmic Koala 'Alternate CD'.


  • Related Answers
  • Aiden Bell

    When booting of USB media, I would be careful of the following:

    1. Swap, unless you need it, save the writes of the flash
    2. Keep the filesystem slim, turn off SELinux/AppArmour unless you need it
    3. Tune the journaling and cache settings to get better performance

    I have a USB key that I use to boot all my systems, it contains the kernel and bootloader with configurations for machine. I also keep the encryption keys for my hard-disks on it.

  • jamuraa

    I've heard some people have concerns about write-cycles with USB pendrives and most of the Linux filesystems, like ext3 which is setup to update the disk whenever a file is accessed. This can cause a lot of writing specifically in the same area of the drive. Usually it is recommended to use the noatime option in order to fix this.

    I created a USB drive linux for a team of robots - I used Debian which was selected because it was very easy to put it in a small space and I am familiar with it already. We've been running them for a while now and there has been no corruption so far. Even if there is corruption, as long as you have backups (we mirror to another drive of the same size periodically) you should be okay and it's not exactly expensive to replace.

    I generally don't partition my USB drives because I find it creates hassles. If I want a reasonable filesystem (with permissions, caps sensitivity, etc) on a windows-accessible drive I create a loop file to use.

  • indyK1ng

    I only have answers for the last 3 questions (I don't have professional experience with booting from flash drives).

    Someone else mentioned that there are concerns about write cycles on flash drives. I've heard it be somewhere in the area of 100,000 writes and 500,000 writes. It's probably the latter. The problem with using ext4 or ext3 is that they're journaling filesystems. This means that the data is transferred to the storage device, stored there and then written to the proper place on the storage device. This way, if the full write is incomplete and the computer crashes, the storage device has a copy and can continue writing. This will reduce the lifespan of your flash drive, specifically, whatever part is being used as the journal. I would recommend using a non-journaling filesystem for this purpose, such as ext2.

    I haven't had a USB drive get corrupted. The write limit I mentioned above was per memory unit. With that being said, they build in backup memory units to be used when one dies. On top of that, even the low end estimate I heard, 100,000 writes, will take a while to reach. If you wrote to 1 memory unit 8 times per day every day, it would take over 30 years to kill a memory unit. With that being said, sometimes Live-USB installs will use a portion of the USB stick as memory if the system doesn't have enough RAM or if it is unsure of how much RAM it will have access to later, although this is almost always just done with Live-CDs to simulate saving data such as web browser history. Since this is a Live-USB, it can just save that data permanently. With all that being said, keep in mind that a memory unit isn't a single byte, but some number of bytes which is determined when the flash drive was designed.

    I myself have had problems partitioning a USB drive, but it is possible.

    CORRECTION: In the second portion I refer to a process by which a flash drive uses itself for RAM and then refer to something similar for Live-CDs. For Live-CDs, they use what's called a RAMdrive where they use the system's RAM as a virtual hard disk to "save" files such as browser history. What I described for flash drives may not actually exist. It may have been a small bit of confusion on my part (I'm in college and am not fully awake yet) where I was thinking of Vista's readyboost. Sorry for the bad information.

  • Margaret

    I like Puppy Linux (http://www.puppylinux.org/), though I haven't played around with it for a while. It's fast, even on underpowered machines. It also has (or had) built-in easy-network wizards, etc, to get online fast. Not sure how easy it is to hack if you run into difficulties - I never delved that deeply into it.

  • Simon P Stevens

    One downside I've come across is often if you boot linux from a usb you carry with you, it's harder to get online on a PC that isn't yours. Especially if the PC is wireless, in my experience the owner will often have trouble remembering things like wireless keys.

    I have a USB with Ubuntu on it which I use occasionally to fix broken machines and stuff like that, and this is the most common problem I have. I can't quite remember the detail of the command I want to do something, and I can't get online to check it out.

  • badp
    1. What other advantages and problems have you seen or anticipate with USB booted Linux?
    2. What is your choice of Linux for this purpose?
    3. Would you suggest ext4 or something more proven/stable for a linux usb-boot?
    4. Do you often find USB drives getting corrupted?
    5. Do you partition your USB drives?

    1- mostly updating the kernel and stuff like that is harder ...

    2- any linux can be a decent live usb but Slitaz is light, fast and is the only linux that could be remaded into an hard drive installation, a live cd, a live dvd or a live usb easily while keeping all the settings added ... (old but decent, I always have my boot floppy, my boot cd and my live usb to help peoples and learn them some linux love ...

    3- I would use ext3 that is journalized for security and cause it can be readed in windows if needed ...

    4- not seen that issue if the usb key is removed correctly but I seen it a lot when peoples remove it without proper removal technique ...

    5- maybe to make it a multiboot usb key ...

    IMP: If you can understand basic french, I would go directly to the Framakey Ubuntu-fr Remix usb key installation package that is the most avanced premaded usb key for now, waiting to be translated if you wanna help them it's really worth it I use it a lot !!! Maybe you could switch ubuntu language easily to english ...

    Framakey ubuntu-fr remix :

    Portable apps for windows and mac ubuntu 9.04 persistant live usb shared profiles between apps virtualization stuff in option

    (add windows and mac live usb to that and it's the paradise !!!)

  • Area 51
    1. Advantages of USB bootable sticks: you can boot any number of systems off a single pen drive if you use e.g. grub4dos, including booting physical ISO files located on your flash stick - either mapped to RAM or directly from the disk (file should be in one contiguous block). Potential problems: booting from ISO files not supported for all distros; some distros would not even boot on exotic or non-typical hardware. With grub4dos you can also easily boot from floppy boot images which is also the way some bootable CD/DVD discs use. Another disadvantage is that reading multiple small files from USB flash drives might be painfully slow. With external USB HDD drives speed is much higher.

    2. Choice of Linux distros: PartedMagic, PuppyLinux, DamnSmallLinux, lubuntu, xubuntu, BartPE, Hiren's Boot CD, Windows installation files.

    3. File system: ext4 or other: FAT32 works the best if you want flexibility and multiple operating systems, e.g. both Linux- and Windows-based OS's on the same stick.

    4. USB getting corrupted: never had this happening; but mostly using boot USB sticks for rescue purposes and not as a regular environment.