我正在尝试使用 Cubic 和 Ubiquity 的预置选项为 Ubuntu 制作自定义安装 ISO。我一直在绞尽脑汁地试图让它自动将整个磁盘分区为加密的 LVM,就像 GUI 安装程序允许的那样。我已经尝试了在网上找到的近十几个示例预置配置,所有这些配置都以安装程序在分区期间出错而告终,因为:
No modifications can be made to the device: Encrypted Volume (sda1p2_crypt) for the following reasons: In use by LVM module group crypt
或任何配方中命名为 LVM 组的内容。我认为这些食谱适用于以前版本的 Ubuntu。
起初,我认为这个错误只是因为磁盘有一些预先存在的带有加密 LVM 的分区,所以我运行了 ,sgdisk -Z /dev/sda
重新启动并重试,但问题仍然存在。
当然,我可以使用安装程序的 GUI 手动对磁盘进行分区。
以下是预种子的示例部分:
d-i partman-auto/method string crypto
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-lvm/confirm boolean true
d-i partman-auto-lvm/guided_size string max
d-i partman-auto-lvm/new_vg_name string crypt
d-i partman-auto/choose_recipe select root-encrypted
d-i partman-auto/expert_recipe string \
root-encrypted :: \
500 500 500 ext4 \
$primary{ } $bootable{ } \
method{ format } format{ } \
use_filesystem{ } filesystem{ ext4 } \
mountpoint{ /boot } \
. \
2000 2000 2000 linux-swap \
$lvmok{ } lv_name{ swap } \
in_vg { crypt } \
$primary{ } \
method{ swap } format{ } \
. \
500 10000 1000000000 ext4 \
$lvmok{ } lv_name{ rootpart } \
in_vg { crypt } \
$primary{ } \
method{ format } format{ } \
use_filesystem{ } filesystem{ ext4 } \
mountpoint{ / } \
.
d-i partman-md/device_remove_md boolean true
d-i partman-basicfilesystems/no_mount_point boolean false
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
另一个会产生相同的错误。在本教程中,我没有使用自定义配方,而是仅选择内置配方。
#Get around the prompt for UEFI-only
d-i partman-efi/non_efi_system boolean true
d-i partman/default_filesystem string ext4
# In addition, you'll need to specify the method to use.
# The presently available methods are:
# - regular: use the usual partition types for your architecture
# - lvm: use LVM to partition the disk
# - crypto: use LVM within an encrypted partition
d-i partman-auto/method string crypto
d-i partman-crypto/passphrase password mypassword7
d-i partman-crypto/passphrase-again password mypassword7
# If one of the disks that are going to be automatically partitioned
# contains an old LVM configuration, the user will normally receive a
# warning. This can be preseeded away...
d-i partman-lvm/device_remove_lvm boolean true
# The same applies to pre-existing software RAID array:
d-i partman-md/device_remove_md boolean true
# And the same goes for the confirmation to write the lvm partitions.
d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm_nooverwrite boolean true
# For LVM partitioning, you can select how much of the volume group to use
# for logical volumes.
d-i partman-auto-lvm/guided_size string max
# You can choose one of the three predefined partitioning recipes:
# - atomic: all files in one partition
# - home: separate /home partition
# - multi: separate /home, /var, and /tmp partitions
d-i partman-auto/choose_recipe select atomic
# This makes partman automatically partition without confirmation, provided
# that you told it what to do using one of the methods above.
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
完成这项工作需要什么partman配置?
经过大量的尝试、研究和阅读其他人试图实现这一目标的经验后,我得出的结论是,由于安装程序中的一些错误,这是不可能的。
带自动安装和 subiquity 的 Ubuntu Server iso 可以通过自动安装功能非常干净地完成此任务,我建议任何人作为解决此问题的替代方案。