curtin-dev team mailing list archive
-
curtin-dev team
-
Mailing list archive
-
Message #03313
[Merge] ~jw-raven/curtin:preserve-luks into curtin:master
Josef Wolf has proposed merging ~jw-raven/curtin:preserve-luks into curtin:master.
Requested reviews:
curtin developers (curtin-dev)
For more details, see:
https://code.launchpad.net/~jw-raven/curtin/+git/curtin/+merge/460745
First commit of this branch fixes path for dmcrypt devices
Second commit tires to unlock preserved LUKS partitions so that they can be reused instead of bailing out.
See also https://answers.launchpad.net/ubuntu/+source/cloud-init/+question/708225
--
Your team curtin developers is requested to review the proposed merge of ~jw-raven/curtin:preserve-luks into curtin:master.
diff --git a/curtin/commands/block_meta.py b/curtin/commands/block_meta.py
index 9fde9c6..34d363c 100644
--- a/curtin/commands/block_meta.py
+++ b/curtin/commands/block_meta.py
@@ -1598,7 +1598,7 @@ def lvm_partition_handler(info, storage_config, context):
def verify_blkdev_used(dmcrypt_dev, expected_blkdev):
dminfo = block.dmsetup_info(dmcrypt_dev)
- found_blkdev = dminfo['blkdevs_used']
+ found_blkdev = '/dev/' + dminfo['blkdevs_used']
msg = (
'Verifying %s volume, expecting %s , found %s ' % (
dmcrypt_dev, expected_blkdev, found_blkdev))
@@ -1656,6 +1656,20 @@ def dm_crypt_handler(info, storage_config, context):
create_dmcrypt = True
if preserve:
+ could_unlock = False
+ for luks_type in ['luks2', 'luks', 'luks1']:
+ cmd = ["cryptsetup", "open", "--type", luks_type,
+ volume_path, dm_name, "--key-file", keyfile]
+ try:
+ util.subp(cmd, log_captured=True)
+ could_unlock = True
+ break
+ except util.ProcessExecutionError:
+ pass
+
+ if not could_unlock:
+ raise RuntimeError('Failed to unlock LUKS volume %s', volume_path)
+
dm_crypt_verify(dmcrypt_dev, volume_path)
LOG.debug('dm_crypt %s already present, skipping create', dmcrypt_dev)
create_dmcrypt = False
Follow ups