2023-08-29 12:25:04 +00:00
---
slug: /en/operations/utilities/clickhouse-disks
sidebar_position: 59
sidebar_label: clickhouse-disks
---
2024-06-14 13:02:41 +00:00
# Clickhouse-disks
2023-08-29 12:25:04 +00:00
2024-06-14 13:02:41 +00:00
A utility providing filesystem-like operations for ClickHouse disks. It can work in both interactive and not interactive modes.
2023-08-29 12:25:04 +00:00
2024-06-14 13:02:41 +00:00
## Program-wide options
2023-08-29 12:25:04 +00:00
* `--config-file, -C` -- path to ClickHouse config, defaults to `/etc/clickhouse-server/config.xml` .
* `--save-logs` -- Log progress of invoked commands to `/var/log/clickhouse-server/clickhouse-disks.log` .
2024-09-22 15:02:46 +00:00
* `--log-level` -- What [type ](../server-configuration-parameters/settings#logger ) of events to log, defaults to `none` .
2023-08-29 12:25:04 +00:00
* `--disk` -- what disk to use for `mkdir, move, read, write, remove` commands. Defaults to `default` .
2024-06-14 13:02:41 +00:00
* `--query, -q` -- single query that can be executed without launching interactive mode
2024-06-14 14:20:49 +00:00
* `--help, -h` -- print all the options and commands with description
2024-06-14 13:02:41 +00:00
## Default Disks
After the launch two disks are initialized. The first one is a disk `local` that is supposed to imitate local file system from which clickhouse-disks utility was launched. The second one is a disk `default` that is mounted to the local filesystem in the directory that can be found in config as a parameter `clickhouse/path` (default value is `/var/lib/clickhouse` ).
## Clickhouse-disks state
For each disk that was added the utility stores current directory (as in a usual filesystem). User can change current directory and switch between disks.
2024-09-22 15:02:46 +00:00
State is reflected in a prompt "`disk_name`:`path_name`"
2023-08-29 12:25:04 +00:00
## Commands
2024-06-14 13:02:41 +00:00
In these documentation file all mandatory positional arguments are referred as `<parameter>` , named arguments are referred as `[--parameter value]` . All positional parameters could be mentioned as a named parameter with a corresponding name.
* `cd (change-dir, change_dir) [--disk disk] <path>`
Change directory to path `path` on disk `disk` (default value is a current disk). No disk switching happens.
* `copy (cp) [--disk-from disk_1] [--disk-to disk_2] <path-from> <path-to>` .
Recursively copy data from `path-from` at disk `disk_1` (default value is a current disk (parameter `disk` in a non-interactive mode))
to `path-to` at disk `disk_2` (default value is a current disk (parameter `disk` in a non-interactive mode)).
* `current_disk_with_path (current, current_disk, current_path)`
2024-09-22 15:02:46 +00:00
Print current state in format:
2024-06-14 13:02:41 +00:00
`Disk: "current_disk" Path: "current path on current disk"`
2024-06-14 13:54:12 +00:00
* `help [<command>]`
Print help message about command `command` . If `command` is not specified print information about all commands.
2024-06-14 13:02:41 +00:00
* `move (mv) <path-from> <path-to>` .
Move file or directory from `path-from` to `path-to` within current disk.
* `remove (rm, delete) <path>` .
Remove `path` recursively on a current disk.
* `link (ln) <path-from> <path-to>` .
Create a hardlink from `path-from` to `path-to` on a current disk.
* `list (ls) [--recursive] <path>`
List files at `path` s on a current disk. Non-recursive by default.
* `list-disks (list_disks, ls-disks, ls_disks)` .
2023-08-29 12:25:04 +00:00
List disks names.
2024-06-14 13:02:41 +00:00
* `mkdir [--recursive] <path>` on a current disk.
2023-08-29 12:25:04 +00:00
Create a directory. Non-recursive by default.
2024-06-14 13:02:41 +00:00
* `read (r) <path-from> [--path-to path]`
Read a file from `path-from` to `path` (`stdout` if not supplied).
* `switch-disk [--path path] <disk>`
2024-09-22 15:02:46 +00:00
Switch to disk `disk` on path `path` (if `path` is not specified default value is a previous path on disk `disk` ).
2024-06-14 13:02:41 +00:00
* `write (w) [--path-from path] <path-to>` .
2024-06-26 15:59:15 +00:00
Write a file from `path` (`stdin` if `path` is not supplied, input must finish by Ctrl+D) to `path-to` .