change vmboxes location drive gnome
Image: cendeced/Adobe Stock

Boxes is a great tool for easily spinning up virtual machines on Linux. With Boxes, you can create virtual machines from several pre-configured machines or even from your own ISO. Those VMs run smoothly and seamlessly, and can be spun up much faster than when using a tool like VirtualBox.

SEE: 40+ open source and Linux terms you need to know (TechRepublic Premium)

But while Boxes is incredibly easy to use, it’s also not nearly as flexible as other solutions. Case in point, there isn’t even a Preferences option in the limited menu. All you can do is create virtual machines.

That shouldn’t be a deal breaker for anyone. However, I recently ran into an issue. On my production machine, my primary drive was getting dangerously low on space. It turns out, a big part of that problem was Boxes. Why? Because Boxes stores the virtual machine files in ~/.local/share/gnome-boxes, which means it’s going to gobble up your local storage space fairly quickly. Given GNOME Boxes doesn’t have any preferences to speak of, what do you do?

Remember, this is Linux, so there’s always a way. Let me show you how.

What you’ll need to change the drive location for GNOME Boxes

The only things you’ll need for this are a separate drive that will house the new GNOME Boxes location. That drive will also need to be accessible (with full read/write permissions) by the user who runs Boxes. Let’s make it happen.

How to relocate the GNOME Boxes directory

For my demonstration, I’m going to be moving the directory to an external drive that is mounted permanently via fstab in /media/jack/HALEY/. To do this, log in to your Linux machine and open a terminal window.

From the terminal window move the GNOME Boxes directory to the destination with the command:

mv ~/.local/share/gnome-boxes /path/to/directory

Where /path/to/directory is the destination. In my case, that would be:

mv ~/.local/share/gnome-boxes /media/jack/HALEY

Once you’ve moved the directory, you then have to create a symbolic link in the original location that points to the new destination. In my case, that command would be:

ln -s /media/jack/HALEY/gnome-boxes/ ~/.local/share/gnome-boxes

Remember to change the path to the new directory according to your needs, so it would be:

ln -s /path/to/directory ~/.local/share/gnome-boxes

Now, when you create a new virtual machine, it will be stored in the new destination instead of taking up precious space in your primary drive.

Congratulations, you’ve just prevented GNOME Boxes from causing you untold headaches. Maybe someday, in future releases, the developers will make it possible to relocate the storage location outside of the user’s HOME. In the meantime, you have the means to avoid the issue.

Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the latest tech advice for business pros from Jack Wallen.

Subscribe to the Developer Insider Newsletter

From the hottest programming languages to commentary on the Linux OS, get the developer and open source news and tips you need to know. Delivered Tuesdays and Thursdays

Subscribe to the Developer Insider Newsletter

From the hottest programming languages to commentary on the Linux OS, get the developer and open source news and tips you need to know. Delivered Tuesdays and Thursdays