3

In my work laptop I want to run Linux Mint without changing anything in the computer, so I was thinking of just getting a 128GB flash drive to install it on.

I know it will work, but what should I consider to lengthen the life of the drive?

I have already considered cache, the laptop has 16GB RAM so I should be able to just disable it and if I find a real need for it I could mount a file on the HDD, and probably use ext3 as a filesystem with noatime option.

Anything else to consider or is this just a bad idea? Is there a guide for doing this anywhere?

  • 1
    This will be heavy wear and tear on a flash drive. I would use an external HDD. Going through a USB port is going to limit the speed, anyway, and in this size range, a HDD will probably be cheaper and more reliable. You can get shirt-pocket-sized drives. – fixer1234 Jan 11 '16 at 17:48
  • Alternatively you can buy a 128GB SSD, USB 3.0 external drive for $60 today (MyDigitalSSD MDMS-OTG-128, roughly 1" by 4"), which won't have the limitation of traditional USB flash drives, bigger but still handy sized. – maxpolk Jan 13 '16 at 19:22
  • Thanks for the tip... But for $60 I think I'm better off to buy a 1TB drive, clone the current installation, and install it and use the remaining space for Linux, then if/when I need to turn in the laptop I'll just put the original drive back in. Got the OK from IT manager so that makes the most sense. – acejavelin Jan 13 '16 at 19:43
  • Since we have compiled information here that is not specific to linux mint but applies to any linux distro, maybe you could change the title to "Run Linux from flash drive" so that people with similar problems are more likely to find it? – Shevek Feb 16 '16 at 9:53
  • @Shevek Males sense... Edited title – acejavelin Feb 16 '16 at 12:56
5

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 /etc/fstab
  • 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 /etc/rc.local (where <device> is the name of your usb device, i.e. sdb):
    echo noop > /sys/block/<device>/queue/scheduler
  • Use a ramdisk to store temporary data if you have enough RAM. Add the following lines to /etc/fstab :
    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/run and /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 /tmp.

  • 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 /etc/sysctl.conf:
    vm.swappiness=10  
  • 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.

  • You might add to /etc/fstab tmpfs mounts of /var/run, /var/lock, /var/log to reduce wear. So much writing goes to /var/log! Might need to add an init script to recreate certain subdirs of /var/log if some services complain they expected them. – maxpolk Jan 12 '16 at 4:43
  • Thanks for pointing that out! It makes total sense to move other directories with mostly temp data to tmpfs. I will include it into the answer as soon as I have time again. Only one constraint: I'd be extremely wary of losing logfile data, because this will reduce the possibilities of analyzing errors and render it impossible to track possible security breaches: I agree that logging is a source of frequent writes though, and depending on use case, logs may seem expendable. A compromise solution might be to move logs to another device... Hmm, have to give this some thought... – Shevek Jan 12 '16 at 10:27
  • @maxpolk: I have included additions/changes regarding /tmp, /var/tmp, /run, /var/run and /var/log. Also found two solutions for syncing data from /var/log to tmpfs and returning it before shutdown which seems like a good compromise to either losing all log data or having constant writes to the log directory on the physical drive. – Shevek Jan 13 '16 at 21:01
0

By lengthen the life of the drive do you mean the physical life of the drive or the inevitable build up of files on the drive due to the OS?

You say that you have considered the cache, but disabling the RAM and mounting a file on the HDD is counter-productive if you claim you want to do this "without changing anything in the computer". If it were me doing this I would simply leave the RAM enabled.

The things I would consider are:

  1. is the laptop new enough to have the "boot from USB" feature?
  2. would that feature be disabled by:
    • your organisation?
    • the laptop OEM?
  3. Would the specific drivers be available for that model of laptop?
  • I mean the life of the thumb drive, from writes mostly. What I meant by considered the cache was placing the cache on the flash drive, which could potentially shorten the flash drive's life considerably. Using as file on the HDD as a pseudo cache partition should be a viable alternative with 16GB of RAM. – acejavelin Jan 11 '16 at 16:30
  • The laptop is an HP Probook 650 G1 Core i5 w/16GB RAM which is plenty new enough and has excellent Linux support. By not changing anything I was referring to changing HDD partitioning or bootloader or anything that would effect the ability to use the laptop normally. I am a local administrator and we have the ability to use the device as we see fit, even for personal use, within a flexible set of guidelines – acejavelin Jan 11 '16 at 16:35
  • 1
    This seems more like a comment/request for clarification than an answer. – blm Jan 11 '16 at 18:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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