Create the S3-backed filesystem
1
Prepare S3 credentials
Create credentials with read, write, list, and delete access scoped to the bucket you want JuiceFS to use. Set the full bucket URL, access key ID, and secret access key in your host shell, then write only those values to a temporary file. The bucket URL can point to Amazon S3 or an S3-compatible provider such as Cloudflare R2 or MinIO.Do not commit
juicefs-s3.env. The sandbox receives the filtered file instead of your complete host environment.2
Create the helper scripts
Save the guest-side workflows as shell files on your host. Keeping them separate makes each later
msb exec command a single, readable action.mount-juicefs.sh
mount-juicefs.sh
mount-juicefs.sh
test-juicefs.sh
test-juicefs.sh
test-juicefs.sh
remount-juicefs.sh
remount-juicefs.sh
remount-juicefs.sh
cleanup-juicefs.sh
cleanup-juicefs.sh
cleanup-juicefs.sh
3
Create the sandbox
Boot Ubuntu with a 6 GiB root disk for the JuiceFS client, metadata database, and local cache. Copy the filtered credentials and register each helper under a short command name:The root disk keeps the metadata database when the sandbox stops and starts. Removing or replacing the sandbox removes that metadata, while the file data remains in S3.
4
Install and mount JuiceFS
Install FUSE and the official JuiceFS client:Format a new JuiceFS volume the first time this sandbox is used, then mount it at
/mnt/juicefs:--backup-meta 0 keeps this single-sandbox example’s metadata lifecycle explicit. It is also required when the S3-compatible provider is Cloudflare R2 because JuiceFS metadata backup relies on object-listing behavior that R2 does not provide.5
Test file operations
Create, read, append, rename, link, and concurrently write files through the mount. The script also saves the checksum of an 8 MiB payload for the remount test:All six checks should print
ok.6
Verify a cold remount
Unmount JuiceFS, clear its local cache, mount it again, and verify the payload against the saved checksum:The checksum should report
/mnt/juicefs/example/payload.bin: OK. Because the first cache was removed before remounting, this read verifies data persisted to S3 rather than only to the guest cache.7
Clean up or keep the filesystem
To retain the filesystem, stop and keep the sandbox together with the object prefix printed during mounting. The SQLite metadata on its root disk is required to interpret the objects in S3.To remove the example, delete its files through JuiceFS and unmount it first:Delete that exact prefix from the bucket with your provider’s console or S3 client, then remove the sandbox:Finally, remove the temporary credential file and clear its variables from the host shell:
Production considerations
- Replace SQLite with Redis, PostgreSQL, or another shared metadata engine before mounting the filesystem from multiple sandboxes.
- Scope the S3 credentials to the target bucket and grant only the object operations JuiceFS needs.
- Persist the metadata engine independently from the sandbox. S3 objects are not enough to reconstruct the complete filesystem namespace without metadata.
- Configure metadata backups for your provider. Keep
--backup-meta 0on R2 mounts and operate an explicit metadata backup process outside the R2 bucket.