> ## 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.

# Mount on Linux

You can use the `archil` CLI to mount an Archil disk locally to an already running Linux server -- such as an Amazon EC2 instance,
a microVM sandbox, or a VPS.

Archil is compatible out-of-the-box with all programs that run on Linux, such as git, SQLite, or ffmpeg. For more details, see
[Application compatibility](https://docs.archil.com/details/support.md).

> [!NOTE]
>
> This article is for servers which are running their own Linux kernel. If you're trying to mount Archil into a container
> such as Docker, Podman, or a container platform (such as Amazon ECS) see [Mount in a container](https://docs.archil.com/mounting/containers.md).

## How the client mounts

The Linux client is a **FUSE** file system. `archil mount` runs in user space, serves the mount through the kernel's FUSE device, and talks to Archil's servers over Archil's own file protocol, encrypted with TLS. It doesn't use NFS or SMB, so no NFS client or kernel module other than FUSE is needed. On macOS, the client mounts through Apple's FSKit instead; see [Mount on macOS](https://docs.archil.com/mounting/macos.md).

## Requirements

Any Linux host can mount an Archil disk with `archil mount` if it meets these requirements. This applies to VMs,
containers, and other providers' sandboxes alike.

| Requirement | Details |
| - | - |
| CPU architecture | x86-64 or arm64. |
| Linux distribution | The installer supports distributions with `apt` (Debian, Ubuntu), RPM-based distributions, and Alpine (`apk`). It installs the client and the FUSE library it uses (`libfuse2`, `fuse-libs`, or `fuse`). |
| FUSE | The kernel's FUSE support, exposed as `/dev/fuse`. If `/dev/fuse` is missing, the installer runs `modprobe fuse`, and warns if the device still isn't there. `archil mount` doesn't check the kernel version. |
| Root | `archil mount` must run as root (uid 0), for example with `sudo`. Otherwise it exits with `The mount command requires root privileges`. |
| Permission to mount | The process must be allowed to mount a filesystem. In a container, that means access to `/dev/fuse` and the `CAP_SYS_ADMIN` capability, for example with `docker run --device /dev/fuse --cap-add SYS_ADMIN` or `--privileged`. Without it, the mount fails with `the kernel returned EINVAL (invalid argument)`. |
| Outbound network | TCP 8100 to the region's mount endpoint, such as `mount.green.us-east-1.aws.prod.archil.com`, and TCP 32050 to Archil's file servers, whose addresses the mount endpoint returns. Both use TLS. To install or upgrade the client, HTTPS to `s3.amazonaws.com`. No inbound ports are needed. |

A mounted disk persists only what is written under its mount point. The rest of the host's filesystem, including
packages you installed, stays on the host. In [Archil sandboxes](https://docs.archil.com/compute/sandboxes/introduction.md#root-filesystem-and-mounted-disks),
the root filesystem is itself on an Archil disk.

### Where mounting works

| Environment | Mounts? | Notes |
| - | - | - |
| Linux VMs and bare metal | Yes | Run `archil mount` with `sudo`. |
| [Archil sandboxes](https://docs.archil.com/compute/sandboxes/introduction.md#attaching-an-archil-disk) | Yes | Pass `mounts` when you create the sandbox; Archil mounts the disk for you. |
| Docker | With `--privileged` | Or mount on the host and bind-mount into the container. See [Mount in a container](https://docs.archil.com/mounting/containers.md). |
| Kubernetes | Yes | Use the [CSI driver](https://docs.archil.com/reference/csi-driver.md). |
| [E2B](https://docs.archil.com/guides/platforms/e2b.md) | Yes | Run the commands with `user: "root"`. |
| [Daytona](https://docs.archil.com/guides/platforms/daytona.md) | Yes | Run with `sudo`. `archil unmount` doesn't work; run `archil sync` and `archil checkin` instead. |
| [Vercel Sandbox](https://docs.archil.com/guides/platforms/vercel-sandbox.md) | Yes | Run the commands with `sudo: true`. |
| [Modal](https://docs.archil.com/guides/platforms/modal.md) | VM Sandboxes only | Modal Functions and Sandboxes on the default gVisor runtime fail with `Operation not permitted`. |
| [Cloud Run](https://docs.archil.com/guides/platforms/cloud-run.md) | Second-generation execution environment only | Deploy with `--execution-environment gen2`. |
| [Cloudflare Containers](https://docs.archil.com/guides/platforms/cloudflare-containers.md), [Sprites](https://docs.archil.com/guides/platforms/sprites.md), [exe.dev](https://docs.archil.com/guides/platforms/exe-dev.md) | Yes | |
| [AWS Lambda MicroVMs](https://docs.archil.com/guides/platforms/lambda-microvms.md) | Yes | Build the image with `--additional-os-capabilities ALL`. |
| AWS Lambda functions, Amazon ECS on Fargate | No | These don't let you mount a filesystem. Use [serverless execution](https://docs.archil.com/compute/serverless-execution.md) or the SDKs instead. |

Where you can't mount, you can still use the disk without FUSE or root: run commands next to it with
[serverless execution](https://docs.archil.com/compute/serverless-execution.md), or read and write files with the
[TypeScript](https://docs.archil.com/sdks/typescript.md#reading-and-writing-objects) or [Python](https://docs.archil.com/sdks/python.md#reading-and-writing-objects) SDK or
the [S3 API](https://docs.archil.com/protocols/s3-api.md).

## Mount a disk

**1. Install the client**

The `archil` client provides support for mounting Archil disks on Linux. First, install it on your server:

```bash theme={null}
curl -s https://archil.com/install | sh
```

**2. Authorize your server**

Each server that connects to the Archil disk needs to be authorized. You can managed which servers are authorized
in the Archil console, by navigating to the disk that you want to use, then selecting **Connections** in the left-bar,
and clicking **Add User** to authorize a new server.

Select **Disk Token**, and save the token somewhere you can retrieve it, you will not be able to see it again.

> [!NOTE]
>
> Archil disks also support *IAM authentication* for users mounting from within AWS. For more details on how disks
> authenticate users, see [Disk users](https://docs.archil.com/concepts/disk-users.md).

**3. Mount the disk**

First, create the directory that you intend to use to mount Archil:

```bash theme={null}
sudo mkdir -p /mnt/archil
```

Using the token that you just saved from the console, you can now mount the disk with `archil mount`.

```bash theme={null}
export ARCHIL_MOUNT_TOKEN="<disk-token>"
sudo --preserve-env=ARCHIL_MOUNT_TOKEN archil mount <disk-name> /mnt/archil --region <disk-region>
```

You can now use any Linux program against your Archil disk by navigating to `/mnt/archil`, and running commands.

## Upgrading the client

The `archil` CLI prints a notice when a newer release is available. To upgrade, run:

```bash theme={null}
sudo archil upgrade
```

To install patch releases automatically, see [`archil config`](https://docs.archil.com/reference/archil-cli#config).

## Disk ownership

By default, new Archil disks are owned by the root user (Linux `uid:0`). When you mount your disk to a folder such as
`/mnt/archil`, that folder will become owned by the root user.

When not running as the root user, you will see `EACCES: Permission denied` for file operations. You can change the owner
of the root directory with the command:

`sudo chown "$(id -u):$(id -g)" /mnt/archil`

The ownership change persists on the disk.

## Mounting on multiple hosts

By default, your disk is mounted in **exclusive-ownership** mode, and a second server can only mount it with `--read-only`.
To write to the disk from several servers, mount it on each one with `--conditional` or `--shared`. See
[Sharing Disks](https://docs.archil.com/concepts/sharing-disks.md) for how the modes compare.

When you mount an Archil disk with `--conditional`, every server can write to any part of the disk without calling
`archil checkout`. See [Conditional mode](https://docs.archil.com/concepts/sharing-disks.md#conditional-mode) for how writes from several servers
interact.

When you mount an Archil disk with `--shared`, each server can only write to paths it holds a delegation on. Creating a
file or directory, or opening a file for writing, takes one automatically; for anything else, call `archil checkout <path>`
before writing and `archil checkin <path>` after. Otherwise, the operation fails with `EROFS: Read-only file system`.

Each server caches what it reads, so it can briefly serve an older version of a file another server changed. See
[Consistency](https://docs.archil.com/details/consistency.md#between-archil-clients) for the exact rules.

## Ensuring that data is persisted on shutdown

Like all local file systems, Archil automatically stages recently written data in-memory until an explicit `fsync` or a periodic
background flush job writes it to durable storage. This means that recently-written data may not be persisted if a machine
is unexpectedly powered off.

Archil sandboxes automatically manage this persistence on shutdown. On other sandbox providers, make sure that you explicitly
call `archil unmount` before powering off the sandbox. See [Crashes and forced ownership](https://docs.archil.com/details/consistency.md#crashes-and-forced-ownership)
for what a client that stops without unmounting loses and leaves behind.

We recommend **always** using `archil unmount` instead of the built-in Linux `umount` command, which does not automatically flush
data to Archil's servers.

## Mount automatically on startup

If your service automatically launches new instances, such as in a load-based auto scaling group, you'll want to ensure that new
servers automatically mount Archil at startup. In addition to service startup scripts, you can achieve this by adding Archil
to the server's `/etc/fstab` with a line like the following:

```bash theme={null}
<disk-name> <mountpoint> archil _netdev,region=<region>,defaults 0 0
```

**Parameters:**

* `<disk-name>`: An owner-qualified disk name (`organization/disk-name` or `employee@email.com/disk-name`) or disk ID (`dsk-0123456789abcdef`).
* `<mountpoint>`: Local directory where the disk should be mounted (e.g., `/mnt/archil`).
* `archil`: Filesystem type for Archil disks.
* `_netdev`: Tells systemd this is a network filesystem that needs network connectivity before mount.
* `region=<region>`: The region your disk is in (e.g., `aws-us-east-1`).

Example:

```bash theme={null}
# /etc/fstab
myorg/mydisk /mnt/archil archil _netdev,region=aws-us-east-1,defaults 0 0
```


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