How can I efficiently force VirtualBox to use /dev/shm for all VM files?

2

SuperUsers. I want to preserve the life of my laptop's SSD drive. I make heavy use of Vagrant, Chef, and Virtualbox. I'm using Test Kitchen w/ Vagrant to run my infrastructure code tests. I am creating and destroying VMs all day, several times a day, sometimes in parallel. I'd like all of this ephemeral activity to happen on a tmpfs, like /dev/shm/, rather than chewing away at my write-limited SSD. I'm running GNU/Linux. I have 32 GB RAM, so would like to make heavy use of it! :)

There are so many locations where these programs store their files, that I was hoping someone out there has a magic symlink, bind mount, or similar that will just magically make this problem easy to solve. :) Any takers? Thanks in advance.

Jesse Adelman

Posted 2017-01-20T19:25:13.533

Reputation: 131

"I want to preserve the life of my laptop's SSD drive." - No need. Really. – Daniel B – 2017-01-20T19:28:35.863

Have you checked the total writes available on your SSD and the number you've used so far? You may be surprised at how much life you've got left even without this. – music2myear – 2017-01-31T19:54:38.343

3Hey, guys. I'm not really interested in being told don't bother. :) I'm looking for help with what I asked about. If I don't want to use a finite resource and use a practically infinite one, I should be able to do so. Ya feel me? – Jesse Adelman – 2017-02-01T21:09:25.663

Answers

1

OK, so I answered this myself, with help from https://www.virtualbox.org/manual/ch10.html .

$ cd ~/.VirtualBox/
$ mv Machines Machines.OFF
$ ln -s /dev/shm/ Machines

NOTE: If you are using a tool like Test Kitchen, and you find yourself faced with an error while purging a machine, undo this configuration and try again:

$ cd ~/.VirtualBox/
$ mv Machines Machines.LINK
$ mv Machines.OFF Machines

NOTE: Monitor available RAM closely. /dev/shm/ is a tmpfs mount on my system, with a default of half of the available physical RAM allocated. Make sure your virtual machines don't allocate more RAM than necessary. I'v'e got 32 GB real RAM, hence my interest in this. :)

Jesse Adelman

Posted 2017-01-20T19:25:13.533

Reputation: 131