Skip to content

Commit

Permalink
Add discard flags during format (#424)
Browse files Browse the repository at this point in the history
  • Loading branch information
Itxaka authored Jul 31, 2024
1 parent 7c93fed commit 33ce079
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
8 changes: 8 additions & 0 deletions pkg/lib/lock.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,19 @@ func formatLuks(device, name, mapper, label, pass string, logger zerolog.Logger)
if err != nil {
return fmt.Errorf("mkfs err: %w, out: %s", err, out)
}

l.Debug().Msg("discards")
out, err = SH(fmt.Sprintf("cryptsetup refresh --persistent --allow-discards %s", mapper))
if err != nil {
return fmt.Errorf("refresh err: %w, out: %s", err, out)
}

l.Debug().Msg("close")
out, err = SH(fmt.Sprintf("cryptsetup close %s", mapper))
if err != nil {
return fmt.Errorf("lock err: %w, out: %s", err, out)
}

return nil
}

Expand Down
1 change: 0 additions & 1 deletion pkg/lib/unlock.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ func LuksUnlock(device, mapper, password string) error {
return err
}
defer dev.Close()

err = dev.Unlock(0, []byte(password), mapper)
if err != nil {
return err
Expand Down

0 comments on commit 33ce079

Please sign in to comment.