LVM Management under Linux

Source: Internet
Author: User

1. Experimental environment:

1), Centos6.5-32bit;

Four SCSI hard drives, respectively:

/dev/sdb (10G),/DEV/SDC (5G),/DEV/SDD (15G),/DEV/SDE (20G);

Requirements Package: LVM2


2. Experimental steps:

1), install the required packages

Yum--disablerepo=\*--enablerepo=c6-media Install lvm2 mdadm-y

2), create a physical volume

[Email protected] ~]# PVCREATE/DEV/SDB/DEV/SDC/DEV/SDD physical Volume "/DEV/SDB" successfully created physical Volu Me "/DEV/SDC" successfully created physical volume "/DEV/SDD" successfully created

To display the created physical volume

[[email protected] ~]# pvdisplay    "/dev/sdb"  is a new  physical volume of  "10.00 gib"   --- NEW Physical volume ---   PV Name                /dev/sdb            #物理卷名称   vg name                                     #加入的存储池名称   PV Size                10.00 GiB           #物理卷的大小   allocatable            NO                    pe size                0     Total PE               0  Free PE                0  Allocated PE           0  PV UUID                lqridi-ms2t-jq0y-l137-e9dd-hsdd-xabiby

Scan physical volumes on the system

[Email protected] ~]# pvscan pv/dev/sdb lvm2 [10.00 GiB] PV/DEV/SDC lvm2 [  5.00 GiB] PV/DEV/SDD lvm2 [15.00 Gib] total:3 [30.00 GIB]/in use:0 [0]/In no vg:3 [30.00 GiB]

3), create volume group (storage pool)

[Email protected] ~]# vgcreate FCY-VG/DEV/SDB/DEV/SDC Volume Group "FCY-VG" successfully created

Show Volume Group

[[email protected] ~]# vgdisplay   --- Volume group ---   VG Name                fcy-vg           #卷组名称   System ID                Format                 lvm2              #卷组格式   Metadata Areas         2  Metadata Sequence No  1  VG Access              read/write        #卷组权限   VG Status              resizable        #卷组状态 (expandable)   MAX LV                 0  Cur LV                 0  Open LV                0  Max PV                 0  Cur PV                 2  act  pv                2   VG Size                14.99 GiB          #存储池大小   PE Size                4.00 mib            #PE块的大小   Total PE               3838                #总PE数量   alloc pe / size       0 /  0     Free  PE / Size        3838 / 14.99 GiB  VG UUID                aiezvv-y5gt-u7s1-9vcb-5yzp-qsmq-t7wo7n

Scan a volume group

[Email protected] ~]# Vgscan Reading all physical volumes.  This is a while ... Found Volume Group "FCY-VG" using metadata type LVM2

Adding physical volumes to a volume group

[Email protected] ~]# vgextend fcy-vg/dev/sde Physical Volume "/DEV/SDE" successfully created volume Group "FCY-VG" Su Ccessfully Extended

Remove a physical volume from a volume group

[Email protected] ~]# vgreduce fcy-vg/dev/sde removed "/DEV/SDE" from volume Group "FCY-VG"

Delete a volume group

Vgremove FCY-VG

4), creating a logical volume

[[email protected] ~]# lvcreate-l 10g-n fcy-lv fcy-vg #-l Specify size,-n Specify name Logical volume "FCY-LV" created

viewing logical volumes

[[email protected] ~]# lvdisplay   --- Logical volume ---   LV Path                 /dev/fcy-vg/fcy-lv  LV Name                 fcy-lv  VG Name                 fcy-vg  LV UUID                 kf3klx-2aex-c3el-eduy-a3p8-jh0g-w9ighq   lv write access        read/write  lv  creation host, time fcy.com.cn, 2015-07-15 20:05:27 +0800  lv  status              available   # open                 0   lv size                 10.00 gib  current le              2560  Segments                2  Allocation              inherit  read ahead sectors     auto  -  currently set to     256  Block device            253:0

Scan logical Volumes

[[email protected] ~]# lvscan ACTIVE '/dev/fcy-vg/fcy-lv ' [10.00 GiB] Inherit

To format a created logical volume

