当LV空间利用率较大即将耗尽LV空间时,我们可以将一块新的磁盘或者一块磁盘上的free空间加入LV,步骤如下: 现在/home空间如下: [root@localhost ~]# df -h 文件系统 容量 已用 可用 已用% 挂载点 /dev/mapper/rootvg-rootlv 7.6G 2.0G 5.2G 28% / /dev/sda1 99M 11M 83M 12% /boot tmpfs 125M 0 125M 0% /dev/shm /dev/mapper/rootvg-homelv 496M 19M 452M 4% /home 1、新建LVM类型分区: [root@localhost ~]# fdisk /dev/sda \\对硬盘sda进行分区操作
Command (m for help): n \\创建新的分区 First cylinder (1160-1305, default 1160):1160 \\指定起始柱面 Last cylinder or +size or +sizeM or +sizeK(1160-1305, default 1305): 1305 \\指定终止柱面
Command (m for help): p \\查看当前分区表信息
Disk /dev/sda: 10.7 GB, 10737418240 bytes 255 heads, 63 sectors/track, 1305 cylinders Units = cylinders of 16065 * 512 = 8225280bytes
Device Boot Start End Blocks Id System /dev/sda1 * 1 13 104391 83 Linux /dev/sda2 14 395 3068415 8e Linux LVM /dev/sda3 396 777 3068415 8e Linux LVM /dev/sda4 778 1305 4241160 5 Extended /dev/sda5 778 1159 3068383+ 8e Linux LVM /dev/sda6 1160 1305 1172713+ 83 Linux \\刚刚新建的分区
Command (m for help): t \\改变分区类型 Partition number (1-6): 6 \\指定分区编号 Hex code (type L to list codes): 8e \\更改为LVM类型分区 Changed system type of partition 6 to 8e(Linux LVM)
Command (m for help): w \\保存退出 The partition table has been altered! 2、创建新的PV [root@localhost ~]# partprobe \\使用partprobe指令更新内核的中硬盘分区表信息 [root@localhost ~]# pvcreate /dev/sda6 \\创建新的PV Physical volume "/dev/sda6" successfully created [root@localhost ~]# pvscan PV/dev/sda2 VG rootvg lvm2 [2.93 GB / 0 free] PV/dev/sda3 VG rootvg lvm2 [2.93 GB / 0 free] PV/dev/sda5 VG rootvg lvm2 [2.93 GB / 0 free] PV /dev/sda6 lvm2[1.12 GB] \\新创建的PV但是尚未加入任何VG组 Total: 4 [9.90 GB] / in use: 3 [8.78 GB] / in no VG: 1 [1.12 GB] 3、将PV加入VG组 [root@localhost ~]# vgextend rootvg/dev/sda6 Volume group "rootvg" successfully extended
[root@localhost ~]# pvscan PV/dev/sda2 VG rootvg lvm2 [2.93 GB / 0 free] PV/dev/sda3 VG rootvg lvm2 [2.93 GB / 0 free] PV/dev/sda5 VG rootvg lvm2 [2.93 GB / 0 free] PV /dev/sda6 VG rootvg lvm2 [1.12 GB / 1.12 GB free] \\已经加入rootvg组 Total: 4 [9.89 GB] / in use: 4 [9.89 GB] / in no VG: 0 [0 ]
4、将VG组中的空闲空间划出100M到/home分区所在的LV [root@localhost ~]# lvextend -L +100M/dev/rootvg/homelv Extending logical volume homelv to 612.00 MB Logical volume homelv successfully resized
5、使用resizefs2命令重新加载逻辑卷的大小才能生效 [root@localhost ~]# resize2fs/dev/rootvg/homelv resize2fs 1.39 (29-May-2006) Filesystem at /dev/rootvg/homelv is mountedon /home; on-line resizing required Performing an on-line resize of/dev/rootvg/homelv to 626688 (1k) blocks. The filesystem on /dev/rootvg/homelv is now626688 blocks long.
查看增加空间后的/home空间 [root@localhost ~]# df -h 文件系统 容量 已用 可用 已用% 挂载点 /dev/mapper/rootvg-rootlv 7.6G 2.0G 5.2G 28% / /dev/sda1 99M 11M 83M 12% /boot tmpfs 125M 0 125M 0% /dev/shm /dev/mapper/rootvg-homelv 593M 19M 544M 4% /home (责任编辑:IT) |