Skip to content

Commit

Permalink
Opal: print descriptive error if format locks the drive.
Browse files Browse the repository at this point in the history
Some chipsets will set write-protection for the *full* drive
even if only small locking range is used.

As LUKS header expect to be writable ehen Opal LR is locked,
this is incompatible with LUKS.

Moreover, device need to be PSID reset and reconnected to clear
the flag. (And kernel lies about write protection so we cannot
get BLROGET ioctl to detect it.)

At least print some warning when LUKS2 header cannot be
written after Opal LR setup.

This applies for all USB adapters/firmware  with RTL9210 chipset.
(Need experimental patch to enable Opal through USB.)
  • Loading branch information
mbroz committed Aug 29, 2023
1 parent ab71eff commit 464fe98
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -2551,6 +2551,10 @@ int crypt_format_luks2_opal(struct crypt_device *cd,
log_err(cd, _("Cannot format device %s, permission denied."),
mdata_device_path(cd));
r = -EINVAL;
} else if (r == -EIO) {
log_err(cd, _("Cannot format device %s, OPAL device seems to be fully write-protected now."),
mdata_device_path(cd));
log_err(cd, _("This is perhaps a bug in firmware. Run OPAL PSID reset and reconnect for recovery."));
} else
log_err(cd, _("Cannot format device %s."),
mdata_device_path(cd));
Expand Down

0 comments on commit 464fe98

Please sign in to comment.