How I used VirtualBox snapshots to create my ultimate Linux post install script
I have always wanted a really awesome Linux post install script to automatically install and set up everything I need to start being a productive web developer within an hour after installing Linux.
I have a few reasons for this:
- It’s cool
- I saw thoughtbot created an OSX laptop script (aka, it’s cool)
- I don’t like doing tedious, repetitive tasks, which is also why I love programming.
- It breaks focus when I am in the middle of coding something and I need to apt-get install some dependancy.
- Installing stuff manually can waste a lot of time, because while I wait for it to download or install I can get distracted.
- I have taught a lot of people to code and really love getting people started. Windows is great but I don’t do development on it, so if you want to “follow me” then I will help you set up your Linux environment so that it is ready to start coding. This means I actually get to use my install script quite often.
- It gives me the freedom to try out different distros whenever I want. As long as I install Linux at the end of the day and set my script to run, I don’t lose any time.
One challenge I always had with not getting my install script tuned quite the way I needed it, was that even while running a bootcamp, I use it less than once per week. So if I needed 25 iterations to get it where I wanted it, that’s over half a year. The other problem is that if something fails halfway through installing things, you can’t fix it and see it working in it’s fixed state, you have to fix it and wait for next time to see the results, which kills motivation. I was slowly making my way through this process with no end in sight when I got annoyed and decided to solve this once and for all.
Enter, VirtualBox Snapshots
It’s like Git for a Virtual Machine. It allowed me take a couple of hours and run my script many times over.
Here are the steps I took:
- Install Linux Mint in a VirtualBox (I switched from Ubuntu to Mint as my main distro this year).
- Take a Snapshot.
- Run my script.
- When something fails I fix the part of the script that caused it to fail.
- Restore to the snapshot. (This is instant on an SSD).
- Repeat steps 3-5 until the whole thing runs without any problems.
Here is my current post-install script. linux-laptop