我增加了用作 LVM PV 的分区的大小,但运行 pvresize 似乎没有看到额外的空间:
cuttle:~# fdisk -l /dev/vda
Disk /dev/vda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00027dbb
Device Boot Start End Blocks Id System
/dev/vda1 * 1 31 248976 83 Linux
/dev/vda2 32 2610 20715817+ 8e Linux LVM
这表明 vda2 大约为 20gig
cuttle:~# pvdisplay
--- Physical volume ---
PV Name /dev/vda2
VG Name debian
PV Size 4.76 GiB / not usable 3.08 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 1217
Free PE 0
Allocated PE 1217
PV UUID tehZic-5vfN-rsrm-B8lN-lpgc-yQT1-ioH1V0
所以目前的 pv 大约是 4-5 gigs
cuttle:~# pvresize -v /dev/vda2
Using physical volume(s) on command line
Archiving volume group "debian" metadata (seqno 12).
No change to size of physical volume /dev/vda2.
Resizing volume "/dev/vda2" to 9975981 sectors.
Updating physical volume "/dev/vda2"
Creating volume group backup "/etc/lvm/backup/debian" (seqno 13).
Physical volume "/dev/vda2" changed
1 physical volume(s) resized / 0 physical volume(s) not resized
pvresize 显示“物理卷 /dev/vda2 的大小没有变化”
cuttle:~# pvdisplay
--- Physical volume ---
PV Name /dev/vda2
VG Name debian
PV Size 4.76 GiB / not usable 3.08 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 1217
Free PE 0
Allocated PE 1217
PV UUID tehZic-5vfN-rsrm-B8lN-lpgc-yQT1-ioH1V0
并且pv的大小没有改变。
不确定我还能做些什么来利用额外的空间。我想我可以将分区大小调整为 pv 的大小,然后添加第二个分区,但在我看来,我在这里尝试做的事情确实应该可行。
答案1
就我而言,我的卷是 60GB,我将其扩展到 110GB。
从 AWS 控制台调整磁盘大小后,运行时df -kh
系统将显示磁盘的新大小,如预期的那样:
nvme3n1 259:4 0 110G 0 disk
└─nvme3n1p1 259:5 0 60G 0 part
└─vg_user01-lv_user01 253:0 0 60G 0 lvm /home/user01
在正常情况下,下一步是扩展物理卷,/dev/nvme3n1p1
但该命令pvresize
并未按预期反映新的额外空间。
sudo pvresize -v /dev/nvme3n1p1
Archiving volume group "vg_user01" metadata (seqno 22).
Resizing volume "/dev/nvme3n1p1" to 125827072 sectors.
No change to size of physical volume /dev/nvme3n1p1.
Updating physical volume "/dev/nvme3n1p1"
Creating volume group backup "/etc/lvm/backup/vg_user01" (seqno 23).
Physical volume "/dev/nvme3n1p1" changed
1 physical volume(s) resized or updated / 0 physical volume(s) not resized
调查完问题后,发现这似乎是内核问题,通常新内核会自动检测这个额外空间。我看到有人建议重启实例,但这也不起作用。
为了解决这个问题,我们需要growpart
在目标磁盘分区上运行。
[root@ec2-basic user01]# growpart /dev/nvme3n1 1
CHANGED: partition=1 start=2048 old: size=125827072 end=125829120 new: size=230684639 end=230686687
然后,我们可以看到反映出来的变化:
[root@ec2-basic user01]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
nvme3n1 259:4 0 110G 0 disk
└─nvme3n1p1 259:5 0 110G 0 part
└─vg_user01-lv_user01 253:0 0 60G 0 lvm /home/user01
然后我们需要检查LVM路径:
[root@ec2-basic user01]# sudo lvdisplay
--- Logical volume ---
LV Path /dev/vg_user01/lv_user01
....
告诉 LVM 扩展逻辑卷以使用所有新分区的大小:
[root@ec2-basic user01]# lvextend -l +100%FREE /dev/vg_user01/lv_user01
Size of logical volume vg_user01/lv_user01 changed from <60.00 GiB (15359 extents) to <110.00 GiB (28159 extents).
Logical volume vg_user01/lv_user01 successfully resized.
最后,我们扩展文件系统:
[root@ec2-basic user01]# resize2fs /dev/vg_user01/lv_user01
resize2fs 1.42.9 (28-Dec-2013)
Filesystem at /dev/vg_user01/lv_user01 is mounted on /home/user01; on-line resizing required
old_desc_blocks = 8, new_desc_blocks = 14
The filesystem on /dev/vg_user01/lv_user01 is now 28834816 blocks long.
[root@aws-test user01]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
nvme3n1 259:4 0 110G 0 disk
└─nvme3n1p1 259:5 0 110G 0 part
└─vg_user01-lv_user01 253:0 0 110G 0 lvm /home/user01
答案2
部分探测/dev/vda
人部分探测
NAME partprobe - 通知操作系统分区表的变化
摘要 partprobe [-d] [-s] [设备...]
答案3
您需要先从存储级别添加空间,然后通过执行以下操作来增加 ISCSI 设备上的空间:
pvresize --setphysicalvolumesize 40G /dev/sda1..
答案4
您必须先使用 fdisk 或 cfdisk 扩展分区大小。只有这样,它才可用于 pvresize。