2023-10-01 12:40:23 +03:00
|
|
|
# bcachefs
|
|
|
|
|
|
|
|
> Manage `bcachefs` filesystems/devices.
|
2024-09-21 16:46:03 +03:00
|
|
|
> Some subcommands such as `device` have their own usage documentation.
|
|
|
|
> More information: <https://bcachefs-docs.readthedocs.io/en/latest/index.html>.
|
2023-10-01 12:40:23 +03:00
|
|
|
|
|
|
|
- Format a partition with `bcachefs`:
|
|
|
|
|
|
|
|
`sudo bcachefs format {{path/to/partition}}`
|
|
|
|
|
|
|
|
- Mount a `bcachefs` filesystem:
|
|
|
|
|
|
|
|
`sudo bcachefs mount {{path/to/partition}} {{path/to/mountpoint}}`
|
|
|
|
|
|
|
|
- Create a RAID 0 filesystem where an SSD acts as a cache and an HDD acts as a long-term storage:
|
|
|
|
|
2025-06-27 15:33:04 +03:00
|
|
|
`sudo bcachefs format {{[-l|--label]}} {{ssd.ssd1}} {{path/to/ssd/partition}} {{[-l|--label]}} {{hdd.hdd1}} {{path/to/hdd/partition}} --replicas 1 --foreground_target {{ssd}} --promote_target {{ssd}} --background_target {{hdd}}`
|
2023-10-01 12:40:23 +03:00
|
|
|
|
|
|
|
- Mount a multidevice filesystem:
|
|
|
|
|
|
|
|
`sudo bcachefs mount {{path/to/partition1}}:{{path/to/partition2}} {{path/to/mountpoint}}`
|
|
|
|
|
|
|
|
- Display disk usage:
|
|
|
|
|
2025-06-27 15:33:04 +03:00
|
|
|
`bcachefs fs usage {{[-h|--human-readable]}} {{path/to/mountpoint}}`
|
2023-10-01 12:40:23 +03:00
|
|
|
|
2024-08-20 22:08:51 +03:00
|
|
|
- Set replicas after formatting and mounting:
|
|
|
|
|
2025-06-27 15:33:04 +03:00
|
|
|
`sudo bcachefs set-fs-option --metadata_replicas {{2}} --data_replicas {{2}} {{path/to/partition}}`
|
2024-08-20 22:08:51 +03:00
|
|
|
|
|
|
|
- Force `bcachefs` to ensure all files are replicated:
|
|
|
|
|
|
|
|
`sudo bcachefs data rereplicate {{path/to/mountpoint}}`
|
|
|
|
|
2025-05-09 20:44:42 +03:00
|
|
|
- Create a snapshot of a particular directory:
|
2023-10-01 12:40:23 +03:00
|
|
|
|
2025-05-09 20:44:42 +03:00
|
|
|
`bcachefs subvolume snapshot {{path/to/directory}} {{path/to/snapshot}}`
|