koverstreet / bcachefs

Other
680 stars 70 forks source link

Fatal error: Required key not available #640

Open djemilbakhti opened 8 months ago

djemilbakhti commented 8 months ago

dmesg:

[ 658.450073] bcachefs (180cb5a9-d16d-40ba-8fad-8f3cfed24ea5): error requesting encryption key: ENOKEY

root@archlinux /h/a1# mount /dev/sdb1 /mnt/ ERROR - bcachefs_rust::cmd_mount: Fatal error: Required key not available

RlndVt commented 8 months ago

This is a known issue:

https://lore.kernel.org/linux-bcachefs/Xp4_NQrvvUiIrrXXHjmhCQLmGSM2uRzN3CKOAHr1e1oridV3HcuggbV_xzRf4uNm7ASyP1QWITqf1zUtONlDh43tNRoKYHYS1hgD1kQxKoY=@protonmail.com/T/#u

https://lore.kernel.org/linux-bcachefs/CACmrr9gQeXccyS9ZRiR2KnTKnA6EVBCVz_YWcDC3p1mbGqgMSg@mail.gmail.com/

What worked for me is using -k session when unlocking the array.

jakobdettner commented 8 months ago

I have the same issue.

I have 1 ssd and 2 hdds passed to a Proxmox VM.

It works just fine when I create the filesystem and unlock it with:

# bcachefs format \
    --fs_label=Data \
    --data_checksum=xxhash \
    --metadata_checksum=xxhash \
    --replicas=2 \
    --encrypted \
    --background_compression=zstd \
    --label=hdd.hdd1 /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi4 \
    --label=hdd.hdd2 /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi5 \
    --discard \
    --label=ssd.ssd1 /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi2 \
    --foreground_target=ssd \
    --promote_target=ssd \
    --background_target=hdd
 ...
# bcachefs unlock -k session /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi2

The mount then works fine with:

# mount -t bcachefs /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi4:/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi5:/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi2 /data/

However, after a reboot when I try to unlock again I get:

# bcachefs unlock -k session /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi2
Error opening /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi2: Invalid argument

And dmesg shows:

# dmesg|grep bcachefs
[  256.797137] bcachefs (xxxxxxxx-xxxx-xxxx-xxxx-xxxx0bdfd330): error requesting encryption key: ENOKEY

System:

root@omv7:~# cat /etc/debian_version 
12.4
root@omv7:~# uname -a
Linux omv7 6.7.2 #1 SMP PREEMPT_DYNAMIC Sat Jan 27 23:46:41 CET 2024 x86_64 GNU/Linux
root@omv7:~# bcachefs version
bcachefs tool version v0.1-nogit
djemilbakhti commented 8 months ago

I have the same issue.

I have 1 ssd and 2 hdds passed to a Proxmox VM.

It works just fine when I create the filesystem and unlock it with:

# bcachefs format \
    --fs_label=Data \
    --data_checksum=xxhash \
    --metadata_checksum=xxhash \
    --replicas=2 \
    --encrypted \
    --background_compression=zstd \
    --label=hdd.hdd1 /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi4 \
    --label=hdd.hdd2 /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi5 \
    --discard \
    --label=ssd.ssd1 /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi2 \
    --foreground_target=ssd \
    --promote_target=ssd \
    --background_target=hdd
 ...
# bcachefs unlock -k session /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi2

The mount then works fine with:

# mount -t bcachefs /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi4:/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi5:/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi2 /data/

However, after a reboot when I try to unlock again I get:

# bcachefs unlock -k session /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi2
Error opening /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi2: Invalid argument

And dmesg shows:

# dmesg|grep bcachefs
[  256.797137] bcachefs (xxxxxxxx-xxxx-xxxx-xxxx-xxxx0bdfd330): error requesting encryption key: ENOKEY

System:

root@omv7:~# cat /etc/debian_version 
12.4
root@omv7:~# uname -a
Linux omv7 6.7.2 #1 SMP PREEMPT_DYNAMIC Sat Jan 27 23:46:41 CET 2024 x86_64 GNU/Linux
root@omv7:~# bcachefs version
bcachefs tool version v0.1-nogit

run as root keyctl link @u @s

jakobdettner commented 8 months ago

run as root keyctl link @U @s

This doesn't help or am I doing it wrong?:

# keyctl link @U @s
Unknown special key: '@U'
# keyctl link @u @s
# bcachefs unlock /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi2
Error opening /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi2: Invalid argument
djemilbakhti commented 8 months ago

run as root keyctl link @U @s

This doesn't help or am I doing it wrong?:

# keyctl link @U @s
Unknown special key: '@U'
# keyctl link @u @s
# bcachefs unlock /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi2
Error opening /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi2: Invalid argument

Screenshot_20240202_212707

jakobdettner commented 8 months ago

Thank you for your help. The problem is gone after building bcachefs-tools from https://github.com/koverstreet/bcachefs-tools and not using the debian version. After that I was able to unlock the drive without an error message and then mount. (keyctl link is not necessary).

root@omv7:~# bcachefs unlock /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi2Enter passphrase: 
root@omv7:~# mount -t bcachefs /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi4:/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi5:/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi2 /data/
root@omv7:~# lsblk|grep data
sdc      8:32   0  16.4T  0 disk /data
root@omv7:~# bcachefs version
1.4.0
root@omv7:~#