command_reference.md 11.2 KB
Newer Older
S
Suave Su 已提交
1 2
# Command Reference

3
There are many commands to help you manage your file system. This page provides a detailed reference for these commands.
S
Suave Su 已提交
4 5 6

## Overview

7
If you run `juicefs` by itself, it will print all available commands. In addition, you can add `-h/--help` flag after each command to get more information of it.
S
Suave Su 已提交
8

9 10
```bash
$ juicefs -h
S
Suave Su 已提交
11
NAME:
12
   juicefs - A POSIX file system built on Redis and object storage.
S
Suave Su 已提交
13 14 15 16 17

USAGE:
   juicefs [global options] command [command options] [arguments...]

VERSION:
S
Sandy Xu 已提交
18
   0.15-dev (2021-06-16 b5d0cd8)
S
Suave Su 已提交
19 20

COMMANDS:
21 22 23 24 25 26 27 28 29 30
   format   format a volume
   mount    mount a volume
   umount   unmount a volume
   gateway  S3-compatible gateway
   sync     sync between two storage
   rmr      remove directories recursively
   info     show internal information for paths or inodes
   bench    run benchmark to read/write/stat big/small files
   gc       collect any leaked objects
   fsck     Check consistency of file system
S
Sandy Xu 已提交
31
   profile  analyze access log
32 33
   status   show status of JuiceFS
   warmup   build cache for target directories/files
S
Sandy Xu 已提交
34 35
   dump     dump JuiceFS metadata into a standalone file
   load     load JuiceFS metadata from a previously dumped file
36
   help, h  Shows a list of commands or help for one command
S
Suave Su 已提交
37 38

GLOBAL OPTIONS:
39 40 41
   --verbose, --debug, -v  enable debug log (default: false)
   --quiet, -q             only warning and errors (default: false)
   --trace                 enable trace log (default: false)
42
   --no-agent              Disable pprof (:6060) and gops (:6070) agent (default: false)
43 44
   --help, -h              show help (default: false)
   --version, -V           print only the version (default: false)
S
Suave Su 已提交
45 46 47 48 49

COPYRIGHT:
   AGPLv3
```

50
> **Note**: If `juicefs` is not placed in your `$PATH`, you should run the script with the path to the script. For example, if `juicefs` is placed in current directory, you should use `./juicefs`. It is recommended to place `juicefs` in your `$PATH` for convenience.
51 52 53

## Auto Completion

