> ## Documentation Index
> Fetch the complete documentation index at: https://docs.archil.com/llms.txt
> Use this file to discover all available pages before exploring further.

# exe.dev

> Mount one Archil disk in many exe.dev VMs so they share files with each other and with the rest of your stack.

An [exe.dev](https://exe.dev/docs) VM is a persistent Linux machine you create and reach over SSH. Its disk belongs to that one VM. Mount an Archil disk in your VMs and they can all read and write the same files, which your other machines and the Archil SDK can reach too.

exe.dev VMs support FUSE and run systemd, so the disk mounts as a regular directory. Mount it with a systemd service, which mounts the disk when the VM boots and unmounts it when the VM shuts down.

## Prerequisites

* An exe.dev account with a plan, and your SSH key added to it. `ssh exe.dev whoami` should print your account.
* `jq` on your machine.
* An Archil disk in the [Archil region](https://docs.archil.com/reference/regions.md) of your choice.

Set your Archil API key and region:

```bash theme={null}
export ARCHIL_API_KEY=key-...
export ARCHIL_REGION=aws-us-west-2
```

Create the disk with the [`disk` CLI](https://docs.archil.com/reference/disk-cli). The output includes the disk ID and a one-time [mount token](https://docs.archil.com/concepts/authorization.md#token-based-disk-authorization), which grants access to this disk only:

```bash theme={null}
npx disk create exe-data
```

Export both for the steps below:

```bash theme={null}
export ARCHIL_DISK_ID=dsk-...
export ARCHIL_MOUNT_TOKEN=adt_...
```

## Mount the disk in a VM

Save this unit on your machine as `archil.service`. It mounts the disk at `/mnt/archil`, gives the `exedev` user ownership of it, and unmounts it when the service stops:

```ini archil.service theme={null}
[Unit]
Description=Mount Archil disk at /mnt/archil
Wants=network-online.target
After=network-online.target

[Service]
Type=oneshot
RemainAfterExit=yes
EnvironmentFile=/etc/archil/disk.env
ExecStartPre=mkdir -p /mnt/archil
ExecStart=archil mount ${ARCHIL_DISK_ID} /mnt/archil --region ${ARCHIL_REGION} --conditional
ExecStartPost=chown exedev:exedev /mnt/archil
ExecStop=archil unmount /mnt/archil

[Install]
WantedBy=multi-user.target
```

Create a VM and install the `archil` client in it. Answer `yes` if SSH asks to trust the new VM's host key:

```bash theme={null}
export VM=$(ssh exe.dev new --json | jq -r .ssh_dest)
ssh "$VM" 'curl -fsSL https://archil.com/install | sh'
```

Write the disk ID, region, and token to a file only root can read, then install and start the service:

```bash theme={null}
printf 'ARCHIL_DISK_ID=%s\nARCHIL_REGION=%s\nARCHIL_MOUNT_TOKEN=%s\n' "$ARCHIL_DISK_ID" "$ARCHIL_REGION" "$ARCHIL_MOUNT_TOKEN" \
  | ssh "$VM" 'sudo install -D -m 600 /dev/stdin /etc/archil/disk.env'
ssh "$VM" 'sudo install -m 644 /dev/stdin /etc/systemd/system/archil.service && sudo systemctl enable --now archil' < archil.service
```

Write a file to the disk:

```bash theme={null}
ssh "$VM" 'echo "Hello from $(hostname)" >> /mnt/archil/visits.log && cat /mnt/archil/visits.log'
```

```text theme={null}
Hello from orange-and-halfopen
```

## Share the disk between VMs

Create a second VM and repeat the same steps:

```bash theme={null}
export VM2=$(ssh exe.dev new --json | jq -r .ssh_dest)
ssh "$VM2" 'curl -fsSL https://archil.com/install | sh'
printf 'ARCHIL_DISK_ID=%s\nARCHIL_REGION=%s\nARCHIL_MOUNT_TOKEN=%s\n' "$ARCHIL_DISK_ID" "$ARCHIL_REGION" "$ARCHIL_MOUNT_TOKEN" \
  | ssh "$VM2" 'sudo install -D -m 600 /dev/stdin /etc/archil/disk.env'
ssh "$VM2" 'sudo install -m 644 /dev/stdin /etc/systemd/system/archil.service && sudo systemctl enable --now archil' < archil.service
ssh "$VM2" 'echo "Hello from $(hostname)" >> /mnt/archil/visits.log && cat /mnt/archil/visits.log'
```

Both VMs have the disk mounted at the same time, and the second one finds the line the first one wrote:

```text theme={null}
Hello from orange-and-halfopen
Hello from nightstand-delta
```

## How the disk behaves in a VM

**The mount uses conditional mode.** With `--conditional`, every VM can read and write anywhere on the disk at the same time, and none of them holds a lock that another VM has to wait for. See [Sharing disks](https://docs.archil.com/concepts/sharing-disks.md).

**Restarts need no special handling.** When the VM shuts down, systemd stops the service, which unmounts the disk and sends every buffered write to it. When the VM boots, systemd mounts the disk again.

**Stop the service to unmount.** `sudo systemctl stop archil` unmounts the disk until you run `sudo systemctl start archil`. To stop mounting it at boot, run `sudo systemctl disable --now archil`.

## Clean up

Delete the VMs and the disk once you no longer need them:

```bash theme={null}
ssh exe.dev rm "${VM%%.*}" "${VM2%%.*}"
npx disk delete "$ARCHIL_DISK_ID"
```

## Next steps

* [TypeScript SDK](https://docs.archil.com/sdks/typescript.md): read, write, and search the disk without mounting it.
* [Sharing disks](https://docs.archil.com/concepts/sharing-disks.md): how conditional mode and checkouts work.
* [`archil` CLI reference](https://docs.archil.com/reference/archil-cli): every `archil mount` option.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.