In my experience of almost two years regular usage of a desktop system on a flashdrive some years back, the most trying part was actually the reduced read and write speed, while there were no real issues with data loss. Still, device wear is of course an issue on solid state media, especially if you're aiming for a longer usage than I was. There are a number of filesystem related tweaks you can use to speed up perfomance when running a system from a flash drive. Many of these are also useful to extend your flashdrives lifetime since frequent writes will cause failure eventually.
- Turn off recording of access timestamps by including the
noatime mount option to the respective devices in
- Change the default I/O scheduler to
noop (using I/O schedulers designed to optimize writes to spinning hard drives will not work well with flash disks and will often cause applications to hang while writing large files to disk). To make the changes, include the following line in the file
<device> is the name of your usb device, i.e.
echo noop > /sys/block/<device>/queue/scheduler
- Use a ramdisk to store temporary data if you have enough RAM. Add the following lines to
tmpfs /tmp tmpfs defaults,noatime,nosuid,mode=1777 0 0
tmpfs /run tmpfs defaults,noatime,nosuid,mode=1777 0 0
You might also consider adding a ramdisk for
/var/tmp. However, check whether
/var/run isn't implemented as a softlink to
runfirst. As for
/var/tmp, be aware that moving this to a ramdisk could break the expected behavior of some programs. From the Filesystem Hierarchy Standard 3.0:
Files and directories located in /var/tmp must not be deleted when the system is booted. Although data stored in /var/tmp is typically deleted in a site-specific manner, it is recommended that deletions occur at a less frequent interval than /tmp.
Place the browser cache and other temporary data storages that do frequent writes on the ramdisk. I.e. for firefox, open
about:config, create a new string
browser.cache.disk.parent_directory and set its value to
- Consider temporarily syncing
/var/log/ to ram and syncing it back to the physical drive before shutdown. Logfiles are frequently written to and only syncing them to physical storage once at the end of a session will reduce wear on the drive. One method for implementing such a solution is discussed in this article on debian-administration.org, another one is the anything-sync-daemon (I have not tested either solution but judging by the article/docs they both seem sensible to me). Another alternative would be to outsource log data to another drive or a log server. I do not recommend simply discarding the logdata on a ramdisk at the end of a session because this will reduce the possibilities of analyzing errors and render it impossible to track possible security breaches. However, if you make an informed decision to go down this road, please be aware that you may need to write an init script to recreate certain directories, if some services complain that they expect them.
- Optimize swap-usage. If you have a lot of memory you may be ok without any swap at all (depending on how you use the system) and for mostly regular/office usage there are numerous reports that this does not prove to be a problem even in the long run on system with 8-16GB. However, many people prefer to have swap space as a fallback. In this case, you should tell the OS to keep its swap usage or "swapiness" minimal. Add the following line to
- Turn off filesystem journaling. While this means losing quick recovery options in case of system crash or data loss, it does reduce extra writes and overhead. To remove the journal from an ext3/4 filesystem, enter
sudo tune2fs -O ^has_journal <device> (where
<device> is the name of the respective partition, i.e.
sdb1). Consider using ext2 which last time I checked still had by far the best I/O benchmark results and even though not journaled, is still a robust system in my experience. Downside: the consistency checks can be lengthy. Also, in directories with huge numbers of files, you'll notice a marked drop in performance due to lacking directory indexing. If you have many of those, I would go for ext4 without journal.
Make sure you're familiar with the commands and options before you implement any of the changes. Like I said to start with: From my experience, it is possible to work with a system on a flashdrive happily quite some time (if you can muster some patience when booting or starting individual programs). And with 16 GB and maybe USB3 you will be especially well equipped for the run. But with system settings that depart from the standard way of doing things, it's good to know what you actually did in case you run into unexpected follow-up behavior or problems.
Thanks to maxpolk for pointing out that it's sensible to also move (/var)/run and /var/log to reduce wear.