码迷,mamicode.com
首页 > 其他好文 > 详细

LVM的基本应用、扩展及缩减实现

时间:2015-09-01 00:01:14      阅读:268      评论:0      收藏:0      [点我收藏+]

标签:linux 马鹏飞 lvm 逻辑卷管理

LVM : 

     Logical Volume Manager 逻辑卷管理, 它是一种可以用在Linux内核的逻辑分卷管理器,常用于管理磁盘和其他大型存储设备上。



LVM的应用:

             在生产环境中常见于增加磁盘,可将多个磁盘合理的合并成一个或多个,但又不会影响业务的进行。


与raid的区别:

              LVM是软件的卷管理方式,而RAID是磁盘保护的方法。对于重要的业务来说,一般是同时存在。RAID用来保护物理的磁盘不会因为故障而中断业务。LVM用来实现对卷的良性的管理,更好的利用磁盘资源。



LVM的扩展及缩减实例: 

1,首先查看逻辑卷容量
[root@bogon ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                       39G  461M   37G   2% /
/dev/mapper/VolGroup00-LogVol03
                       64G  222M   61G   1% /var
/dev/mapper/VolGroup00-LogVol02
                       49G  2.0G   45G   5% /usr
/dev/mapper/VolGroup00-LogVol01
                       39G  177M   37G   1% /home
/dev/sda1              99M   13M   82M  14% /boot
tmpfs                1005M     0 1005M   0% /dev/shm
/dev/hdc              3.5G  3.5G     0 100% /media


2,在home下有lost+found可以看到home分区单独挂载到一个分区下面
[root@bogon ~]# ls /home/
innofidei  lost+found

3,卸载并验证
[root@bogon ~]# umount /dev/mapper/VolGroup00-LogVol01 
[root@bogon ~]# ls /home/

4,resize2fs  卷组
[root@bogon ~]# resize2fs /dev/mapper/VolGroup00-LogVol01 20G 
resize2fs 1.39 (29-May-2006)
Resizing the filesystem on /dev/mapper/VolGroup00-LogVol01 to 5242880 (4k) blocks.
The filesystem on /dev/mapper/VolGroup00-LogVol01 is now 5242880 blocks long.
注意这里会提醒你e2fsck的
所以resize2fs之前要这样做: e2fsck -f /dev/mapper/VolGroup-logVol01

5,缩减lvm
[root@bogon ~]# lvreduce -L 20G /dev/mapper/VolGroup00-LogVol01
  /dev/hdc: open failed: Read-only file system
  WARNING: Reducing active logical volume to 20.00 GB
  THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce LogVol01? [y/n]: y
  Reducing logical volume LogVol01 to 20.00 GB
  Logical volume LogVol01 successfully resized

6,重新挂载并验证
[root@bogon ~]# mount -a
[root@bogon ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                       39G  461M   37G   2% /
/dev/mapper/VolGroup00-LogVol03
                       64G  222M   61G   1% /var
/dev/mapper/VolGroup00-LogVol02
                       49G  2.0G   45G   5% /usr
/dev/sda1              99M   13M   82M  14% /boot
tmpfs                1005M     0 1005M   0% /dev/shm
/dev/hdc              3.5G  3.5G     0 100% /media
/dev/mapper/VolGroup00-LogVol01
                       20G  173M   19G   1% /home
[root@bogon ~]# ls /home/
innofidei  lost+found

7,扩展另一lvm
[root@bogon ~]# lvextend -L +20G /dev/mapper/VolGroup00-LogVol02
  /dev/hdc: open failed: Read-only file system
  Extending logical volume LogVol02 to 70.00 GB
  Logical volume LogVol02 successfully resized
[root@bogon ~]# resize2fs /dev/mapper/VolGroup00-LogVol02
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/mapper/VolGroup00-LogVol02 is mounted on /usr; on-line resizing required
Performing an on-line resize of /dev/mapper/VolGroup00-LogVol02 to 18350080 (4k) blocks.
The filesystem on /dev/mapper/VolGroup00-LogVol02 is now 18350080 blocks long.

8,再验证
[root@bogon ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                       39G  461M   37G   2% /
/dev/mapper/VolGroup00-LogVol03
                       64G  222M   61G   1% /var
/dev/mapper/VolGroup00-LogVol02
                       68G  2.0G   63G   4% /usr
/dev/sda1              99M   13M   82M  14% /boot
tmpfs                1005M     0 1005M   0% /dev/shm
/dev/hdc              3.5G  3.5G     0 100% /media
/dev/mapper/VolGroup00-LogVol01
                       20G  173M   19G   1% /home



LVM的基本应用、扩展及缩减实现

标签:linux 马鹏飞 lvm 逻辑卷管理

原文地址:http://mapengfeilinux.blog.51cto.com/2560592/1690299

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!