红联Linux门户
Linux帮助

Linux LVM-文件系统扩展

发布时间:2015-01-04 09:38:20来源:linux网站作者:linux人

LVM extent volume size
当前的LVM管理一块磁盘/dev/sda
方法1:对现有磁盘sda进行扩容,并将增加的空间扩展进最大volumn
方法2:添加一块新的磁盘sdb,并将增加的空间扩展到最大的volumn


1,扩展现有磁盘/dev/sda(扩存储5GB),并重启机器
a,创建新的主分区/dev/sda3,命令fdisk /dev/sda
[root@localhost ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg01-lv01
                      46G  3.0G  41G  7% /
/dev/sda1              99M  18M  77M  19% /boot
tmpfs                185M    0  185M  0% /dev/shm

b,创建新pv,命令pvcreate /dev/sda3,如果不重启则出错。
[root@localhost ~]# pvcreate /dev/sda3
Physical volume "/dev/sda3" successfully created

c,扩展现有vg,命令vgextend vg01 /dev/sda3
[root@localhost ~]# vgextend vg01 /dev/sda3
Volume group "vg01" successfully extended

d,扩展lv 2GB,命令lvextend -L+2G /dev/vg01/lv01
[root@localhost ~]# lvextend -L+2G /dev/vg01/lv01
Extending logical volume lv01 to 49.00 GB
Logical volume lv01 successfully resized

e,扩展lv的文件系统,命令resize2fs /dev/vg01/lv01

[root@localhost ~]# resize2fs /dev/vg01/lv01
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/vg01/lv01 is mounted on /; on-line resizing required
Performing an on-line resize of /dev/vg01/lv01 to 12845056 (4k) blocks.
The filesystem on /dev/vg01/lv01 is now 12845056 blocks long.

[root@localhost ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg01-lv01
48G  3.0G  43G  7% /
/dev/sda1              99M  18M  77M  19% /boot
tmpfs                185M    0  185M  0% /dev/shm


2,添加额外的磁盘,也可以扩展LVM的volumn,方法与1完全一样。