Skip to content

Commit 2fb1755

Browse files
committed
Fix encrypted ZFS persistence issue
Problem: VMs with encrypted ZFS storage were reformatting the disk on every reboot, even with KMS or local key provider enabled. Root cause: The is_disk_initialized() check required both LUKS header AND zpool detection for encrypted ZFS (line 1057-1058). However, zpool import is attempted on the raw encrypted device (/dev/vdb1) before LUKS is opened, which always fails since the ZFS pool is inside the LUKS container. Solution: For any encrypted filesystem (ext4 or ZFS), only check for LUKS header presence, since the actual filesystem can only be detected after opening LUKS. This aligns encrypted ZFS handling with encrypted ext4, which was already using this approach. Testing: Verified that ext4 encrypted storage persists correctly with KMS key provider. ZFS testing pending after build completes.
1 parent 745b168 commit 2fb1755

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

dstack-util/src/system_setup.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,11 +1053,12 @@ impl<'a> Stage0<'a> {
10531053
}
10541054
};
10551055

1056-
// For encrypted ZFS, need both LUKS header AND zpool to exist
1057-
let initialized = if opts.storage_encrypted && opts.storage_fs == FsType::Zfs {
1058-
has_luks && has_fs
1056+
// For encrypted filesystems, we can only detect the filesystem after LUKS is opened
1057+
// So we rely on LUKS header presence as the indicator for both ext4 and ZFS
1058+
let initialized = if opts.storage_encrypted {
1059+
has_luks
10591060
} else {
1060-
has_luks || has_fs
1061+
has_fs
10611062
};
10621063

10631064
if !initialized {

0 commit comments

Comments
 (0)