这里记录一些任务用到的快速命令,详细LVM管理可参考:

http://wenku.baidu.com/view/c29b8bc4bb4cf7ec4afed0ad.html

1.把home分区的磁盘空间移到/根目录

[root@localhost ~]# lvs
LV VG Attr LSize Pool Origin Data% Move Log Cpy%Sync Convert
lv_home VolGroup -wi-a----- .23g
lv_root VolGroup -wi-ao---- .00g
lv_swap VolGroup -wi-ao---- .00g
[root@localhost ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda3 VolGroup lvm2 a-- .23g
[root@localhost ~]# lvremove /dev/VolGroup/lv_home
Do you really want to remove active logical volume lv_home? [y/n]: y
Logical volume "lv_home" successfully removed [root@localhost ~]# lvextend /dev/VolGroup/lv_root /dev/sda3
Extending logical volume lv_root to 403.23 GiB
Logical volume lv_root successfully resized
[root@localhost ~]# resize2fs /dev/VolGroup/lv_root
resize2fs 1.41. (-May-)
Filesystem at /dev/VolGroup/lv_root is mounted on /; on-line resizing required
old desc_blocks = , new_desc_blocks =
Performing an on-line resize of /dev/VolGroup/lv_root to (4k) blocks.
The filesystem on /dev/VolGroup/lv_root is now blocks long. [root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root 397G .9G 374G % /
tmpfs 127G 224K 127G % /dev/shm
/dev/sda2 485M 39M 421M % /boot
/dev/sda1 200M 260K 200M % /boot/efi
[root@localhost ~]#
最后别忘了vim /etc/fstab
把里面关于lv_home的那行删除,否则重启会出错,万一出错,使用
mount -w -o remount /
重新挂载文件系统删除相应行即可。

2. 给根目录增加空间

add a disk size 200G /dev/sdb
pvcreate /dev/sdb
vgextend VolGroup /dev/sdb
lvextend /dev/VolGroup/lv_root /dev/sdb
resize2fs /dev/VolGroup/lv_root #rhel 6 and below
fdisk -l 对于RHEL7以上,因为使用XFS做为文件系统,使用resize2fs会报错,请用xfs_growfs代替:

[root@localhost ~]# xfs_growfs /dev/rhel/root

meta-data=/dev/mapper/rhel-root  isize=256    agcount=4, agsize=1026816 blks

=                       sectsz=512   attr=2, projid32bit=1

=                       crc=0        finobt=0

data     =                       bsize=4096   blocks=4107264, imaxpct=25

=                       sunit=0      swidth=0 blks

naming   =version 2              bsize=4096   ascii-ci=0 ftype=0

log      =internal               bsize=4096   blocks=2560, version=2

=                       sectsz=512   sunit=0 blks, lazy-count=1

realtime =none                   extsz=4096   blocks=0, rtextents=0

data blocks changed from 4107264 to 17223680

[root@localhost ~]# df

3. Reduce

Sometimes when we are running out of disk space in our linux box and if partition created on LVM , then we can make some free space in the volume group by reducing the LVM using lvreduce command.In this article we will discuss the required steps to reduce the size of LVM safely .

Scenario : Suppose we want to reduce /home by 2GB which is LVM and formated as ext4.

[root@cloud ~]# df -h /home/
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_cloud-LogVol00
12G 9.2G 1.9G 84% /home Step:1 Umount the filesystem [root@cloud ~]# umount /home/ Step:2 check the filesystem for Errors using e2fsck command . [ root@cloud ~]# e2fsck -f /dev/mapper/vg_cloud-LogVol00
e2fsck 1.41.12 (17-May-2010)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/mapper/vg_cloud-LogVol00: 12/770640 files (0.0% non-contiguous), 2446686/3084288 blocks Note: In the above command e2fsck , we use the option '-f' to forcefully check the filesystem , even if the filesystem is clean. Step:3 Shrink the size of /home to desire size. As shown in the above scenario , size of /home is 12 GB , so by reducing it by 2GB , then the size will become 10GB. [root@cloud ~]# resize2fs /dev/mapper/vg_cloud-LogVol00 10G
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/mapper/vg_cloud-LogVol00 to 2621440 (4k) blocks.
The filesystem on /dev/mapper/vg_cloud-LogVol00 is now 2621440 blocks long. Step:4 Now reduce the size using lvreduce command. [root@cloud ~]# lvreduce -L 10G /dev/mapper/vg_cloud-LogVol00
WARNING: Reducing active logical volume to 10.00 GiB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce LogVol00? [y/n]: y
Reducing logical volume LogVol00 to 10.00 GiB
Logical volume LogVol00 successfully resized Step:5 ( Optional) For the safer side , now check the reduced filesystem for errors [root@cloud ~]# e2fsck -f /dev/mapper/vg_cloud-LogVol00
e2fsck 1.41.12 (17-May-2010)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/mapper/vg_cloud-LogVol00: 12/648960 files (0.0% non-contiguous), 2438425/2621440 blocks Step:6 Mount the file system and verify the size. [root@cloud ~]# mount /home/
[root@cloud ~]# df -h /home/
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_cloud-LogVol00
9.9G 9.2G 208M 98% /home

 从LVM 添加和移除硬盘

add disk to vm

pvcreate /dev/sdb
vgextend vg00 /dev/sdb
lvcreate --size 1g -name sas /dev/vg00/sas
mkdir /mnt/sas
mount /dev/vg00/sas /mnt/sas remove disk from lvm umount /dev/vg00/sas
lvremove /dev/vvg00/sas
vgreduce vg00 /dev/sdb
pvremove /dev/sdb
remove disk from hardware

  

LVM quick start的更多相关文章

  1. Extend a root LVM partition online

    There is also a quick remedy for the emergency situation when your root partition runs out of disk s ...

  2. Redis Quick Start [遇到问题解决问题版]

    http://redis.io/topics/quickstart make test 时的问题: 问题:gcc: Command not found 解决:yum install gcc [root ...

  3. [算法]——快速排序(Quick Sort)

    顾名思义,快速排序(quick sort)速度十分快,时间复杂度为O(nlogn).虽然从此角度讲,也有很多排序算法如归并排序.堆排序甚至希尔排序等,都能达到如此快速,但是快速排序使用更加广泛,以至于 ...

  4. Linux LVM逻辑卷配置过程详解

    许多Linux使用者安装操作系统时都会遇到这样的困境:如何精确评估和分配各个硬盘分区的容量,如果当初评估不准确,一旦系统分区不够用时可能不得不备份.删除相关数据,甚至被迫重新规划分区并重装操作系统,以 ...

  5. linux下 lvm 磁盘扩容

    打算给系统装一个oracle,发现磁盘空间不足.在安装系统的时候我选择的是自动分区,系统就会自动以LVM的方式分区.为了保证系统后期的可用性,建议所有新系统安装都采用LVM,之后生产上的设备我也打算这 ...

  6. LVM基本介绍与常用命令

    一.LVM介绍LVM是 Logical Volume Manager(逻辑卷管理)的简写,它是Linux环境下对磁盘分区进行管理的一种机制LVM - 优点:LVM通常用于装备大量磁盘的系统,但它同样适 ...

  7. Linux归档压缩、分区管理与LVM管理

    归档和压缩命令: 命令格式: gzip [-9] 文件名 bzip2 [-9] 文件名 gzip –d .gz格式的压缩文件 bzip2 –d .bz2格式的压缩文件 选项: -9:高压缩比,多用于压 ...

  8. 2.lvm动态逻辑卷

    Lvm动态逻辑卷 一.             基本概念 LVM 把实际的物理磁盘数据映射到一个简单而灵活的虚拟逻辑存储视图上,藉以控制磁盘资源: 也就是重新考虑了管理文件系统和卷的方法,在文件系统管 ...

  9. Linux LVM学习总结——扩展卷组VG

    Linux服务器由于应用变更或需求的缘故,有可能出现分区空间不足的情况,此时往往需要进行扩容(要增加分区的空间),而采用LVM的好处就是可以在不需停机的情况下可以方便地调整各个分区大小.如下所示,分区 ...

随机推荐

  1. 从基础开始,从一个SQLHelper开始

    最开始考虑的问题有这三点: 1.Access和SQLServer都要能用. 2.尽量简单,清晰. 3.性能不出大问题. public class SQLHelp { #region 私有域 priva ...

  2. C#模糊查询绑定datagridview

    private CollectionViewSource wgdData = new CollectionViewSource(); private DataTable Ds_wgd { get { ...

  3. Iframe 自适应高度的方法!

    第一种方法:代码简单,兼容性还可以,大家可以先测试下. function SetWinHeight(obj) { var win=obj; if (document.getElementById) { ...

  4. Excle中LOOKUP经典用法

    在Excle中我们经常会遇到需要求根据某个区间的判断然后获取到对应的结果,下面是一个具体的实现例子: 例如: 现在需要实现,当输入0到25以内的任何数字时,会自动获取相应的英文字母 =IFERROR( ...

  5. arcgis离海距离的计算

    1.利用arctoolbox——要素——面转线工具,将县界提取出来. 2.对线要素编辑,利用“分割”工具对边界截断,而后融合成一条海岸线 3.利用分析工具——领域分析——近邻分析计算点到海岸线要素的距 ...

  6. OpenGL学习笔记之配置OpenGL

    OpenGL是计算机图形学领域的一门入门语言,OpenGL开发库的一些文件在官网上可以下载到.里面包含三个文件,如下: 1.把在OpenGL开发库中LIB(库文件)glut.lib和glut32.li ...

  7. Linux下安装Firefox以及更新Adobe flash

    一直无法舍弃Firefox浏览器,老是提示更新,但包管理器中的版本又不是最新版,只能自己手动安装了(一下是在Ubuntu14.04环境中进行的). 1.去官网下载最新版本 2.进入下载目录,解压文件 ...

  8. CoolShell Puzzle攻略[更新隐藏剧情]

    CoolShell博主陈皓做了一个在线的puzzle很有意思,链接在这里,这里记录一下解题的一些步骤. Puzzle 0 ++++++++[>+>++>+++>++++> ...

  9. 设置搜狗输入法在任何时候按左右两侧的shift激活

    如上图,搜狗输入法for linux最近与广大用户见面了,现在的版本是1.0.0.0014,本人系统是ubuntu 14.04非麒麟版本 使用过程中有个习惯就是在任何窗口内只要按任意一侧的shift就 ...

  10. 快速排序QuickSort

    前几天实现了直接插入排序.冒泡排序和直接选择排序这三个基础排序.今天看了一下冒泡排序的改进算法,快速排序.单独记录一下,后面还有归并和基数排序等 快速排序 1.选择一个支点默认为数组第一个元素及arr ...