How format bcachefs with compression for install Ubuntu?

Hello.
Thanks for reading my topic.
I want create an bcachefs partition for install Ubuntu.
I has used the command below, but not work if is added the option compression=zstd

sudo bcachefs format /dev/sda3 --data_replicas=1 --metadata_replicas=1 --replicas=1 compression=zstd=15

is showed the error message

Error opening device to format compression=zstd=15: No such file or directory

I want format an partition with compression and not file replication. I want only written 1 file for each file saved and not 1 file and 1 copy for each saved file.
I want install Ubuntu 24.04 in an bcachefs. Here is kernel 6.8. Is possible it ? How configure the fstab ?

How to do it ?
Thanks for any reply.

2 Likes

That is no small feat, some real nice info here: https://wiki.archlinux.org/title/Bcachefs#Multi_Device_fstab

And you will need to install rEFInd it won’t boot on Grub
I had much better luck on Arch.

inxi -F|grep fs
  Host: cachyos-bcahefs Kernel: 6.14.4-1-cachyos-bore arch: x86_64 bits: 64
  IF-ID-2: surfshark_ipv6 state: unknown speed: N/A duplex: N/A
  IF-ID-3: surfshark_wg state: unknown speed: N/A duplex: N/A mac: N/A
  ID-1: / size: 215.7 GiB used: 36.23 GiB (16.8%) fs: bcachefs dev: /dev/sdc2
  ID-2: /boot size: 2 GiB used: 524.6 MiB (25.7%) fs: vfat dev: /dev/sdc1

ls /boot
amd-ucode.img  initramfs-linux-cachyos-bore-fallback.img  refind_linux.conf
EFI            initramfs-linux-cachyos-bore.img           vmlinuz-linux-cachyos-bore

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a device; this may
# be used with UUID= as a more robust way to name devices that works even if
# disks are added and removed. See fstab(5).
#
# <file system>             <mount point>  <type>  <options>  <dump>  <pass>
UUID=5F0E-B00D                            /boot          vfat    defaults   0 2
UUID=40b9e0e7-c926-4ae0-ab2c-76869b78d3be /              bcachefs defaults,noatime 0 1
tmpfs                                     /tmp           tmpfs   defaults,noatime,mode=1777 0 0
~

My mounts look like:

 cat /proc/mounts
proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0
sys /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0
dev /dev devtmpfs rw,nosuid,relatime,size=6951832k,nr_inodes=1737958,mode=755,inode64 0 0
run /run tmpfs rw,nosuid,nodev,relatime,mode=755,inode64 0 0
efivarfs /sys/firmware/efi/efivars efivarfs rw,nosuid,nodev,noexec,relatime 0 0
devpts /dev/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
/dev/sdc2 / bcachefs rw,noatime, 0 0
securityfs /sys/kernel/security securityfs rw,nosuid,nodev,noexec,relatime 0 0
tmpfs /dev/shm tmpfs rw,nosuid,nodev,inode64 0 0
cgroup2 /sys/fs/cgroup cgroup2 rw,nosuid,nodev,noexec,relatime,nsdelegate,memory_recursiveprot 0 0
pstore /sys/fs/pstore pstore rw,nosuid,nodev,noexec,relatime 0 0
bpf /sys/fs/bpf bpf rw,nosuid,nodev,noexec,relatime,mode=700 0 0
systemd-1 /proc/sys/fs/binfmt_misc autofs rw,relatime,fd=40,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=10073 0 0
debugfs /sys/kernel/debug debugfs rw,nosuid,nodev,noexec,relatime 0 0
mqueue /dev/mqueue mqueue rw,nosuid,nodev,noexec,relatime 0 0
tracefs /sys/kernel/tracing tracefs rw,nosuid,nodev,noexec,relatime 0 0
hugetlbfs /dev/hugepages hugetlbfs rw,nosuid,nodev,relatime,pagesize=2M 0 0
fusectl /sys/fs/fuse/connections fusectl rw,nosuid,nodev,noexec,relatime 0 0
configfs /sys/kernel/config configfs rw,nosuid,nodev,noexec,relatime 0 0
tmpfs /run/credentials/systemd-resolved.service tmpfs ro,nosuid,nodev,noexec,relatime,nosymfollow,size=1024k,nr_inodes=1024,mode=700,inode64,noswap 0 0
tmpfs /tmp tmpfs rw,noatime,inode64 0 0
/dev/sdc1 /boot vfat rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro 0 0
tmpfs /run/credentials/systemd-journald.service tmpfs ro,nosuid,nodev,noexec,relatime,nosymfollow,size=1024k,nr_inodes=1024,mode=700,inode64,noswap 0 0
tmpfs /run/user/1000 tmpfs rw,nosuid,nodev,relatime,size=1415260k,nr_inodes=353815,mode=700,uid=1000,gid=1000,inode64 0 0
gvfsd-fuse /run/user/1000/gvfs fuse.gvfsd-fuse rw,nosuid,nodev,relatime,user_id=1000,group_id=1000 0 0
/dev/sde1 /run/media/me/Ventoy exfat rw,nosuid,nodev,relatime,uid=1000,gid=1000,fmask=0022,dmask=0022,iocharset=utf8,errors=remount-ro 0 0
portal /run/user/1000/doc fuse.portal rw,nosuid,nodev,relatime,user_id=1000,group_id=1000 0 0
run /run/firejail/dbus tmpfs rw,nosuid,nodev,noexec,relatime,mode=755,inode64 0 0
run /run/firejail/firejail.ro.dir tmpfs ro,nosuid,nodev,relatime,mode=755,inode64 0 0
run /run/firejail/firejail.ro.file tmpfs ro,nosuid,nodev,relatime,mode=755,inode64 0 0
/dev/sdd1 /run/media/me/Crucial-1TB ext4 rw,nosuid,nodev,relatime,errors=remount-ro 0 0

