command_reference.md 11.3 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
`--enable-xattr`\
S
Suave Su 已提交
180 181
enable extended attributes (xattr) (default: false)

D
Davies Liu 已提交
182 183 184
`--read-only`\
allow lookup/read operations only (default: false)

185 186 187
`--subdir`\
mount a sub-directory as root (default: "")

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

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

194
`--io-retries value`\
S
Suave Su 已提交
195 196
number of retries after network failure (default: 30)

197
`--max-uploads value`\
S
Suave Su 已提交
198 199
number of connections to upload (default: 20)

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

203
`--prefetch value`\
204
prefetch N blocks in parallel (default: 1)
S
Suave Su 已提交
205

206
`--writeback`\
C
Changjian Gao 已提交
207
upload objects in background (default: false)
S
Suave Su 已提交
208

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

212
`--cache-size value`\
S
Suave Su 已提交
213 214
size of cached objects in MiB (default: 1024)

215
`--free-space-ratio value`\
S
Suave Su 已提交
216 217
min free space (ratio) (default: 0.1)

218
`--cache-partial-only`\
S
Suave Su 已提交
219 220
cache only random/small read (default: false)

221 222 223
`--open-cache value`\
open file cache timeout in seconds (0 means disable this feature) (default: 0)

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

`--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)

288 289 290
`--open-cache value`\
open file cache timeout in seconds (0 means disable this feature) (default: 0)

C
Changjian Gao 已提交
291 292 293 294 295 296 297 298 299
`--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)

300
### juicefs sync
301

302
#### Description
303 304 305

Sync between two storage.

306
#### Synopsis
307 308 309 310 311

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

312
#### Options
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 361 362 363

`--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 已提交
364

365
### juicefs rmr
D
Davies Liu 已提交
366

367
#### Description
D
Davies Liu 已提交
368 369 370

Remove all files in directories recursively.

371
#### Synopsis
D
Davies Liu 已提交
372 373 374 375 376

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

377
### juicefs info
378

379
#### Description
380 381 382

Show internal information for given paths or inodes.

383
#### Synopsis
384 385 386 387 388

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

389
#### Options
390 391

`--inode, -i`\
392
use inode instead of path (current dir should be inside JuiceFS) (default: false)
393 394


395
### juicefs bench
S
Suave Su 已提交
396

397
#### Description
S
Suave Su 已提交
398 399 400

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

401
#### Synopsis
S
Suave Su 已提交
402 403

```
404
juicefs bench [command options] PATH
S
Suave Su 已提交
405 406
```

407
#### Options
S
Suave Su 已提交
408

409
`--block-size value`\
S
Suave Su 已提交
410 411
block size in MiB (default: 1)

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

415
`--small-file-size value`\
S
Suave Su 已提交
416 417
size of small file in MiB (default: 0.1)

418
`--small-file-count value`\
419
number of small files (default: 100)
420

421
### juicefs gc
422

423
#### Description
424 425 426

Collect any leaked objects.

427
#### Synopsis
428 429

```
430
juicefs gc [command options] META-URL
431 432
```

433
#### Options
434 435 436 437

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

D
Davies Liu 已提交
438 439 440
`--compact`\
compact all chunks with more than 1 slices (default: false).

441
`--threads value`\
D
Davies Liu 已提交
442
number threads to delete leaked objects (default: 10)
443

444
### juicefs fsck
445

446
#### Description
447 448 449

Check consistency of file system.

450
#### Synopsis
451 452

```
453
juicefs fsck [command options] META-URL
454
```
S
Sandy Xu 已提交
455

456
### juicefs profile
S
Sandy Xu 已提交
457

458
#### Description
S
Sandy Xu 已提交
459

S
Sandy Xu 已提交
460
Analyze access log.
S
Sandy Xu 已提交
461

462
#### Synopsis
S
Sandy Xu 已提交
463 464 465 466 467

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

468
#### Options
S
Sandy Xu 已提交
469 470 471 472 473 474 475 476 477 478 479 480

`--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)
481

482
### juicefs status
483

484
#### Description
485 486 487

show status of JuiceFS

488
#### Synopsis
489 490

```
491
juicefs status [command options] META-URL
492 493
```

494
#### Options
495 496 497 498

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

499
### juicefs warmup
500

501
#### Description
502 503 504

build cache for target directories/files

505
#### Synopsis
506 507 508 509 510

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

511
#### Options
512 513 514 515 516 517 518 519 520

`--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 已提交
521

522
### juicefs dump
S
Sandy Xu 已提交
523

524
#### Description
S
Sandy Xu 已提交
525 526 527

dump metadata into a JSON file

528
#### Synopsis
S
Sandy Xu 已提交
529 530

```
531
juicefs dump [command options] META-URL [FILE]
S
Sandy Xu 已提交
532 533
```

534 535
When the FILE is not provided, STDOUT will be used instead.

536 537 538 539 540
#### Options

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

541
### juicefs load
S
Sandy Xu 已提交
542

543
#### Description
S
Sandy Xu 已提交
544 545 546

load metadata from a previously dumped JSON file

547
#### Synopsis
S
Sandy Xu 已提交
548 549

```
550
juicefs load [command options] META-URL [FILE]
S
Sandy Xu 已提交
551
```
552 553

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