1、查看磁盘分区表
# fdisk -l
Disk /dev/sda: 128.8 GB, 128849018880 bytes
255 heads, 63 sectors/track, 15665 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 24 192748+ 83 Linux
/dev/sda2 25 15665 125636332+ 8e Linux LVM
LVM所在的物理卷PV设备名为/dev/sda2
2、查看剩余的卷组空间
#
vgs
VG #PV #LV #SN Attr VSize VFree
VolGroup00 1 6 0 wz--n- 119.81G 12.81G
剩余空间为12.81G,卷组为VolGroup00
3、查看已有的逻辑卷,避免重名
#
lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
lv_home VolGroup00 -wi-ao 10.00G
lv_opt VolGroup00 -wi-ao 20.00G
lv_root VolGroup00 -wi-ao 5.00G
lv_swap VolGroup00 -wi-ao 2.00G
lv_tmp VolGroup00 -wi-ao 50.00G
lv_var VolGroup00 -wi-ao 20.00G
4、利用VolGroup00上的空闲空间创建一个新的逻辑卷LV
# vcreate -L 12G -n lv_usr VolGroup00
/dev/cdrom: open failed: Read-only file system
Logical volume "lv_usr" created
5、在逻辑卷lv_usr上创建ext3文件系统
#
mkfs.ext3 /dev/VolGroup00/lv_usr
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
1572864 inodes, 3145728 blocks
157286 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=3221225472
96 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 24 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@localhost ~]# mount /dev/VolGroup00/lv_usr /usr
6、设置挂载点
#
mount /dev/VolGroup00/lv_usr /usr
7、查看挂载
# df -HT
释放逻辑分区的一部分空间
lvreduce -L -2G /dev/VolGroup00/lv_opt
给逻辑分区增加空间
lvextend-L +2G /dev/VolGroup00/lv_usr
***lvreduce和lvextend调整逻辑卷之后,系统不能正常引导。
如上所示,由于调整逻辑卷空间大小,导致在开机的时候,出现提示lv_opt文件系统错误:
修复方法:
1) 进入rescue模式
2) 逆向操作恢复
# lvresize -l -2G /dev/VolGroup00/lv_usr
# lvresize -l +2G /dev/VolGroup00/lv_opt
#reboot
即可正常引导系统
不能正常的引导原因是:没有使用resize2fs改变调整文件的大小,导致文件系统破坏。
在使用lvextend大小之前最好先卸载分区,之后使用resize2fs调整大小。