Stop a VM instance in GCP with local SSD attached to it - google-cloud-platform

According to the documentation - https://cloud.google.com/compute/docs/disks/#localssds - it is not possible to stop and instance that has a local SSD. It merely acts as a cache memory.
Is it possible to get a local SSD for an instance which is persistent and allows us to stop the instance?
Also, are local SSDs and persistent SSDs detected as different hardware types by an instance?

At this moment there's no way to setup a GCE instance with a local SSD and be able to stop it, as is mentioned in the documentation this kind of storage is used to store caches and as processing space.
Now, about the hardware differences between a local SSD and a persistent SSD. Since the point of view of the GCE instance they are the same, I mean the instance detects the two of them just as another mount; however, the technology that behind each of them it's completely different.
A local SSD, just as the documentation states, is physically attached to the server where is hosted the instance while a persistent SSD it's just a Log-Structured Volume, in other words it's not a physical hard drive.
There's a complete explanation about how persistent disks works on Google Cloud at [1].
[1] https://www.youtube.com/watch?v=jA_A-OXsIss

WARNING stopping your VM will delete all data from the local disk
You can stop the VM from ssh with the commands
sudo shutdown -h now or sudo poweroff
This is the correct way to stop the VM if it has a local ssd attached.
https://cloud.google.com/compute/docs/instances/stop-start-instance

Related

Is volume in aws like a hard drive that the instance uses?

I am learning about aws and using ec2 instances. I am trying to understand what a volume is.
I have read from the aws site that:
An Amazon EBS volume is a durable, block-level storage device that you
can attach to your instances. After you attach a volume to an
instance, you can use it as you would use a physical hard drive.
Is it where things are stored when I install things like npm and node? Does it function like the harddrive o my server?
AWS EBS is block storage volume, and for the ease of understanding, yes you can consider it same as hard drive, however with more benefits over traditional hard drive. few of them are:
You can increase/decrease size of the storage as per your requirement
(Hence name Elastic)
You can add multiple ebs to your instances, for example 20 GB of volume1 and 30 GB of volume2
And for the question you asked if you can install npm & node yes you
can as it would be attached to your EC2 instance and your instance
can easily utilised attached data, modules,etc
For further explanation you can refer this user guide from AWS on EBS: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-volumes.html
Yes it is exactly like a hard drive on your server and you can have multiple devices.
The cool thing is that you also can expand them if you need extra space.
where things are stored when I install things like npm and node
Yes, technically ebs volume is virtual storage drive which is
connected to your instance through network, ( flash drive connected over network).
Since network is involved which implicitly means there will be some latency because of data transfer through network.
The data is persistent even if instance stops,terminates, hibernates or hardware failure.
Since it is network drive it can be attached or detached to any other instance.
Adding to this there is another type of storage which you will find called as instance store
You can specify instance store volumes for an instance only when you launch it. You can't detach an instance store volume from one instance and attach it to a different instance.
it gives very high IOPS because it is directly (physically) attached to instance.
The use case for instance store would where data changes rapidly like for cache or buffers.
Your data will be lost if any of these events happens like The underlying disk drive fails The instance stops, instance hibernates instance terminates or drive failure.

Google Cloud- New Disk while Creating VM-Redundancy Options

Referencing this as well:https://cloud.google.com/compute/docs/disks/regional-persistent-disk#repd_create_disk
It seems to imply that we cannot directly define the disk as having regional redundancy at time of creation of a VM(no such disk option visible). Only after creation of VM, we need to go to Storage Section and create disk with redundancy option and then attach it to VM.
2.Additionally,with regard to Local SSDs [which are non persistent], looks like we cannot randomly attach them while a VM is running, seems like option below appears only at time of VM creation?:
Kind regards,
Aditya
According to this article [1], regional persistent disk cannot be created as boot disk. And it need to be attached after the VM is created.
And for your second question, yes, you can add local SSD only during VM creation. According to this [2]:
"Local SSDs are located on the physical machine where your virtual machine instance is running, they can be created only during the instance creation process. Local SSDs cannot be used as boot devices"
[1] https://cloud.google.com/compute/docs/disks/regional-persistent-disk
[2] https://cloud.google.com/compute/docs/disks/local-ssd#create_local_ssd

