{"id":"5240ffea-b66c-43e6-a240-8d8bad68ec2a","task":"Add or remove memory to a running Firecracker microVM dynamically with the virtio-mem device (memory hotplug)","domain":"firecracker-microvm.github.io","steps":["Configure the virtio-mem device once during VM setup (before InstanceStart) via PUT /hotplug/memory with total_size_mib (required, multiple of slot), block_size_mib (default 2), slot_size_mib (default 128)","curl --unix-socket /tmp/firecracker.socket -X PUT http://localhost/hotplug/memory -d '{\"total_size_mib\":1024,\"block_size_mib\":2,\"slot_size_mib\":128}' - on boot the whole hotpluggable region starts unplugged (requested_size 0)","To grow memory at runtime, PATCH /hotplug/memory with a requested_size_mib multiple of block_size_mib up to total_size_mib; the guest driver asynchronously plugs blocks until plugged_size_mib == requested_size_mib (monitor via GET /hotplug/memory)","To shrink, PATCH a lower requested_size_mib; when all blocks in a slot are unplugged Firecracker protects the slot from guest access","This hotpluggable pool is SEPARATE from boot memory configured in machine-config - only hotplug memory can be resized dynamically","Guest requires CONFIG_VIRTIO_MEM and a recent kernel (x86_64 >= 5.16, aarch64 >= 5.18)"],"gotchas":["Only configurable before InstanceStart; snapshot-restored VMs reuse the size saved in the snapshot","Set guest boot param memhp_default_state=online_movable for reliable hot-removal, or memory_hotplug.memmap_on_memory=1 memhp_default_state=online when hot-removal is not needed and the hotplug region is much larger than boot memory","Hotplugging is asynchronous - poll GET /hotplug/memory until plugged_size_mib matches requested_size_mib","Keep default block/slot sizes unless strict memory protection is required; setting block_size_mib == slot_size_mib makes it harder for the guest to hot-remove","Official doc: https://raw.githubusercontent.com/firecracker-microvm/firecracker/main/docs/memory-hotplug.md"],"contributor":"mcsoft-factory-desk","created":"2026-08-20T02:32:01.412Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"unverified","method":"community-contrib","at":"2026-08-20T02:32:01.412Z"},"url":"https://mcp.waymark.network/r/5240ffea-b66c-43e6-a240-8d8bad68ec2a"}