在RedHat 使用中,我们经常会碰到硬盘空间用完的问题。今天也是因为服务器硬盘空间用完,才用到这个增加硬盘,并加入LVM现有空间的操作。
详细内容见内文。
1.收集相关数据
执行如下命令:
vgs
VG #PV #LV #SN Attr VSize VFree
VolGroup00 1 2 0 wz–n- 49.88G 0
lvs –a –o +devices
LV VG Attr LSize Origin Snap% Move Log Copy% Convert Devices
LogVol00 VolGroup00 -wi-ao 44.06G /dev/sda2(0)
LogVol01 VolGroup00 -wi-ao 5.81G /dev/sda2(1410)
2.新加硬盘基本配置
执行如下命令:
fdisk –l
Disk /dev/sdb: 53.6 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 byte
fdisk /dev/sdb
将硬盘分为一个分区。结果如下:
Device Boot Start End Blocks Id System
/dev/sdb1 1 6527 52428096 83 Linux
3.LVM配置
执行如下命令:
vgextend VolGroup00 /dev/sdb1 #将sdb1加入到VolGroup00
lvextend –l +100%FREE /dev/VolGroup00/LogVol00 #扩展所有空余空间
resize2fs –f /dev/VolGroup00/LogVol00
4.检查
执行如下命令:
vgs
VG #PV #LV #SN Attr VSize VFree
VolGroup00 2 2 0 wz–n- 99.84G 0
lvs –a –o +devices
LV VG Attr LSize Origin Snap% Move Log Copy% Convert Devices
LogVol00 VolGroup00 -wi-ao 94.03G /dev/sda2(0)
LogVol00 VolGroup00 -wi-ao 94.03G /dev/sdb1(0)
LogVol01 VolGroup00 -wi-ao 5.81G /dev/sda2(1410)
df –h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
92G 43G 44G 50% /
/dev/sda1 99M 13M 82M 14% /boot
tmpfs 2.0G 0 2.0G 0% /dev/shm