Is it possible to attach usb to an instance?

Is it possible to attach usb to an instance? Just curious to know if it is possible to attach memory stick or external hard disk on GCP instance
It's not possible to attach USB (or any other storage device that you own) to a GCP VM instance.
Only supported storage solutions are described in the official documentation.
It's possible to attach a local SSD disk but it's just a temporary storage - in case of VM restart (or shutdown) data are lost (in most cases).
You could mount your own USB stick as a samba share but you'd have to run another machine somewhere where you can physically connect it and share it from.

How can one keep the data on a local SSD between stopping and restarting an instance

In my case I need only CPU compute for a while, and then at at the end I need GPUs. So I run the instance only with CPUs, then stop and restart with GPUs added (and CPUs reduced). However, it seems this will lead to the data on the local SSD being erased. Is there any way around that? Could one maybe back it up first with a snapshot for example and then restore the data to the local SSD after restarting the instance?
I have not tried out using local SSDs. I want to know what would happen.
You data may or may not survive machine restart - depending on how lucky on unlucky you are. Moreover, if your VM crashes (e.g. if underlying hardware fails) you may also lose contents of Local SSD at random time.
I don't think Local SSD implements snapshots or any sort of data redundancy functionality. You can however implement your own - e.g. you can partition your SSD using lvm, take lvm snapshots once in a while and upload them to e.g. GCS or store somewhere else.
In my experience, rebooting is typically fine, while shutting down will always result in data purge.
The easiest way I've found to backup and restore is to copy to/from a persistent drive or Google Cloud Storage. gsutil rsync works well for this. I don't believe snapshots work with local SSDs.
From google docs:
https://cloud.google.com/compute/docs/disks/local-ssd
Data on local SSDs persist only through the following events:
If you reboot the guest operating system.
If you configure your instance for live migration and the instance goes through a host maintenance event.
If the host system experiences a host error, Compute Engine makes a best effort to reconnect to the VM and preserve the local SSD data, but might not succeed. If the attempt is successful, the VM restarts automatically. However, if the attempt to reconnect fails, the VM restarts without the data. While Compute Engine is recovering your VM and local SSD, which can take up to 60 minutes, the host system and the underlying drive are unresponsive. To configure how your VM instances behave in the event of a host error, see Setting instance availability policies.
Data on Local SSDs does not persist through the following events:
If you shut down the guest operating system and force the instance to stop.
If you configure the instance to be preemptible and the instance goes through the preemption process.
If you configure the instance to stop on host maintenance events and the instance goes through a host maintenance event.
If the host system experiences a host error, and the underlying drive does not recover within 60 minutes, Compute Engine does not attempt to preserve the data on your local SSD. While Compute Engine is recovering your VM and local SSD, which can take up to 60 minutes, the host system and the underlying drive are unresponsive.
If you misconfigure the local SSD so that it becomes unreachable.
If you disable project billing. The instance will stop and your data will be lost.

Google Cloud - Local SSD hadware failure?

We are planning to use Google Cloud Local SSDs, because we need better IOPS than the persistent SSD disk have. We want to build a RAID5 array with 4 disks with mdamd (Linux). My question: how can we manage hardware failure with these disks? We can't unplug these disks, because we don't have phisycal access to the server. If we remove a disk with mdamd and add a new one, will it solve this problem?
Local SSD is an ephemeral storage space and is not a reliable storage method. For example, should the machine hosting your VM suffer from a hardware failure, your data will be lost and unrecoverable. The same is true if you stop the machine on purpose or accidentally.
RAID does not help, as your instance (and Google for that matter) will lose access to the data you stored on Local SSD once the instance stops running on that machine.