Skip to main content

Automation Deployment

After JuiceFS has been successfully mounted, you can automate this process to mount JuiceFS on multiple hosts. Several different approaches are introduced in this chapter.

You'll be needing your JuiceFS Token, and credentials for object storage, use them to run juicefs auth to generate a config file:

sudo juicefs auth myjfs --token xxxxx --accesskey xxxxx --secretkey xxxxx

The config file generated above is /root/.juicefs/myjfs.conf, which includes crucial information like the JuiceFS Token, Volume Name, and object storage access credentials:

"rootname": "myjfs",
"storage": "oss",
"region": "cn-shanghai",
"bucket": "",
"partitions": 0,
"replicated": false,
"compatible": false,
"public": false,
"blockSize": 4096,
"master": "",
"master_ip": [
"password": "xxxxx",
"compress": "lz4",
"accesskey": "xxxxx",
"secretkey": "xxxxx",
"tested": 1,
"token": "xxxxx"

Shell Script

Create a simple bash script, e.g.
set -e
curl -sSL -o /usr/local/bin/juicefs && chmod +x /usr/local/bin/juicefs
sudo juicefs auth "$1" --token "$2" --accesskey "$3" --secretkey "$4"
sudo juicefs mount "$1" "$5"

And then mount can be done without interaction by using the following command:


If your cloud service provider supports configuring bucket access policy for virtual machines, and achieve access to object storage without credentials (like AWS IAM), you can omit those keys during juicefs auth or juicefs mount (provide empty value), see juicefs auth for details.


Use below example to deploy JuiceFS with SaltStack:

- source:
- mode: 0755
- skip_verify: True

juicefs auth:
- name: /root/juicefs auth {{jfs_name}} --token {{jfs_token}} --accesskey={{accesskey}} --secretkey={{secretkey}}
- creates: /root/.juicefs/{{jfs_name}}.conf
- file: /root/juicefs

- device: {{jfs_name}}
- fstype: juicefs
- mkmnt: True
- opts: _netdev
# JuiceFS storage name is prefixed with JuiceFS:
- device_name_regex:
- JuiceFS:{{jfs_name}}
- cmd: juicefs auth


Use below example to deploy JuiceFS with Ansible:

- hosts: localhost
- set_fact:
# Change accordingly
jfs_bin: /usr/local/bin/juicefs
jfs_path: /jfs
jfs_name: jfs-volume
jfs_token: xxx
accesskey: xxx
secretkey: xxx

- get_url:
mode: 0755
dest: "{{jfs_bin}}"

- command: {{jfs_bin}} auth {{jfs_name}} --token {{jfs_token}} --accesskey={{accesskey}} --secretkey={{secretkey}}
creates: /root/.juicefs/{{jfs_name}}.conf

- name: Create symbolic for fstab
src: "{{jfs_bin}}"
dest: "/sbin/mount.juicefs"
state: link

- mount:
path: "{{jfs_path}}"
src: "{{jfs_name}}"
fstype: juicefs
opts: _netdev
state: mounted