Feargal
Feargal

Reputation: 118

Mount persistent disks on instance restart

I have a server that has a persistent disk that I mounted with safe_format_and_mount. When I restarted the instance that the disk did not get mounted automatically, which I now see is a feature from looking at the docs. It is suggested to put the safe mount command into the google startup script.

However I did not start this instance with a startup script. Is there any way I can do this now? I do not see that there is.

Alternatively I can try and use safe_format_and_mount in the upstart script for the service that needs the disk, in this case MongoDB. I have the feeling that unless I create a new instance with a startup script that this is my best option.

Upvotes: 1

Views: 931

Answers (1)

koma
koma

Reputation: 6566

Add meta data to you compute engine instance with key startup-script and value the bash script to mount the drive. That's it. The key is a reserved word and GCE will execute the value as a bash script.

You can add the meta data to an already existing instance.

Upvotes: 3

Related Questions