title: Configure Linux to Suspend to Disk on ACPI G2 Soft Off -- so Google Compute Engine can suspend and restore preemptible machine via disk
body: <p><a href="https://cloud.google.com/compute/" rel="nofollow noreferrer">Google Compute Engine</a> rents all size Linux VMs from 1 core to 64 cores at various prices.  There are <a href="https://cloud.google.com/compute/docs/instances/preemptible" rel="nofollow noreferrer">"preempt-able" instances</a> for about 1/4 the price of guaranteed instances,  but the the preempt-able instances can be terminated at any time (with an ACPI G2 soft off warning and ~ 30 secs until hard cutoff). Although you can provide a startup and shutdown script, the usual approach seems to lead to the unnecessary overhead of having to then create additional software to allow calculations to be interrupted, and to manage partial results of calculations whereas the suspend-to-disk/restore-from-disk scheme seen in laptops and desktops could be a much simpler approach to storing and resuming calculations and therefore preferable. </p>
  
  <p>If I start a Linux preemptible VM on GCE, is it possible generally to suspend the state of the VM to the disk (aka hibernate) and restart a new preemptible VM from the disk afterwards? My idea is:</p>
  
  <ol>
  <li>Start a new preemptible Linux VM.</li>
  <li>When the OS receives the the preemption notice (ACPI G2 Soft Off signal), then trigger suspend the to disk - hibernate the Linux OS.</li>
  <li>Start a new preemptible Linux VM from the suspended image, i.e. restore the former VM and continue in the computation.</li>
  </ol>
  
  <p>How would I configure Linux to suspend/restore in this way?</p>