Skip to main content
Modal containers start fast, but their files disappear when they exit. Mount an Archil disk in a Modal Sandbox and anything written there stays on the disk, where the next Sandbox can mount it and your app can read it with the Archil SDK, without starting any compute. archil mount uses FUSE, which Modal supports in VM Sandboxes (runtime="vm"). Modal Functions and Sandboxes on the default runtime can’t mount FUSE file systems. From those, read and write the disk with the Python SDK (get_object and put_object, with ARCHIL_API_KEY and ARCHIL_REGION in a Modal Secret), the same way the last step below reads it from your machine.

Prerequisites

Export your Archil API key and region, then install the Archil and Modal SDKs and sign in to Modal:

Mount a disk

First, create a disk and store its mount token in a Modal Secret. The token grants access to this disk only. You only do this once:
setup.py
Run it with eval "$(python setup.py)" to export the disk ID. Now start a VM Sandbox from an image with the archil client installed. The Sandbox mounts the disk at /mnt/archil, writes a file, and unmounts on exit:
sandbox.py
The archil client buffers recent writes, so the trap unmounts before the Sandbox exits, even if a command fails: archil unmount returns once every write has reached the disk. Run modal run sandbox.py twice. Each run starts a new Sandbox, and the second one finds the line the first one wrote:
A plain mount is exclusive: one Sandbox holds the disk at a time. To mount it in several Sandboxes at once, add --shared, and see Sharing disks.

Read it from anywhere

Both Sandboxes are gone, and the file is still on the disk. Read it from your own machine or app with the SDK:
read.py
If a Sandbox is terminated before it unmounts, see Troubleshooting mounts on other platforms.

Clean up

Delete the disk and the Modal Secret with python cleanup.py. Apps started with modal run stop on their own.
cleanup.py

Next steps