LVM

LVM
   1.它可以动态的进行扩大和缩小容量
   2. 可以实现空间的合并
分为:    PV  物理卷
    VG  卷组
    LV  逻辑卷
创建:首先创建PV然后创建VG最后创建LV
    1. pvcreat /dev/hdb[567]  
    2. pvdisplay 查看新生成的PV的信息
    3. vgcreat +vg_name /dev/hdb[567]
    4.vgdisplay 查看合成的VG的信息
    5. lvcreat -n lv_name -L 400M  vg_name  用vg来创建一个400M大小的LV
    6. lvdisplay  查看生成的LV的信息
    7. mke2fs -j /dev/vg_name/lv_name
    8. mount /dev/vg_name/lv_name  /mnt
    9. cp /etc/rc.d/init.d/*  /mnt/

&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
VG和LV的扩大和减小

VG的扩大和缩小:
    1. pvcreat /dev/hdb8   (首先创建一个新的分区)
    2. vgextent vg_name /dev/hdb8  (扩大)
    3. vgreduce vg_name /dev/hdb8  (缩小)     

&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
LV的扩大和减小:
        
       扩大:1. lvresize -L +400M /dev/vg_name/lv_name
             2. resize2fs /dev/vg_name/lv_name   (更新) 

      lvextend -l +100%FREE /dev/centos/quan 我把所有剩余空间都分配给了quan

      xfs_growfs /dev/centos/quan

       缩小:1. umount /mnt
         2. e2fsck -f /dev/vg_name/lv_name  (离线并且作强制检查)
         3.resize2fs /dev/vg_name/lv_name 250M  (rhel5的在线扩容命令)
         4. lvresize -L 250M /dev/vg_name/lv_name    (收缩LV)
         5. mount /dev/vg_name/lv_name /mnt
         6. df -Th

例子:        [root@lan1 /]# umount /mnt
        先离线
        再做强制检查
        [root@lan1 /]# e2fsck -f /dev/vg01/lv01
        e2fsck 1.39 (29-May-2006)
        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/vg01/lv01: 81/51200 files (2.5% non-contiguous), 12353/204800 blocks
收缩文件系统
        [root@lan1 /]# resize2fs /dev/vg01/lv01 100M
        resize2fs 1.39 (29-May-2006)
        Resizing the filesystem on /dev/vg01/lv01 to 102400 (1k) blocks.
        The filesystem on /dev/vg01/lv01 is now 102400 blocks long.
        [root@lan1 /]# lvdisplay
          --- Logical volume ---
          LV Name                /dev/vg01/lv01
         VG Name                vg01
          LV UUID                CjVh40-MrBQ-u852-W5oQ-pd8j-5MJ1-ZmYDQZ
          LV Write Access        read/write
          LV Status              available
          # open                 0
          LV Size                200.00 MB
          Current LE             50
          Segments               1
          Allocation             inherit
          Read ahead sectors     auto
          - currently set to     256
          Block device           253:0
再收缩LV   
        [root@lan1 /]# lvresize -L 100M /dev/vg01/lv01
          WARNING: Reducing active logical volume to 100.00 MB
          THIS MAY DESTROY YOUR DATA (filesystem etc.)
        Do you really want to reduce lv01? [y/n]: y
          Reducing logical volume lv01 to 100.00 MB
          Logical volume lv01 successfully resized
        [root@lan1 /]# lvdisplay
          --- Logical volume ---
          LV Name                /dev/vg01/lv01
          VG Name                vg01
          LV UUID                CjVh40-MrBQ-u852-W5oQ-pd8j-5MJ1-ZmYDQZ
          LV Write Access        read/write
          LV Status              available
          # open                 0
          LV Size                100.00 MB
          Current LE             25
          Segments               1
          Allocation             inherit
          Read ahead sectors     auto
          - currently set to     256
          Block device           253:0
           [root@lan1 /]# mount /dev/vg01/lv01  /mnt
        [root@lan1 /]# df -Th
        文件系统      类型    容量  已用 可用 已用% 挂载点
        /dev/sda2     ext3    5.7G  2.4G  3.1G  44% /
        /dev/sda1     ext3     99M   12M   83M  12% /boot
        tmpfs        tmpfs    125M     0  125M   0% /dev/shm
       /dev/mapper/vg01-lv01   ext3     97M  5.8M   86M   7% /mnt

*******************************************************************





posted @ 2018-03-07 20:33  屌丝的IT  阅读(175)  评论(0)    收藏  举报