我已将第二个磁盘添加到我的 LVM 系统。我在那里创建了一个物理卷,将其添加到ubuntu的卷组“vgubuntu”中,扩展逻辑卷以填充整个磁盘。如何扩展LUKS
系统分区以填充整个逻辑卷?以下是pvdisplay
、vgdisplay
和提供的更多信息lvdisplay
:
--- Physical volume ---
PV Name /dev/mapper/nvme0n1p3_crypt
VG Name vgubuntu
PV Size <464.53 GiB / not usable 0
Allocatable NO
PE Size 4.00 MiB
Total PE 118919
Free PE 0
Allocated PE 118919
PV UUID DwO3R1-DeRo-c83D-qx5F-xjC5-icXG-x3j28i
--- Physical volume ---
PV Name /dev/nvme1n1p1
VG Name vgubuntu
PV Size <476.94 GiB / not usable 0
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 122096
Free PE 0
Allocated PE 122096
PV UUID 9UyJR4-m0G9-sYPG-BBkW-2WEg-TBdR-DAj0u3
root@omen15:~# vgdisplay
--- Volume group ---
VG Name vgubuntu
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 8
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 2
Act PV 2
VG Size 941.46 GiB
PE Size 4.00 MiB
Total PE 241015
Alloc PE / Size 241015 / 941.46 GiB
Free PE / Size 0 / 0
VG UUID ANNTFf-p9hU-O4R3-jwDQ-bZhP-v8tm-hVL8Fn
root@omen15:~# lvdisplay
--- Logical volume ---
LV Path /dev/vgubuntu/root
LV Name root
VG Name vgubuntu
LV UUID rxnIOU-yNg2-ythJ-Dz5V-N3Sr-X7DQ-WzbUUF
LV Write Access read/write
LV Creation host, time ubuntu, 2021-07-24 17:25:39 +0300
LV Status available
# open 1
LV Size <940.51 GiB
Current LE 240770
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
--- Logical volume ---
LV Path /dev/vgubuntu/swap_1
LV Name swap_1
VG Name vgubuntu
LV UUID MOvhEP-64w3-wHHO-wmDh-YkSU-XARL-7hRQIf
LV Write Access read/write
LV Creation host, time ubuntu, 2021-07-24 17:25:39 +0300
LV Status available
# open 2
LV Size 980.00 MiB
Current LE 245
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:2
这是df -h
打印的内容:
root@omen15:~# df -h
Filesystem Size Used Avail Use% Mounted on
tmpfs 1.6G 2.1M 1.6G 1% /run
/dev/mapper/vgubuntu-root 925G 7.3G 871G 1% /
tmpfs 7.6G 12M 7.6G 1% /dev/shm
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 4.0M 0 4.0M 0% /sys/fs/cgroup
/dev/nvme0n1p2 705M 251M 403M 39% /boot
/dev/nvme0n1p1 511M 5.3M 506M 2% /boot/efi
tmpfs 1.6G 2.0M 1.6G 1% /run/user/1000
答案1
您在 PV 级别上配置了 LUKS,因此您的 LVM 设置“位于”之下,因此不幸的是您需要重新开始 - 您的 PV 必须加密,您无法将现有 LUKS/dm-crypt 设备“扩展”到第二个磁盘。结构应该是这样的磁盘 -> 分区 -> LUKS -> PV -> VG -> LV(可以在 LV 级别上配置加密,但您现有的配置是在 PV 级别上加密的)。
因此,您需要缩小root
LV,从中删除新创建的 PV vgubuntu
,然后在nvme1n1p1
( cryptsetup luksFormat /dev/nvme1n1p1
) 上创建 LUKS,将其解锁 ( cryptsetup luksOpen /dev/nvme1n1p1 nvme1n1p1_crypt
) 并用作/dev/mapper/nvme1n1p1_crypt
第二个 PV。您还需要将新的 LUKS 设备添加到/etc/crypttab
.