54 55
> **Note**: This feature requires JuiceFS >= 0.15.0. It is implemented based on `github.com/urfave/cli/v2`. You can find more information [here](https://github.com/urfave/cli/blob/master/docs/v2/manual.md#enabling).

56 57 58 59 60 61 62 63 64 65 66 67 68
To enable commands completion, simply source the script provided within `hack/autocomplete`. For example:

Bash:

```bash
$ source hack/autocomplete/bash_autocomplete
```

Zsh:

```bash
$ source hack/autocomplete/zsh_autocomplete
```
S
Suave Su 已提交
69

70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
Please note the auto-completion is only enabled for the current session. If you want it for all new sessions, add the `source` command to `.bashrc` or `.zshrc`:

```bash
$ echo "source path/to/bash_autocomplete" >> ~/.bashrc
```

or

```bash
$ echo "source path/to/zsh_autocomplete" >> ~/.zshrc
```

Alternatively, if you are using bash on a Linux system, you may just copy the script to `/etc/bash_completion.d` and rename it to `juicefs`:

```bash
$ sudo cp hack/autocomplete/bash_autocomplete /etc/bash_completion.d/juicefs
$ source /etc/bash_completion.d/juicefs
```
S
Suave Su 已提交
88

89
## Commands
S
Suave Su 已提交
90

91
### juicefs format
S
Suave Su 已提交
92

93
#### Description
S
Suave Su 已提交
94

95
Format a volume. It's the first step for initializing a new file system volume.
S
Suave Su 已提交
96

97
#### Synopsis
S
Suave Su 已提交
98 99

```
100
juicefs format [command options] META-URL NAME
S
Suave Su 已提交
101 102
```

103
#### Options
S
Suave Su 已提交
104

105
`--block-size value`\
S
Suave Su 已提交
106 107
size of block in KiB (default: 4096)

108
`--compress value`\
109
compression algorithm (lz4, zstd, none) (default: "none")
S
Suave Su 已提交
110

D
Davies Liu 已提交
111 112 113 114 115 116
`--capacity value`\
the limit for space in GiB (default: unlimited)

`--inodes value`\
the limit for number of inodes (default: unlimited)

117 118 119
`--shards value`\
store the blocks into N buckets by hash of key (default: 0)

120
`--storage value`\
S
Suave Su 已提交
121 122
Object storage type (e.g. s3, gcs, oss, cos) (default: "file")

123
`--bucket value`\
124
A bucket URL to store data (default: `"$HOME/.juicefs/local"` or `"/var/jfs"`)
S
Suave Su 已提交
125

126 127
`--access-key value`\
Access key for object storage (env `ACCESS_KEY`)
S
Suave Su 已提交
128

129 130
`--secret-key value`\
Secret key for object storage (env `SECRET_KEY`)
S
Suave Su 已提交
131

132 133 134
`--encrypt-rsa-key value`\
A path to RSA private key (PEM)

135
`--force`\
S
Suave Su 已提交
136 137
overwrite existing format (default: false)

138 139 140
`--no-update`\
don't update existing volume (default: false)

141
### juicefs mount
S
Suave Su 已提交
142

143
#### Description
S
Suave Su 已提交
144

145
Mount a volume. The volume shoud be formatted first.
S
Suave Su 已提交
146

147
#### Synopsis
S
Suave Su 已提交
148 149

```
150
juicefs mount [command options] META-URL MOUNTPOINT
S
Suave Su 已提交
151 152
```

153
#### Options
S
Suave Su 已提交
154

155 156 157 158 159 160
`--metrics value`\
address to export metrics (default: "127.0.0.1:9567")

`--no-usage-report`\
do not send usage report (default: false)

161
`-d, --background`\
S
Suave Su 已提交
162 163
run in background (default: false)

164
`--no-syslog`\
S
Suave Su 已提交
165 166
disable syslog (default: false)

167
`-o value`\
168
other FUSE options (see [this document](fuse_mount_options.md) for more information)
S
Suave Su 已提交
169

170
`--attr-cache value`\
S
Suave Su 已提交
171 172
attributes cache timeout in seconds (default: 1)

173
`--entry-cache value`\
S
Suave Su 已提交
174 175
file entry cache timeout in seconds (default: 1)

176
`--dir-entry-cache value`\
S
Suave Su 已提交
177 178
dir entry cache timeout in seconds (default: 1)

179 180 181
`--open-cache value`\
open file cache timeout in seconds (default: 0)

182
`--enable-xattr`\
S
Suave Su 已提交
183 184
enable extended attributes (xattr) (default: false)

D
Davies Liu 已提交
185 186 187
`--read-only`\
allow lookup/read operations only (default: false)

188 189 190
`--subdir`\
mount a sub-directory as root (default: "")

191
`--get-timeout value`\
S
Suave Su 已提交
192 193
the max number of seconds to download an object (default: 60)

194
`--put-timeout value`\
S
Suave Su 已提交
195 196
the max number of seconds to upload an object (default: 60)

197
`--io-retries value`\
S
Suave Su 已提交
198 199
number of retries after network failure (default: 30)

200
`--max-uploads value`\
S
Suave Su 已提交
201 202
number of connections to upload (default: 20)

203 204
`--buffer-size value`\
total read/write buffering in MiB (default: 300)
S
Suave Su 已提交
205

206
`--prefetch value`\
207
prefetch N blocks in parallel (default: 1)
S
Suave Su 已提交
208

209
`--writeback`\
C
Changjian Gao 已提交
210
upload objects in background (default: false)
S
Suave Su 已提交
211

212
`--cache-dir value`\
213
directory paths of local cache, use colon to separate multiple paths (default: `"$HOME/.juicefs/cache"` or `"/var/jfsCache"`)
S
Suave Su 已提交
214

215
`--cache-size value`\
S
Suave Su 已提交
216 217
size of cached objects in MiB (default: 1024)

218
`--free-space-ratio value`\
S
Suave Su 已提交
219 220
min free space (ratio) (default: 0.1)

221
`--cache-partial-only`\
S
Suave Su 已提交
222 223
cache only random/small read (default: false)

224
### juicefs umount
D
Davies Liu 已提交
225

226
#### Description
D
Davies Liu 已提交
227

228
Unmount a volume.
D
Davies Liu 已提交
229

230
#### Synopsis
D
Davies Liu 已提交
231 232

```
S
Sandy Xu 已提交
233
juicefs umount [command options] MOUNTPOINT
D
Davies Liu 已提交
234 235
```

236
#### Options
D
Davies Liu 已提交
237 238

`-f, --force`\
239
unmount a busy mount point by force (default: false)
D
Davies Liu 已提交
240

241
### juicefs gateway
C
Changjian Gao 已提交
242

243
#### Description
C
Changjian Gao 已提交
244 245 246

S3-compatible gateway.

247
#### Synopsis
C
Changjian Gao 已提交
248 249

```
250
juicefs gateway [command options] META-URL ADDRESS
C
Changjian Gao 已提交
251 252
```

253
#### Options
C
Changjian Gao 已提交
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296

`--get-timeout value`\
the max number of seconds to download an object (default: 60)

`--put-timeout value`\
the max number of seconds to upload an object (default: 60)

`--io-retries value`\
number of retries after network failure (default: 30)

`--max-uploads value`\
number of connections to upload (default: 20)

`--buffer-size value`\
total read/write buffering in MiB (default: 300)

`--prefetch value`\
prefetch N blocks in parallel (default: 3)

`--writeback`\
upload objects in background (default: false)

`--cache-dir value`\
directory paths of local cache, use colon to separate multiple paths (default: `"$HOME/.juicefs/cache"` or `/var/jfsCache`)

`--cache-size value`\
size of cached objects in MiB (default: 1024)

`--free-space-ratio value`\
min free space (ratio) (default: 0.1)

`--cache-partial-only`\
cache only random/small read (default: false)

`--access-log value`\
path for JuiceFS access log

`--no-usage-report`\
do not send usage report (default: false)

`--no-banner`\
disable MinIO startup information (default: false)

297
### juicefs sync
298

299
#### Description
300 301 302

Sync between two storage.

303
#### Synopsis
304 305 306 307 308

```
juicefs sync [command options] SRC DST
```

309
#### Options
310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360

`--start KEY, -s KEY`\
the first KEY to sync

`--end KEY, -e KEY`\
the last KEY to sync

`--threads value, -p value`\
number of concurrent threads (default: 10)

`--http-port PORT`\
HTTP PORT to listen to (default: 6070)

`--update, -u`\
update existing file if the source is newer (default: false)

`--force-update, -f`\
always update existing file (default: false)

`--perms`\
preserve permissions (default: false)

`--dirs`\
Sync directories or holders (default: false)

`--dry`\
don't copy file (default: false)

`--delete-src, --deleteSrc`\
delete objects from source after synced (default: false)

`--delete-dst, --deleteDst`\
delete extraneous objects from destination (default: false)

`--exclude PATTERN`\
exclude keys containing PATTERN (POSIX regular expressions)

`--include PATTERN`\
only include keys containing PATTERN (POSIX regular expressions)

`--manager value`\
manager address

`--worker value`\
hosts (seperated by comma) to launch worker

`--bwlimit value`\
limit bandwidth in Mbps (0 means unlimited) (default: 0)

`--no-https`\
do not use HTTPS (default: false)
D
Davies Liu 已提交
361

362
### juicefs rmr
D
Davies Liu 已提交
363

364
#### Description
D
Davies Liu 已提交
365 366 367

Remove all files in directories recursively.

368
#### Synopsis
D
Davies Liu 已提交
369 370 371 372 373

```
juicefs rmr PATH ...
```

374
### juicefs info
375

376
#### Description
377 378 379

Show internal information for given paths or inodes.

380
#### Synopsis
381 382 383 384 385

```
juicefs info [command options] PATH or INODE
```

386
#### Options
387 388

`--inode, -i`\
389
use inode instead of path (current dir should be inside JuiceFS) (default: false)
390 391


392
### juicefs bench
S
Suave Su 已提交
393

394
#### Description
S
Suave Su 已提交
395 396 397

Run benchmark, include read/write/stat big and small files.

398
#### Synopsis
S
Suave Su 已提交
399 400

```
401
juicefs bench [command options] PATH
S
Suave Su 已提交
402 403
```

404
#### Options
S
Suave Su 已提交
405

406
`--block-size value`\
S
Suave Su 已提交
407 408
block size in MiB (default: 1)

409
`--big-file-size value`\
S
Suave Su 已提交
410 411
size of big file in MiB (default: 1024)

412
`--small-file-size value`\
S
Suave Su 已提交
413 414
size of small file in MiB (default: 0.1)

415
`--small-file-count value`\
416
number of small files (default: 100)
417

418
### juicefs gc
419

420
#### Description
421 422 423

Collect any leaked objects.

424
#### Synopsis
425 426

```
427
juicefs gc [command options] META-URL
428 429
```

430
#### Options
431 432 433 434

`--delete`\
deleted leaked objects (default: false)

D
Davies Liu 已提交
435 436 437
`--compact`\
compact all chunks with more than 1 slices (default: false).

438
`--threads value`\
D
Davies Liu 已提交
439
number threads to delete leaked objects (default: 10)
440

441
### juicefs fsck
442

443
#### Description
444 445 446

Check consistency of file system.

447
#### Synopsis
448 449

```
450
juicefs fsck [command options] META-URL
451
```
S
Sandy Xu 已提交
452

453
### juicefs profile
S
Sandy Xu 已提交
454

455
#### Description
S
Sandy Xu 已提交
456

S
Sandy Xu 已提交
457
Analyze access log.
S
Sandy Xu 已提交
458

459
#### Synopsis
S
Sandy Xu 已提交
460 461 462 463 464

```
juicefs profile [command options] MOUNTPOINT/LOGFILE
```

465
#### Options
S
Sandy Xu 已提交
466 467 468 469 470 471 472 473 474 475 476 477

`--uid value, -u value`\
track only specified UIDs(separated by comma ,)

`--gid value, -g value`\
track only specified GIDs(separated by comma ,)

`--pid value, -p value`\
track only specified PIDs(separated by comma ,)

`--interval value`\
flush interval in seconds (default: 2)
478

479
### juicefs status
480

481
#### Description
482 483 484

show status of JuiceFS

485
#### Synopsis
486 487

```
488
juicefs status [command options] META-URL
489 490
```

491
#### Options
492 493 494 495

`--session value, -s value`\
show detailed information (sustained inodes, locks) of the specified session (sid) (default: 0)

496
### juicefs warmup
497

498
#### Description
499 500 501

build cache for target directories/files

502
#### Synopsis
503 504 505 506 507

```
juicefs warmup [command options] [PATH ...]
```

508
#### Options
509 510 511 512 513 514 515 516 517

`--file value, -f value`\
file containing a list of paths

`--threads value, -p value`\
number of concurrent workers (default: 50)

`--background, -b`\
run in background (default: false)
S
Sandy Xu 已提交
518

519
### juicefs dump
S
Sandy Xu 已提交
520

521
#### Description
S
Sandy Xu 已提交
522 523 524

dump metadata into a JSON file

525
#### Synopsis
S
Sandy Xu 已提交
526 527

```
528
juicefs dump [command options] META-URL [FILE]
S
Sandy Xu 已提交
529 530
```

531 532
When the FILE is not provided, STDOUT will be used instead.

533 534 535 536 537
#### Options

`--subdir value`\
only dump a sub-directory.

538
### juicefs load
S
Sandy Xu 已提交
539

540
#### Description
S
Sandy Xu 已提交
541 542 543

load metadata from a previously dumped JSON file

544
#### Synopsis
S
Sandy Xu 已提交
545 546

```
547
juicefs load [command options] META-URL [FILE]
S
Sandy Xu 已提交
548
```
549 550

When the FILE is not provided, STDIN will be used instead.