[[email protected] ~]# mkfs -t ext3 /dev/fcy-vg/fcy-lv mke2fs 1.41.12   (17-may-2010) filesystem label=os type: linuxblock size=4096  (log=2) Fragment  size=4096  (log=2) Stride=0 blocks, stripe width=0 blocks655360 inodes,  2621440 blocks131072 blocks  (5.00%)  reserved for the super  userfirst data block=0maximum filesystem blocks=268435456080 block groups32768  blocks per group, 32768 fragments per group8192 inodes per  groupsuperblock backups stored on blocks: 32768, 98304, 163840, 229376 , 294912, 819200, 884736, 1605632writing inode tables: done                              creating journal  (32768 blocks):  donewriting superblocks and  filesystem accounting information: doneThis filesystem will be  Automatically checked every 26 mounts or180 days, whichever comes  first.  use tune2fs -c or -i to override.

     mount logical volumes

[[email protected] ~]# mount /dev/fcy-vg/fcy-lv /mnt/fcy-lvm/[[email protected]  ~]# df -hFilesystem                    size  used avail use% mounted on/dev/ sda2                      15G  1.9G   12G  14% /tmpfs                          250m     0  250m   0% /dev/shm/dev/ sda1                     194M   26M  158M  15% /boot/dev/sr0                      3.6g  3.6g      0 100% /media/cdrom/dev/mapper/fcy--vg-fcy--lv  9.9G   151m  9.2g   2% /mnt/fcy-lvm    #已经挂载并可以使用

     expanding Logical volume size online

[[email protected] ~]# lvresize -l +1g /dev/fcy-vg/fcy-lv    Extending logical volume fcy-lv to 11.00 gib  logical volume  fcy-lv successfully resized[[email protected] ~]# lvdisplay   -- - logical volume ---  LV Path                 /dev/fcy-vg/fcy-lv  LV Name                 fcy-lv  vg name                 fcy-vg   LV UUID                 KF3klx-2aex-c3el-EduY-a3p8-Jh0G-W9IgHQ  LV Write Access         read/write  lv creation host, time fcy.com.cn, 2015-07-15 20:05:27 +0800   LV Status               available  # open                  1  LV Size                 11.00 GiB  Current LE              2816  Segments                2  Allocation              inherit  Read ahead sectors      auto  - currently set to     256   block device           253:0 

Note: After executing the lvresize, continue with the following command to extend the completion

[Email protected] ~]# resize2fs/dev/fcy-vg/fcy-lv resize2fs 1.41.12 (17-may-2010) Filesystem AT/DEV/FCY-VG/FCY-LV is mo Unted ON/MNT/FCY-LVM; On-line resizing Requiredold desc_blocks = 1, new_desc_blocks = 1Performing an on-line resize of/dev/fcy-vg/fcy-lv to 288 3584 (4k) blocks. The filesystem on/dev/fcy-vg/fcy-lv is now 2883584 blocks long.

Reduce the size of the logical volume ( Note that the directive does not support online, so uninstall the mount point first )

[Email protected] ~]# e2fsck-f/dev/fcy-vg/fcy-lv #强制系统文件检测e2fsck 1.41.12 (17-may-2010) Pass 1:checking inodes, block S, and Sizespass 2:checking directory structurepass 3:checking directory connectivitypass 4:checking reference Countspa SS 5:checking Group Summary information/dev/fcy-vg/fcy-lv:11/720896 files (0.0% non-contiguous), 84449/2883584 blocks

[[email protected] ~]# lvresize-l 8G/DEV/FCY-VG/FCY-LV warning:reducing Active Logical Volume to 8.00 GiB this may DE Stroy YOUR DATA (filesystem etc) Does really want to reduce fcy-lv? [y/n]: Y reducing Logical Volume FCY-LV to 8.00 GiB Logical volume FCY-LV successfully resized

Create a snapshot of a logical volume

[[email protected] ~]# lvcreate-l 1g-n fcy-snap-s/dev/fcy-vg/fcy-lv #-s Specifies the logical volume to take the snapshot Logical volume "Fcy-snap" created

Mount and compare

[[email protected] ~]# mount /dev/fcy-vg/fcy-snap /mnt/fcy-snapshot/[[email  protected] ~]# df -hfilesystem                      size  used avail use%  Mounted on/dev/sda2                        15G  1.9G   12G   14% /tmpfs                           250m     0   250M   0% /dev/shm/dev/sda1                       194m   26m   158m  15% /boot/dev/sr0                        3.6g  3.6g     0 100% / media/cdrom/dev/mapper/fcy--vg-fcy--lv    7.9g  151m  7.4g    2% /mnt/fcy-lvm/dev/mapper/fcy--vg-fcy--snap  7.9G  151M  7.4G    2% /mnt/fcy-snapshot


This article is from the "but evil Water Heart Pan" blog, please be sure to keep this source http://shmilyfl.blog.51cto.com/8897986/1675107

LVM Management under Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.