Skip to content


lvm在线增加磁盘空间

一。查看当前空间
#df -h

Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
97G 1.9G 91G 3% /
/dev/mapper/VolGroup00-LogVol01
194G 140G 44G 77% /home
/dev/mapper/VolGroup00-LogVol04
97G 17G 75G 19% /var
/dev/mapper/VolGroup00-LogVol03
97G 52G 41G 56% /opt
/dev/mapper/VolGroup00-LogVol02
9.7G 158M 9.1G 2% /tmp
/dev/sda1 99M 12M 82M 13% /boot
tmpfs 1010M 4.0K 1010M 1% /dev/shm

/home 增加200G
/opt 增加100G

fdisk 查看下磁盘为1T大小,并全部分给lvm
#fdisk -l

Disk /dev/sda: 1000.2 GB, 1000203804160 bytes
255 heads, 63 sectors/track, 121601 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 535 4192965 82 Linux swap / Solaris
/dev/sda3 536 121601 972462645 8e Linux LVM

vgdisplay查看卷组空间,还有400G空闲空间
#vgdisplay

— Volume group —
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 6
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 5
Open LV 5
Max PV 0
Cur PV 1
Act PV 1
VG Size 927.41 GB
PE Size 32.00 MB
Total PE 29677
Alloc PE / Size 16320 / 510.00 GB
Free PE / Size 13357 / 417.41 GB
VG UUID 4Wzdqp-f3RH-1lEP-YfXN-01Vp-3K5c-EmtcBE

二.开始增加空间
(错误的方式)
#lvextend -L +100G /dev/mapper/VolGroup00-LogVol03

Volume group “mapper” not found
Volume group mapper doesn’t exist

这里的设备名写错了(另注意一定要加”+“),正确的是
#lvextend -L +100G /dev/VolGroup00/LogVol03

Extending logical volume LogVol03 to 200.00 GB
Logical volume LogVol03 successfully resized

三.lvextend修改了lvm的大小,下面还需修改文件系统大小。
可以用umount+resize2fs 或ext2online
umount通常会碰到device is busy,这里用ext2online

下载ext2online
http://www.mirrorservice.org/sites/download.sourceforge.net/pub/sourceforge/e/project/ex/ext2resize/ext2resize/ext2resize-1.1.19/

1.下载i386的rpm
#wget http://www.mirrorservice.org/sites/download.sourceforge.net/pub/sourceforge/e/project/ex/ext2resize/ext2resize/ext2resize-1.1.19/ext2resize-1.1.19-1.i386.rpm

2.创建sct用户
#useradd sct
#rpm -ivh ext2resize-1.1.19-1.i386.rpm
—————–
安装完成后会有三个命令:
ext2online ext2prepare ext2resize
—————–
注意:安装此工具,必须有sct用户(当前用户不用是sct)

3.运行
#ext2online /dev/VolGroup00/LogVol03
ext2online v1.1.18 – 2001/03/18 for EXT2FS 0.5b

四.最后检查
#df -h

Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
97G 1.9G 91G 3% /
/dev/mapper/VolGroup00-LogVol01
194G 140G 44G 77% /home
/dev/mapper/VolGroup00-LogVol04
97G 17G 75G 19% /var
/dev/mapper/VolGroup00-LogVol03
194G 52G 133G 28% /opt
/dev/mapper/VolGroup00-LogVol02
9.7G 158M 9.1G 2% /tmp
/dev/sda1 99M 12M 82M 13% /boot
tmpfs 1010M 0 1010M 0% /dev/shm

/opt 已增加到200G.同样的方式再增加/home就可以了。

Posted in linux 维护优化, 技术.

Tagged with , , .


No Responses (yet)

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.