我在 Mac 上的 Virtualbox 4.0.12 中以虚拟机的形式运行 Oracle Enterprise Linux 5.6。最初我分配了 8G 的硬盘空间,现在我将虚拟硬盘大小增加到 30G。
重启后,虽然 fdisk 告诉我有 31.4G,但是根逻辑卷仍然显示旧磁盘空间。这是 fdisk 的输出。
[root@xyz ~]# fdisk -l
Disk /dev/sda: 31.4 GB, 31457280000 bytes
255 heads, 63 sectors/track, 3824 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 1044 8281507+ 8e Linux LVM
Disk /dev/dm-0: 6341 MB, 6341787648 bytes
255 heads, 63 sectors/track, 771 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/dm-0 doesn't contain a valid partition table
Disk /dev/dm-1: 2113 MB, 2113929216 bytes
255 heads, 63 sectors/track, 257 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/dm-1 doesn't contain a valid partition table
这是 df -h 的输出
[root@xyz ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
5.8G 5.4G 40M 100% /
/dev/sda1 99M 61M 34M 65% /boot
tmpfs 2.9G 0 2.9G 0% /dev/shm
[root@xyz ~]#
vgdisplay的输出:
[root@xyz ~]# vgdisplay
--- Volume group ---
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 7.88 GB
PE Size 32.00 MB
Total PE 252
Alloc PE / Size 252 / 7.88 GB
Free PE / Size 0 / 0
VG UUID k5viVC-eWvO-9wuG-146f-cGjk-RAHK-yDRJKz
pvscan 的输出:
[root@xyz ~]# pvscan
PV /dev/sda2 VG VolGroup00 lvm2 [7.88 GB / 0 free]
Total: 1 [7.88 GB] / in use: 1 [7.88 GB] / in no VG: 0 [0 ]
[root@xyz ~]#
我需要帮助将 LVM 逻辑卷大小调整为 30G,谢谢!
答案1
请执行下列操作:
1. use fdisk create a new primary partition using the available open space.
For this example it would be /dev/sda3.
2. pvcreate /dev/sda3 to set it up
3. vgextend /dev/VolGroup00 /dev/sda3
4. do a vgdisplay and see how many open extents you have on VolGroup00.
For this example assume 407 extents are open
5. lvextend -l +407 /dev/VolGroup00/LogVol00
6. resize2fs /dev/VolGroup00/LogVol00 (assumming ext2/ext3)
如果您使用的是 Linux 2.6 内核,则此过程无需卸载根磁盘即可运行。
答案2
您可以查看 /usr/sbin/pvscan 以了解物理卷中剩余多少空间以及它们附加到哪个卷组。
在您的情况下,/usr/sbin/lvextend --size +25G /dev/VolGroup00/LogVol00 && /sbin/resize2fs /dev/VolGroup00/LogVol00 应该可以解决您的问题。