diff --git a/RECIPE.md b/RECIPE.md index ecb068d2..71a54b39 100644 --- a/RECIPE.md +++ b/RECIPE.md @@ -190,6 +190,16 @@ Same as `format`, but formats an LVM logical volume. - *FsType* (`string`): The filesystem for the partition. Can be either `btrfs`, `ext[2,3,4]`, `linux-swap`, `ntfs`\*, `reiserfs`\*, `udf`\*, or `xfs`\*. - *Label* (optional `string`): An optional filesystem label. If not given, no label will be set. +### lvm-luks-format + +Same as `luks-format`, but formats an LVM logical volume. + +**Accepts**: +- *Name* (`string`): Thin logical volume name (in format `vg_name/lv_name`). +- *FsType* (`string`): The filesystem for the partition. Can be either `btrfs`, `ext[2,3,4]`, `linux-swap`, `ntfs`\*, `reiserfs`\*, `udf`\*, or `xfs`\*. +- *Password* (`string`): The password used to encrypt the volume. +- *Label* (optional `string`): An optional filesystem label. If not given, no label will be set. + --- ## Post-Installation diff --git a/core/recipe.go b/core/recipe.go index 560588ec..94e40ad6 100644 --- a/core/recipe.go +++ b/core/recipe.go @@ -125,10 +125,7 @@ func runSetupOperation(diskLabel, operation string, args []interface{}) error { // UUID, so we loop until it gives us one uuid := "" for uuid == "" { - uuid, err = part.GetUUID() - } - if err != nil { - return fmt.Errorf("failed to execute operation %s: %s", operation, err) + uuid, _ = part.GetUUID() } err = LuksOpen(part, fmt.Sprintf("luks-%s", uuid), luksPassword) if err != nil { @@ -271,6 +268,12 @@ func runSetupOperation(diskLabel, operation string, args []interface{}) error { if err != nil { return fmt.Errorf("failed to execute operation %s: %s", operation, err) } + // lsblk seems to take a few milliseconds to update the partition's + // UUID, so we loop until it gives us one + uuid := "" + for uuid == "" { + uuid, _ = part.GetUUID() + } err = LUKSMakeFs(&part) if err != nil { return fmt.Errorf("failed to execute operation %s: %s", operation, err) @@ -531,6 +534,53 @@ func runSetupOperation(diskLabel, operation string, args []interface{}) error { return fmt.Errorf("failed to execute operation %s: %s", operation, err) } } + /* !! ### lvm-luks-format + * + * Same as `luks-format`, but formats an LVM logical volume. + * + * **Accepts**: + * - *Name* (`string`): Thin logical volume name (in format `vg_name/lv_name`). + * - *FsType* (`string`): The filesystem for the partition. Can be either `btrfs`, `ext[2,3,4]`, `linux-swap`, `ntfs`\*, `reiserfs`\*, `udf`\*, or `xfs`\*. + * - *Password* (`string`): The password used to encrypt the volume. + * - *Label* (optional `string`): An optional filesystem label. If not given, no label will be set. + */ + case "lvm-luks-format": + name := args[0].(string) + filesystem := args[1].(string) + password := args[2].(string) + lv, err := lvm.FindLv(name) + if err != nil { + return fmt.Errorf("failed to execute operation %s: %s", operation, err) + } + dummyPart := Partition{ + Path: "/dev/" + lv.VgName + "/" + lv.Name, + Filesystem: PartitionFs(filesystem), + } + err = LuksFormat(&dummyPart, password) + if err != nil { + return fmt.Errorf("failed to execute operation %s: %s", operation, err) + } + // lsblk seems to take a few milliseconds to update the partition's + // UUID, so we loop until it gives us one + uuid := "" + for uuid == "" { + uuid, _ = dummyPart.GetUUID() + } + err = LuksOpen(&dummyPart, fmt.Sprintf("luks-%s", uuid), password) + if err != nil { + return fmt.Errorf("failed to execute operation %s: %s", operation, err) + } + err = LUKSMakeFs(&dummyPart) + if err != nil { + return fmt.Errorf("failed to execute operation %s: %s", operation, err) + } + if len(args) == 4 { + label := args[3].(string) + err := LUKSSetLabel(&dummyPart, label) + if err != nil { + return fmt.Errorf("failed to execute operation %s: %s", operation, err) + } + } /* !! --- */ default: return fmt.Errorf("unrecognized operation %s", operation) diff --git a/debian/changelog b/debian/changelog index b43233db..c78c8e45 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +albius (0.3.1) unstable; urgency=critical + + * LUKS on LVM support + + -- Mateus Melchiades Sat, 05 Nov 2023 11:47:00 -0300 + albius (0.3.0) unstable; urgency=critical * LVM support diff --git a/debian/files b/debian/files index 9922effb..255f140c 100644 --- a/debian/files +++ b/debian/files @@ -1 +1 @@ -albius_0.3.0_source.buildinfo devel extra +albius_0.3.1_source.buildinfo devel extra