mirror of
https://github.com/kairos-io/kcrypt.git
synced 2025-09-03 16:07:07 +00:00
Add label to luks partition and dont gate on label (#471)
* Add label to luks partition and dont gate on label Instead of gating on labels, lets just add the label to the luks partition, the same way we do to the underlying unlocked partition, so they share the fs label. That way, the locking and unlocking refer to the same label always --------- Signed-off-by: Itxaka <itxaka@kairos.io>
This commit is contained in:
@@ -76,6 +76,7 @@ func Luksify(label string, logger types.KairosLogger, argsCreate ...string) (str
|
||||
device := fmt.Sprintf("/dev/%s", part)
|
||||
|
||||
extraArgs := []string{"--uuid", uuid.NewV5(uuid.NamespaceURL, label).String()}
|
||||
extraArgs = append(extraArgs, "--label", label)
|
||||
extraArgs = append(extraArgs, argsCreate...)
|
||||
|
||||
if err := CreateLuks(device, pass, extraArgs...); err != nil {
|
||||
@@ -207,10 +208,14 @@ func formatLuks(device, name, mapper, label, pass string, logger types.KairosLog
|
||||
return fmt.Errorf("mkfs err: %w, out: %s", err, out)
|
||||
}
|
||||
|
||||
// Refresh needs the password as its doing actions on the device directly
|
||||
l.Debug().Msg("discards")
|
||||
out, err = SH(fmt.Sprintf("cryptsetup refresh --persistent --allow-discards %s", mapper))
|
||||
cmd := exec.Command("cryptsetup", "refresh", "--persistent", "--allow-discards", mapper)
|
||||
cmd.Stdin = strings.NewReader(pass)
|
||||
output, err := cmd.CombinedOutput()
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("refresh err: %w, out: %s", err, out)
|
||||
return fmt.Errorf("refresh err: %w, out: %s", err, string(output))
|
||||
}
|
||||
|
||||
l.Debug().Msg("close")
|
||||
|
Reference in New Issue
Block a user