我正在尝试在 Ubuntu 14.04 上扩展 LVM 分区。如您所见,总磁盘空间为 40G,但 sda3 只有 8.9G。我尝试运行 lvextend,但由于某些原因,可用空间未被占用。
感谢您的帮助。
root@ubuntu:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 39.1G 0 disk
├─sda1 8:1 0 142M 0 part /boot
├─sda2 8:2 0 954M 0 part [SWAP]
└─sda3 8:3 0 9G 0 part
└─CAC_VG-CAC_LV (dm-0) 252:0 0 8.9G 0 lvm /
sr0 11:0 1 354K 0 rom
root@ubuntu:~# pvscan
PV /dev/sda3 VG CAC_VG lvm2 [8.93 GiB / 0 free]
Total: 1 [8.93 GiB] / in use: 1 [8.93 GiB] / in no VG: 0 [0 ]
root@ubuntu:~# vgdisplay
--- Volume group ---
VG Name CAC_VG
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 1
Act PV 1
VG Size 8.93 GiB
PE Size 4.00 MiB
Total PE 2285
Alloc PE / Size 2285 / 8.93 GiB
Free PE / Size 0 / 0
VG UUID A4SRwW-Vqpz-qRLf-iXIm-yKny-tcyI-wYTMdg
root@ubuntu:~# lvdisplay
--- Logical volume ---
LV Path /dev/CAC_VG/CAC_LV
LV Name CAC_LV
VG Name CAC_VG
LV UUID 0DUf2t-XI5Q-Xv8W-f2Yn-uycK-4l0x-A6zI1E
LV Write Access read/write
LV Creation host, time ubuntu, 2014-07-27 16:00:17 -0400
LV Status available
# open 1
LV Size 8.93 GiB
Current LE 2285
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 252:0
root@ubuntu:~# vgextend CAC_VG /dev/sda3
Physical volume '/dev/sda3' is already in volume group 'CAC_VG'
Unable to add physical volume '/dev/sda3' to volume group 'CAC_VG'.
root@ubuntu:~# lvextend -l +100%FREE /dev/CAC_VG/CAC_LV
New size (2285 extents) matches existing size (2285 extents)
Run `lvextend --help' for more information.
root@ubuntu:~# vgs -o +vg_free_count,vg_extent_count
VG #PV #LV #SN Attr VSize VFree Free #Ext
CAC_VG 1 1 0 wz--n- 8.93g 0 0 2285
答案1
为了使其lvresize
正常工作,您必须首先扩展sda3
包含 LVM 物理卷的分区:
sudo parted /dev/sda -- resizepart 3 -1
这将调整大小/dev/sda3
以占据磁盘上所有可用的空间。(resizepart 3 -1
意思是“将分区号 3 的末尾移动到磁盘上的最后一个扇区”)。
您可能需要从安装媒体启动到实时会话,以避免挂载的文件系统出现任何问题。