我们有一些红帽服务器,其详细信息如下(当操作系统磁盘大小为 230G 时)
# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 230G 0 disk
├─sda1 8:1 0 1G 0 part /boot/efi
├─sda2 8:2 0 1G 0 part /boot
└─sda3 8:3 0 228G 0 part
├─VG100-lv_root 253:0 0 20G 0 lvm /
├─VG100-lv_swap 253:1 0 16G 0 lvm [SWAP]
└─VG100-lv_var 253:2 0 30G 0 lvm /var
fdisk -l
Disk /dev/sda: 193.3 GB, 193273528320 bytes, 377487360 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x00000000
Device Boot Start End Blocks Id System
/dev/sda1 1 209715199 104857599+ ee GPT
目标是在当前 /var 为 30G 且根文件系统为 20G 的情况下,基于磁盘大小为 230G 来增加 /var 和根文件系统
因此,我们从以下步骤开始,该步骤应该为我们提供足够的 PFREE 或足够的“物理可用”空间。
parted /dev/sda resizepart 3 100%
Error: The backup GPT table is not at the end of the disk, as it should be. This might mean that another operating system believes the disk is smaller. Fix, by moving the backup to the end (and removing the old backup)?
parted: invalid token: 3
Fix/Ignore/Cancel?
sgdisk -e /dev/sda
注意 - sgdisk:修复备份 GPT 表的最简单方法是使用带有 -e 选项的 sgdisk 命令,该命令将备份 GPT 数据结构移动到磁盘末尾
parted /dev/sda resizepart 3 100%
Information: You may need to update /etc/fstab.
partprobe /dev/sda
pvresize /dev/sda
Failed to find physical volume "/dev/sda".
0 physical volume(s) resized or updated / 0 physical volume(s) not resized
但来自 pvsPfree
仍为 0
# pvs
PV VG Fmt Attr PSize PFree
/dev/sda3 VG100 lvm2 a-- 66.00g 0
关于能够增加 /var 和根文件系统分区的其他方法有什么想法吗?
更多信息
# vgs
VG #PV #LV #SN Attr VSize VFree
VG100 1 3 0 wz--n- <228.00g <162.00g
我们也尝试这个(例如)
lvextend -l +100%FREE -r /dev/mapper/VG100-lv_root
Size of logical volume VG100/lv_root unchanged from 20.00 GiB (5120 extents).
Logical volume VG100/lv_root successfully resized.
xfs_growfs /dev/mapper/VG100-lv_root
但根文件系统的大小相同
df -h | grep VG100-lv_root
/dev/mapper/VG100-lv_root 20G 3.8G 17G 19% /
pvs
PV VG Fmt Attr PSize PFree
/dev/sda3 VG100 lvm2 a-- 66.00g 0