加密分区缩容, LVM on LUKS
Contents
加密分区缩容, LVM on LUKS
https://linux-blog.anracom.com/2018/11/09/shrinking-an-encrypted-partition-with-lvm-on-luks/
https://wiki.archlinux.org/title/Resizing_LVM-on-LUKS
https://wiki.archlinux.org/title/LVM#Resizing_the_logical_volume_and_file_system_in_one_go
https://starbeamrainbowlabs.com/blog/article.php?article=posts%2F441-resize-luks-lvm.html
Step 1: Get an overview over your block devices
|
|
加密分区在 /dev/nvme0n1p3 上
Step 2: Open the encrypted partition
|
|
能看到 PV: /dev/mapper/cr-ext 还有 LVM-volumes: /dev/mapper/ubuntu–vg-ubuntu–lv
Step 3: Get an overview on LVM structure
|
|
|
|
输出
|
|
一般情况打开 luks 加密的设备之后 lvm 的 vg, lv 会自动 激活 如果没有激活的话, 手动激活 vg
|
|
Step 4: Check the integrity of the filesystem
|
|
Step 5: Check the physical block size of the filesystem and the used space within the filesystem
|
|
Step 6: Plan the reduced volume and filesystem sizes ahead – perform safety and limit considerations
1000G 缩容到 500G 安全系数 0.9 500*0.9 = 450G 文件系统至少要比逻辑卷小 10%, 因为后面用到的工具使用的单位不一样, 有的是 GB, 有的是 GiB
Step 7: Shrink the filesystem
|
|
Step 8: Shrink the logical volume
|
|
Step 9: Extend the fs to the volume size again
|
|
Step 10: Check for gaps between the volumes of your LVM volume group
ubuntu 24.04 默认不会有 swap 分区, 有个swap 文件 在 /root 分区
Step 11: Resize/reduce the physical LVM
|
|
Step 12: Set new size of the encrypted region
|
|
Step 13: Reduce the size of the physical partition – a pretty scary step!
|
|
Step 14: Set new size of the encrypted region
|
|
Step 15: Reset the PV size to the full partition size
|
|
Step 16: Closing and leaving the encrypted device
|
|
Author -
LastMod 2025-05-20