Ubuntu – How to make an existing persistant live USB installation load more of the OS to RAM


A while back I installed (a permanent installation, not a Live USB) Ubuntu on my USB thumb drive. Unfortunately, the transfer rates are too slow for a smooth and responsive experience, so I'd like to load more of the OS into RAM when it boots up, kind of like a Live USB.

The problem is that while a typical Live USB created from the standard desktop .iso will probably fit in 2 GB of RAM when the OS (/casper/filesystem.squashfs?) is fully uncompressed and loaded, my installation is nearly 5 GB in size, and my computer only has 2GB of RAM. However, much of the installation consists of texlive packages and other files which I definitely use, but use rarely. In reality, the commonly used apps and files are so little that their total size could probably fit in RAM easily.

Is it possible to modify my already existing (permanent) Ubuntu installation on a USB thumb drive such that I can specify which folders should load to RAM (and which ones can be excluded), as I don't believe I can fit the whole OS into 2GB of RAM. I mainly want my browser, shell, and common shell commands to be fast. /home is not very important when it comes to performance.

I've partitioned the USB drive as follows, if it helps:

  • boot (/boot)
  • root (/)
  • home partition (/home)
  • swap

Also, I've taken a look at a Boot to RAM page on the Ubuntu website, but the focus there seems to be for customizing a LiveCD image.

Best Answer

Check out these instructions. To summarize:

  1. align the partitions with the SD card erase block size (so the filesystems are aligned when created).
  2. Move directories like /tmp and /var/log to RAM by making fstab entries. Also turn off access time tracking for / with the noatime option in fstab.
  3. Link other directories like /var/cache/apt/archive and your browser cache to a place in /tmp.
  4. Make RAM home based users for quickest access -- you may not explicitly write much in your home directory, but the GUI and browser certainly do.