### Initialisation script to set up VM from cold start

Just having a nicely configured VM doesn’t anwer the whole question in a machine learning scenario. In particular, using preemptible machines means that the VM is hard-stopped at minimum every 24hrs, and a typical way to do training, etc, involves setting up screen to allow for clear disconnects.

So, in addition to mounting an extra drive, wouldn’t it be nice to get some screen sessions going with the correct paths, virtualenv already running, and ready-to-roll?

#### Create a startup script locally

Create this script as a local file startup.bash (clearly, your details will be very different, but some essential elements are included here) :

#### Create a ‘startup hook’ for the GCP machine

Post that script to the VM using the gcloud add-metadata command from your local machine :

#### Test that it works

Go on! Just start an instance and see whether it works!

If you need to change the script, just make the changes locally, and redo the add-metadata step : It seems to replace what was there before. Then, you’ll have to stop and start the instance again - best done during down-time, rather than when hot on the trail of the latest model…