1 Like

Should that not be --compression= ?
I have never used bcachefs, but usually options start with two dashes --

The compression=zstd:15 setting does not directly work on bcachefs as it is currently implemented.

Instead, you can enable compression for the entire filesystem or on specific files or directories using the bcachefs setattr command. The compression level can be specified as an integer between 0 and 15, where 0 is the default level, 1 is the fastest with the lowest compression ratio, and 15 is the slowest with the best compression ratio.

Additionally, if you want to use more aggressive compression without impacting foreground writes, you can use the background_compression option. This allows data to be compressed or re compressed in the background by the re-balance thread.

bcachefs setattr  --help
Unknown command setattr
bcachefs - tool for managing bcachefs filesystems
usage: bcachefs <command> [<args>]

Superblock commands:
  format                   Format a new filesystem
  show-super               Dump superblock information to stdout
  recover-super            Attempt to recover overwritten superblock from backups
  set-fs-option            Set a filesystem option
  reset-counters           Reset all counters on an unmounted device

Mount:
  mount                    Mount a filesystem

Repair:
  fsck                     Check an existing filesystem for errors

Commands for managing a running filesystem:
  fs usage                 Show disk usage
  fs top                   Show runtime performance information

Commands for managing devices within a running filesystem:
  device add               Add a new device to an existing filesystem
  device remove            Remove a device from an existing filesystem
  device online            Re-add an existing member to a filesystem
  device offline           Take a device offline, without removing it
  device evacuate          Migrate data off of a specific device
  device set-state         Mark a device as failed
  device resize            Resize filesystem on a device
  device resize-journal    Resize journal on a device

Commands for managing subvolumes and snapshots:
  subvolume create         Create a new subvolume
  subvolume delete         Delete an existing subvolume
  subvolume snapshot       Create a snapshot

Commands for managing filesystem data:
  data rereplicate         Rereplicate degraded data
  data scrub               Verify checksums and correct errors, if possible
  data job                 Kick off low level data jobs

Encryption:
  unlock                   Unlock an encrypted filesystem prior to running/mounting
  set-passphrase           Change passphrase on an existing (unmounted) filesystem
  remove-passphrase        Remove passphrase on an existing (unmounted) filesystem

Migrate:
  migrate                  Migrate an existing filesystem to bcachefs, in place
  migrate-superblock       Add default superblock, after bcachefs migrate

Commands for operating on files in a bcachefs filesystem:
  set-file-option          Set various attributes on files or directories

Debug:
These commands work on offline, unmounted filesystems
  dump                     Dump filesystem metadata to a qcow2 image
  list                     List filesystem metadata in textual form
  list_journal             List contents of journal

Miscellaneous:
  completions              Generate shell completions
  version                  Display the version of the invoked bcachefs tool
bcachefs fs usage
Filesystem: 40b9e0e7-c926-4ae0-ab2c-76869b78d3be
Size:                   233597976064
Used:                    43291421696
Online reserved:             3500032

Data type       Required/total  Durability    Devices
reserved:       1/1                [] 41028096
btree:          1/1             1             [sdc2]             663486464
user:           1/1             1             [sdc2]           42582711296

Btree usage:
extents:           119537664
inodes:            223870976
dirents:            86245376
xattrs:               262144
alloc:              32505856
reflink:             1048576
subvolumes:           262144
snapshots:            262144
lru:                  524288
freespace:            524288
need_discard:         524288
backpointers:      106954752
bucket_gens:          262144
snapshot_trees:       262144
deleted_inodes:       262144
logged_ops:           262144
subvolume_children:   262144
accounting:         89653248

(no label) (device 0):          sdc2              rw
                                data         buckets    fragmented
  free:                 207860793344          792926
  sb:                        3149824              13        258048
  journal:                1983643648            7567
  btree:                   663486464            2531
  user:                  42582711296          165556     816800768
  cached:                          0               0
  parity:                          0               0
  stripe:                          0               0
  need_gc_gens:                    0               0
  need_discard:                    0               0
  unstriped:                       0               0
  capacity:             253910843392       
sudo bcachefs fsck  /dev/sdc2 
[sudo] password for me: 
Running fsck online
bcachefs (sdc2): check_alloc_info... done
bcachefs (sdc2): check_lrus... done
bcachefs (sdc2): check_btree_backpointers... done
bcachefs (sdc2): check_backpointers_to_extents... done
bcachefs (sdc2): check_extents_to_backpointers... done
bcachefs (sdc2): check_alloc_to_lru_refs... done
bcachefs (sdc2): check_snapshot_trees... done
bcachefs (sdc2): check_snapshots... done
bcachefs (sdc2): check_subvols... done
bcachefs (sdc2): check_subvol_children... done
bcachefs (sdc2): delete_dead_snapshots... done
bcachefs (sdc2): check_indirect_extents... done
bcachefs (sdc2): check_root... done
bcachefs (sdc2): check_subvolume_structure... done
bcachefs (sdc2): check_directory_structure... done

2 Likes

Thanks for all replies.
I reading all replies is as bcachefs not is still ready to be used as file system for Ubuntu partition.
I want change to bcachefs because BTRFS is very good in “paper”, but when the file system is damaged you are with serious problems even mainly if happen the terrible “parent transid” error being in some times fatal error. YOU LOST ALL FILES. NOT IS POSSIBLE FIX IT.

Have an nice week,