cryptsetup v2.8 does not allow slashes (#623)

* cryptsetup v2.8 does not allow slashes

Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com>

* add comment

Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com>

---------

Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com>
This commit is contained in:
Mauro Morales
2025-09-17 16:28:34 +02:00
committed by GitHub
parent c9ef4c6ccb
commit 19024b2a1e

View File

@@ -221,7 +221,9 @@ func formatLuks(device, name, mapper, label, pass string, logger types.KairosLog
// Refresh needs the password as its doing actions on the device directly
l.Debug().Msg("discards")
cmd := exec.Command("cryptsetup", "refresh", "--persistent", "--allow-discards", mapper)
// Note: cryptsetup v2.8+ expects the device name (not the device path) for the 'refresh' command.
// Using 'name' with v2.7 also works, hence why no fallback is needed for backward compatibility.
cmd := exec.Command("cryptsetup", "refresh", "--persistent", "--allow-discards", name)
cmd.Stdin = strings.NewReader(pass)
output, err := cmd.CombinedOutput()