Boot Instance from Snapshot
Boot starts a brand-new VM from a snapshot's disk image (a cold boot). It restarts the operating system and does not preserve any in-memory process or other volatile state. Use boot when you want to change the machine configuration (vCPU, memory, disk) or create fresh instances from a snapshot. If you want to restore memory and running process state from a saved snapshot, use instance start instead.
Boot Instance from Snapshot
- Python
- TypeScript
- CLI
from morphcloud.api import MorphCloudClient
client = MorphCloudClient()
# Boot instance from snapshot with default settings
snapshot_id = "snapshot_your_snapshot_id" # Replace with a valid snapshot ID
instance = client.instances.boot(snapshot_id=snapshot_id)
print(f"Instance ID: {instance.id}")
print(f"Instance Status: {instance.status}")
import { MorphCloudClient } from 'morphcloud';
const client = new MorphCloudClient();
async function bootFromSnapshot() {
const snapshot_id = "snapshot_your_snapshot_id"; // Replace with a valid snapshot ID
const instance = await client.instances.boot({ snapshot_id: snapshot_id });
console.log(`Instance ID: ${instance.id}`);
console.log(`Instance Status: ${instance.status}`);
}
bootFromSnapshot();
# Boot instance from snapshot
morphcloud snapshot boot snapshot_your_snapshot_id
Boot with Custom Resource Specifications
You can override the snapshot's default resource specifications when booting:
- Python
- TypeScript
- CLI
from morphcloud.api import MorphCloudClient
client = MorphCloudClient()
snapshot_id = "snapshot_your_snapshot_id" # Replace with a valid snapshot ID
# Boot with custom resource specifications
instance = client.instances.boot(
snapshot_id=snapshot_id,
vcpus=4, # Override CPU cores
memory=4096, # Override memory (MB)
disk_size=20480, # Override disk size (MB)
)
print(f"Instance ID: {instance.id}")
print(f"vCPUs: {instance.spec.vcpus}")
print(f"Memory: {instance.spec.memory}MB")
print(f"Disk Size: {instance.spec.disk_size}MB")
import { MorphCloudClient } from 'morphcloud';
const client = new MorphCloudClient();
async function bootWithCustomSpecs() {
const snapshot_id = "snapshot_your_snapshot_id"; // Replace with a valid snapshot ID
// Boot with custom resource specifications
const instance = await client.instances.boot({
snapshot_id: snapshot_id,
vcpus: 4, // Override CPU cores
memory: 4096, // Override memory (MB)
disk_size: 20480, // Override disk size (MB)
});
console.log(`Instance ID: ${instance.id}`);
console.log(`vCPUs: ${instance.spec.vcpus}`);
console.log(`Memory: ${instance.spec.memory}MB`);
console.log(`Disk Size: ${instance.spec.disk_size}MB`);
}
bootWithCustomSpecs();
# Boot with custom resource specifications
morphcloud snapshot boot snapshot_your_snapshot_id \
--vcpus 4 \
--memory 4096 \
--disk-size 20480
Boot with Time-to-Live (TTL) Settings
Set automatic expiration for instances by configuring TTL settings:
- Python
- TypeScript
- CLI
from morphcloud.api import MorphCloudClient
client = MorphCloudClient()
snapshot_id = "snapshot_your_snapshot_id" # Replace with a valid snapshot ID
# Boot instance with TTL settings
instance = client.instances.boot(
snapshot_id=snapshot_id,
ttl_seconds=3600, # Instance expires in 1 hour
ttl_action="pause" # Pause instead of stop when TTL expires
)
print(f"Instance ID: {instance.id}")
print(f"TTL: 1 hour (will be paused when expired)")
import { MorphCloudClient } from 'morphcloud';
const client = new MorphCloudClient();
async function bootWithTTL() {
const snapshot_id = "snapshot_your_snapshot_id"; // Replace with a valid snapshot ID
// Boot instance with TTL settings
const instance = await client.instances.boot({
snapshot_id: snapshot_id,
ttl_seconds: 3600, // Instance expires in 1 hour
ttl_action: "pause" // Pause instead of stop when TTL expires
});
console.log(`Instance ID: ${instance.id}`);
console.log("TTL: 1 hour (will be paused when expired)");
}
bootWithTTL();
# Boot instance with TTL settings
morphcloud snapshot boot snapshot_your_snapshot_id \
--ttl-seconds 3600 \
--ttl-action pause
Best Practices
- Verify snapshot exists before attempting to boot
- Set appropriate TTL to avoid unexpected costs
- Use custom resources only when necessary
- Monitor boot status for mission-critical instances
If new files don’t show up after booting from a snapshot, run Linux sync
inside the VM before creating the snapshot to flush pending writes:
# inside the VM (or via exec)
sudo sync
Booting from snapshots provides a quick way to create instances with pre-configured disk state, ideal for scaling applications and resizing into different resources. For restoring active memory/process state, prefer instance start.