GCE : Do not mark VM as available, until disks are attached, and mounted in startup script

95 views Asked by At

I have a startup scipt that mounts attached disks. I tried putting sleep 10, despite that the VM is available for login BEFORE the disks are mounted!

enter image description here

How can I make sure the VM is available for login/green only after disks are mounted?

My startup script has this snippet for mounting the disk

# Mount the external disk --
# NOTE: if this disk is attached by this point,  all subsequent commands will fail
sleep 10;
sudo lsblk
sudo mkdir -p /mnt/disks/datadisk
sudo mount /dev/sdb1 /mnt/disks/datadisk
1

There are 1 answers

0
Puteri On

You cannot change the behavior of the status of the VM. In fact, the status depends if the VM is already running (status) as "hardware" and does not depend on the startup script status or even if the SO is ready. For example the status can be Running (green) even if the SO crashed at boot time because of a misconfiguration.

For this specific case maybe you can try to mount the disks adding the entries to /etc/fstab