Posted by & filed under Computers & Internet.

I use VirtualBox for testing a couple of web applications. But I found myself using the same image for two different projects, but switching the memory back and forth between 512mb and 2gb. 512mb was more than enough for one of the projects; but the other, running a Dockerized version of Canvas; would use every bit of the 2gb.

First task was to come up with a way to quickly switch between 512mb and 2gb without going through the menus in VirtualBox.

The other tweak I wanted to make was running the VM headless. Yes, I can right click on the VM in VirtualBox and start it up headless. But I tended to forget.

Enter VBoxManage and batch files.

Here’s the batch file that starts up the 512mb VM.

It calls the VBoxManage file to set the memory, starts the VM, waits for a keypress, and then turns off the VM. That lets me just have a small console window open instead of the full VirtualBox app.

And here’s the one for the 2gb VM.

Same thing except the numbers change in a couple of places.

Now, I just SSH into the box and everything is slick. And as a bonus, my computer doesn’t seem to slow down as much.

Leave a Reply

Your email address will not be published. Required fields are marked *