venerdì 20 dicembre 2013

CentOS Logical Volumes Management

PREPARATORY STEPS

  • I did shut down the virtual host
  • I created 4 virtual hard disk drives big 10GB each
  • I attached them to a virtual SCSI controller of my virtual host
  • I powered on the virtual host

AT BOOT

Now these messages ad displayed at boot (dmesg):
...
hv_vmbus: registering driver hv_storvsc
scsi2 : storvsc_host_t
scsi 2:0:0:0: Direct-Access     Msft     Virtual Disk     1.0  PQ: 0 ANSI: 4
scsi3 : storvsc_host_t
scsi 3:0:0:0: Direct-Access     Msft     Virtual Disk     1.0  PQ: 0 ANSI: 4
scsi 3:0:0:2: Direct-Access     Msft     Virtual Disk     1.0  PQ: 0 ANSI: 4
scsi 3:0:0:1: Direct-Access     Msft     Virtual Disk     1.0  PQ: 0 ANSI: 4
scsi 3:0:0:3: Direct-Access     Msft     Virtual Disk     1.0  PQ: 0 ANSI: 4
sd 2:0:0:0: [sda] 266338304 512-byte logical blocks: (136 GB/127 GiB)
sd 2:0:0:0: [sda] Write Protect is off
sd 2:0:0:0: [sda] Mode Sense: 0f 00 00 00
sd 3:0:0:0: [sdb] 20971520 512-byte logical blocks: (10.7 GB/10.0 GiB)
sd 3:0:0:2: [sdc] 20971520 512-byte logical blocks: (10.7 GB/10.0 GiB)
sd 3:0:0:0: [sdb] Write Protect is off
sd 3:0:0:0: [sdb] Mode Sense: 0f 00 00 00
sd 3:0:0:2: [sdc] Write Protect is off
sd 3:0:0:2: [sdc] Mode Sense: 0f 00 00 00
sd 2:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
sd 3:0:0:0: [sdb] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
sd 3:0:0:2: [sdc] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
 sda:
 sdb: sda1 sda2
 sdc:
sd 3:0:0:1: [sdd] 20971520 512-byte logical blocks: (10.7 GB/10.0 GiB)
sd 3:0:0:1: [sdd] Write Protect is off
sd 3:0:0:1: [sdd] Mode Sense: 0f 00 00 00
sd 2:0:0:0: [sda] Attached SCSI disk
sd 3:0:0:1: [sdd] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
sd 3:0:0:3: [sde] 20971520 512-byte logical blocks: (10.7 GB/10.0 GiB)
sd 3:0:0:3: [sde] Write Protect is off
sd 3:0:0:3: [sde] Mode Sense: 0f 00 00 00
sd 3:0:0:3: [sde] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
 sdd:
 sde: unknown partition table
sd 3:0:0:0: [sdb] Attached SCSI disk
 unknown partition table
sd 3:0:0:2: [sdc] Attached SCSI disk
 unknown partition table
 unknown partition table
sd 3:0:0:1: [sdd] Attached SCSI disk
sd 3:0:0:3: [sde] Attached SCSI disk
...
sd 2:0:0:0: Attached scsi generic sg0 type 0
sd 3:0:0:0: Attached scsi generic sg1 type 0
sd 3:0:0:2: Attached scsi generic sg2 type 0
sd 3:0:0:1: Attached scsi generic sg3 type 0
sd 3:0:0:3: Attached scsi generic sg4 type 0
...
So, my new volumes are: sdb sdc sdd sde.

CREATING THE PHISICAL VOLUMES

[root@centoshost ~]# ls /dev/sd*
/dev/sda  /dev/sda1  /dev/sda2  /dev/sdb  /dev/sdc  /dev/sdd  /dev/sde
[root@centoshost ~]# pvcreate /dev/sdb
  Physical volume "/dev/sdb" successfully created
[root@centoshost ~]# pvcreate /dev/sdc
  Physical volume "/dev/sdc" successfully created
[root@centoshost ~]# pvcreate /dev/sdd
  Physical volume "/dev/sdd" successfully created
[root@centoshost ~]# pvcreate /dev/sde
  Physical volume "/dev/sde" successfully created
[root@centoshost ~]#

CREATING THE VOLUME GROUP

[root@centoshost ~]# vgcreate mytestvg /dev/sdb  /dev/sdc  /dev/sdd  /dev/sde
  Volume group "mytestvg" successfully created
[root@centoshost ~]# vgdisplay -v mytestvg
    Using volume group(s) on command line
    Finding volume group "mytestvg"
  --- Volume group ---
  VG Name               mytestvg
  System ID
  Format                lvm2
  Metadata Areas        4
  Metadata Sequence No  1
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                4
  Act PV                4
  VG Size               39.98 GiB
  PE Size               4.00 MiB
  Total PE              10236
  Alloc PE / Size       0 / 0
  Free  PE / Size       10236 / 39.98 GiB
  VG UUID               VuOgyc-w2NO-wZ7j-dDnn-Hy77-OOgN-rLjXOt

  --- Physical volumes ---
  PV Name               /dev/sdb
  PV UUID               cwLnS8-bDiV-OoXC-p6Mt-QxqT-WDLr-JjgjNZ
  PV Status             allocatable
  Total PE / Free PE    2559 / 2559

  PV Name               /dev/sdc
  PV UUID               ChG7YS-Lpfu-606z-E5Vq-hrux-qxxx-HYEupJ
  PV Status             allocatable
  Total PE / Free PE    2559 / 2559

  PV Name               /dev/sdd
  PV UUID               KL8MMX-L6tl-hdIm-PLko-11Nh-xpPg-MwIqBT
  PV Status             allocatable
  Total PE / Free PE    2559 / 2559

  PV Name               /dev/sde
  PV UUID               MoLGEY-7J3e-YIdI-GPP1-50n2-F57e-ofu6Hu
  PV Status             allocatable
  Total PE / Free PE    2559 / 2559

[root@centoshost ~]#

CREATING THE LOGICAL VOLUME

[root@centoshost ~]# lvcreate -l 2559 -n mytestlv1 mytestvg
  Logical volume "mytestlv1" created
[root@centoshost ~]#

[root@centoshost ~]# vgdisplay -v mytestvg
    Using volume group(s) on command line
    Finding volume group "mytestvg"
  --- Volume group ---
  VG Name               mytestvg
  System ID
  Format                lvm2
  Metadata Areas        4
  Metadata Sequence No  2
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               0
  Max PV                0
  Cur PV                4
  Act PV                4
  VG Size               39.98 GiB
  PE Size               4.00 MiB
  Total PE              10236
  Alloc PE / Size       2559 / 10.00 GiB
  Free  PE / Size       7677 / 29.99 GiB
  VG UUID               VuOgyc-w2NO-wZ7j-dDnn-Hy77-OOgN-rLjXOt

  --- Logical volume ---
  LV Path                /dev/mytestvg/mytestlv1
  LV Name                mytestlv1
  VG Name                mytestvg
  LV UUID                v5Btut-Kxod-g9Zm-KqtK-9HRr-pddL-7ziFOM
  LV Write Access        read/write
  LV Creation host, time centoshost, 2013-07-06 16:14:58 +0200
  LV Status              available
  # open                 0
  LV Size                10.00 GiB
  Current LE             2559
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:3

  --- Physical volumes ---
  PV Name               /dev/sdb
  PV UUID               cwLnS8-bDiV-OoXC-p6Mt-QxqT-WDLr-JjgjNZ
  PV Status             allocatable
  Total PE / Free PE    2559 / 0

  PV Name               /dev/sdc
  PV UUID               ChG7YS-Lpfu-606z-E5Vq-hrux-qxxx-HYEupJ
  PV Status             allocatable
  Total PE / Free PE    2559 / 2559

  PV Name               /dev/sdd
  PV UUID               KL8MMX-L6tl-hdIm-PLko-11Nh-xpPg-MwIqBT
  PV Status             allocatable
  Total PE / Free PE    2559 / 2559

  PV Name               /dev/sde
  PV UUID               MoLGEY-7J3e-YIdI-GPP1-50n2-F57e-ofu6Hu
  PV Status             allocatable
  Total PE / Free PE    2559 / 2559

[root@centoshost ~]# lvdisplay /dev/mytestvg/mytestlv1
  --- Logical volume ---
  LV Path                /dev/mytestvg/mytestlv1
  LV Name                mytestlv1
  VG Name                mytestvg
  LV UUID                v5Btut-Kxod-g9Zm-KqtK-9HRr-pddL-7ziFOM
  LV Write Access        read/write
  LV Creation host, time centoshost, 2013-07-06 16:14:58 +0200
  LV Status              available
  # open                 0
  LV Size                10.00 GiB
  Current LE             2559
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:3

[root@centoshost ~]#

CREATING THE FILESYSTEM ON THE LOGICAL VOLUME

[root@centoshost ~]# mke2fs /dev/mytestvg/mytestlv1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
655360 inodes, 2620416 blocks
131020 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2684354560
80 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

Writing inode tables: done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 32 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[root@centoshost ~]# tune2fs -l /dev/mytestvg/mytestlv1
tune2fs 1.41.12 (17-May-2010)
Filesystem volume name:   <none>
Last mounted on:          <not available>
Filesystem UUID:          ab9beb1c-2ded-4ae1-a083-c2f482ed074f
Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)
Filesystem features:      ext_attr resize_inode dir_index filetype sparse_super large_file
Filesystem flags:         signed_directory_hash
Default mount options:    (none)
Filesystem state:         clean
Errors behavior:          Continue
Filesystem OS type:       Linux
Inode count:              655360
Block count:              2620416
Reserved block count:     131020
Free blocks:              2573521
Free inodes:              655349
First block:              0
Block size:               4096
Fragment size:            4096
Reserved GDT blocks:      639
Blocks per group:         32768
Fragments per group:      32768
Inodes per group:         8192
Inode blocks per group:   512
Filesystem created:       Sat Jul  6 16:19:40 2013
Last mount time:          n/a
Last write time:          Sat Jul  6 16:19:40 2013
Mount count:              0
Maximum mount count:      32
Last checked:             Sat Jul  6 16:19:40 2013
Check interval:           15552000 (6 months)
Next check after:         Thu Jan  2 15:19:40 2014
Reserved blocks uid:      0 (user root)
Reserved blocks gid:      0 (group root)
First inode:              11
Inode size:               256
Required extra isize:     28
Desired extra isize:      28
Default directory hash:   half_md4
Directory Hash Seed:      7a3b64a5-abf6-4070-93ba-7ed4775e1dc5
[root@centoshost ~]# mount /dev/mytestvg/mytestlv1 /mnt/
[root@centoshost ~]# mount | grep test
/dev/mapper/mytestvg-mytestlv1 on /mnt type ext2 (rw)
[root@centoshost ~]# ls /mnt
lost+found
[root@centoshost ~]# df -m /mnt
Filesystem           1M-blocks      Used Available Use% Mounted on
/dev/mapper/mytestvg-mytestlv1
                         10076        23      9542   1% /mnt
[root@centoshost ~]#

CREATING SOME BOGUS CONTENT

[root@centoshost ~]# cd /mnt
[root@centoshost mnt]# for x in $(seq 0 9); do dd if=/dev/zero of=zero${x}.bin  bs=1024 count=10240; done
10240+0 records in
10240+0 records out
10485760 bytes (10 MB) copied, 0.0253373 s, 414 MB/s
10240+0 records in
10240+0 records out
10485760 bytes (10 MB) copied, 0.026879 s, 390 MB/s
10240+0 records in
10240+0 records out
10485760 bytes (10 MB) copied, 0.0264344 s, 397 MB/s
10240+0 records in
10240+0 records out
10485760 bytes (10 MB) copied, 0.025419 s, 413 MB/s
10240+0 records in
10240+0 records out
10485760 bytes (10 MB) copied, 0.0263466 s, 398 MB/s
10240+0 records in
10240+0 records out
10485760 bytes (10 MB) copied, 0.0195509 s, 536 MB/s
10240+0 records in
10240+0 records out
10485760 bytes (10 MB) copied, 0.0192691 s, 544 MB/s
10240+0 records in
10240+0 records out
10485760 bytes (10 MB) copied, 0.0110749 s, 947 MB/s
10240+0 records in
10240+0 records out
10485760 bytes (10 MB) copied, 0.0104302 s, 1.0 GB/s
10240+0 records in
10240+0 records out
10485760 bytes (10 MB) copied, 0.0116289 s, 902 MB/s
[root@centoshost mnt]# ls -l
total 112876
drwx------. 2 root root    16384 Jul  6 16:19 lost+found
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero0.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero1.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero2.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero3.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero4.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero5.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero6.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero7.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero8.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero9.bin
[root@centoshost mnt]# df -m .
Filesystem           1M-blocks      Used Available Use% Mounted on
/dev/mapper/mytestvg-mytestlv1
                         10076       123      9441   2% /mnt
[root@centoshost mnt]#

REDUCING A VOLUME GROUP - REMOVING PHISICAL VOLUMES TO IT:

[root@centoshost mnt]# pvscan
  PV /dev/sdb    VG mytestvg        lvm2 [10.00 GiB / 0    free]
  PV /dev/sdc    VG mytestvg        lvm2 [10.00 GiB / 10.00 GiB free]
  PV /dev/sdd    VG mytestvg        lvm2 [10.00 GiB / 10.00 GiB free]
  PV /dev/sde    VG mytestvg        lvm2 [10.00 GiB / 10.00 GiB free]
  PV /dev/sda2   VG vg_centoshost   lvm2 [126.51 GiB / 0    free]
  Total: 5 [166.49 GiB] / in use: 5 [166.49 GiB] / in no VG: 0 [0   ]
[root@centoshost mnt]# vgreduce mytestvg /dev/sde
  Removed "/dev/sde" from volume group "mytestvg"
[root@centoshost mnt]# vgreduce mytestvg /dev/sdd /dev/sdc
  Removed "/dev/sdd" from volume group "mytestvg"
  Removed "/dev/sdc" from volume group "mytestvg"
[root@centoshost mnt]# pvscan
  PV /dev/sdb    VG mytestvg        lvm2 [10.00 GiB / 0    free]
  PV /dev/sda2   VG vg_centoshost   lvm2 [126.51 GiB / 0    free]
  PV /dev/sdc                       lvm2 [10.00 GiB]
  PV /dev/sdd                       lvm2 [10.00 GiB]
  PV /dev/sde                       lvm2 [10.00 GiB]
  Total: 5 [166.50 GiB] / in use: 2 [136.50 GiB] / in no VG: 3 [30.00 GiB]
[root@centoshost mnt]#

EXTENDING A VOLUME GROUP - ADDING PHISICAL VOLUMES TO IT

[root@centoshost mnt]# vgextend mytestvg /dev/sdc
  Volume group "mytestvg" successfully extended
[root@centoshost mnt]#

EXTENDING A LOGICAL VOLUME

[root@centoshost mnt]# lvextend -l +2559 /dev/mytestvg/mytestlv1
  Extending logical volume mytestlv1 to 19.99 GiB
  Logical volume mytestlv1 successfully resized
[root@centoshost mnt]# lvdisplay -v /dev/mytestvg/mytestlv1
    Using logical volume(s) on command line
  --- Logical volume ---
  LV Path                /dev/mytestvg/mytestlv1
  LV Name                mytestlv1
  VG Name                mytestvg
  LV UUID                v5Btut-Kxod-g9Zm-KqtK-9HRr-pddL-7ziFOM
  LV Write Access        read/write
  LV Creation host, time centoshost, 2013-07-06 16:14:58 +0200
  LV Status              available
  # open                 1
  LV Size                19.99 GiB
  Current LE             5118
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:3

[root@centoshost mnt]# pvscan
  PV /dev/sdb    VG mytestvg        lvm2 [10.00 GiB / 0    free]
  PV /dev/sdc    VG mytestvg        lvm2 [10.00 GiB / 0    free]
  PV /dev/sda2   VG vg_centoshost   lvm2 [126.51 GiB / 0    free]
  PV /dev/sdd                       lvm2 [10.00 GiB]
  PV /dev/sde                       lvm2 [10.00 GiB]
  Total: 5 [166.50 GiB] / in use: 3 [146.50 GiB] / in no VG: 2 [20.00 GiB]
[root@centoshost mnt]# vgdisplay -v mytestvg
    Using volume group(s) on command line
    Finding volume group "mytestvg"
  --- Volume group ---
  VG Name               mytestvg
  System ID
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  13
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               19.99 GiB
  PE Size               4.00 MiB
  Total PE              5118
  Alloc PE / Size       5118 / 19.99 GiB
  Free  PE / Size       0 / 0
  VG UUID               VuOgyc-w2NO-wZ7j-dDnn-Hy77-OOgN-rLjXOt

  --- Logical volume ---
  LV Path                /dev/mytestvg/mytestlv1
  LV Name                mytestlv1
  VG Name                mytestvg
  LV UUID                v5Btut-Kxod-g9Zm-KqtK-9HRr-pddL-7ziFOM
  LV Write Access        read/write
  LV Creation host, time centoshost, 2013-07-06 16:14:58 +0200
  LV Status              available
  # open                 1
  LV Size                19.99 GiB
  Current LE             5118
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:3

  --- Physical volumes ---
  PV Name               /dev/sdb
  PV UUID               cwLnS8-bDiV-OoXC-p6Mt-QxqT-WDLr-JjgjNZ
  PV Status             allocatable
  Total PE / Free PE    2559 / 0

  PV Name               /dev/sdc
  PV UUID               ChG7YS-Lpfu-606z-E5Vq-hrux-qxxx-HYEupJ
  PV Status             allocatable
  Total PE / Free PE    2559 / 0

[root@centoshost mnt]#

EXTENDING A FILESYSTEM

[root@centoshost mnt]# resize2fs /dev/mytestvg/mytestlv1 $((4*5118))M # extent size * number of extents
resize2fs 1.41.12 (17-May-2010)
resize2fs: New size smaller than minimum (26802)

[root@centoshost mnt]# resize2fs /dev/mytestvg/mytestlv1 $((4*5118))M
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mytestvg/mytestlv1 is mounted on /mnt; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 2
resize2fs: Kernel does not support online resizing
[root@centoshost mnt]# cd
[root@centoshost ~]# umount /mnt/
[root@centoshost ~]# resize2fs /dev/mytestvg/mytestlv1 $((4*5118))M
resize2fs 1.41.12 (17-May-2010)
Please run 'e2fsck -f /dev/mytestvg/mytestlv1' first.

[root@centoshost ~]# e2fsck -f /dev/mytestvg/mytestlv1
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/mytestvg/mytestlv1: 21/655360 files (4.8% non-contiguous), 72536/2620416 blocks
[root@centoshost ~]# resize2fs /dev/mytestvg/mytestlv1 $((4*5118))M
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/mytestvg/mytestlv1 to 5240832 (4k) blocks.
The filesystem on /dev/mytestvg/mytestlv1 is now 5240832 blocks long.

[root@centoshost ~]# mount /dev/mytestvg/mytestlv1 /mnt
[root@centoshost ~]# df -m /mnt
Filesystem           1M-blocks      Used Available Use% Mounted on
/dev/mapper/mytestvg-mytestlv1
                         20151       128     19000   1% /mnt
[root@centoshost ~]# ls -l /mnt
total 102616
drwx------. 2 root root    16384 Jul  6 16:19 lost+found
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero0.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero1.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero2.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero3.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero4.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero5.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero6.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero7.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero8.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero9.bin
[root@centoshost ~]#

RISKY STUFF!!! - REDUCING THE FILESYSTEM AND THE LOGICAL VOLUME

[root@centoshost ~]# umount /mnt
[root@centoshost ~]# resize2fs /dev/mytestvg/mytestlv1 $((4*2559))M
resize2fs 1.41.12 (17-May-2010)
Please run 'e2fsck -f /dev/mytestvg/mytestlv1' first.
[root@centoshost ~]# e2fsck -f /dev/mytestvg/mytestlv1
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/mytestvg/mytestlv1: 21/1310720 files (4.8% non-contiguous), 114938/5240832 blocks
[root@centoshost ~]# resize2fs /dev/mytestvg/mytestlv1 $((4*2559))M
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/mytestvg/mytestlv1 to 2620416 (4k) blocks.
The filesystem on /dev/mytestvg/mytestlv1 is now 2620416 blocks long.
[root@centoshost ~]# lvreduce -l -2559 /dev/mytestvg/mytestlv1
  WARNING: Reducing active logical volume to 10.00 GiB
  THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce mytestlv1? [y/n]: y
  Reducing logical volume mytestlv1 to 10.00 GiB
  Logical volume mytestlv1 successfully resized
[root@centoshost ~]# pvscan
  PV /dev/sdb    VG mytestvg        lvm2 [10.00 GiB / 0    free]
  PV /dev/sdc    VG mytestvg        lvm2 [10.00 GiB / 10.00 GiB free]
  PV /dev/sda2   VG vg_centoshost   lvm2 [126.51 GiB / 0    free]
  PV /dev/sdd                       lvm2 [10.00 GiB]
  PV /dev/sde                       lvm2 [10.00 GiB]
  Total: 5 [166.50 GiB] / in use: 3 [146.50 GiB] / in no VG: 2 [20.00 GiB]
[root@centoshost ~]# mount /dev/mytestvg/mytestlv1 /mnt
[root@centoshost ~]# df -m /mnt
Filesystem           1M-blocks      Used Available Use% Mounted on
/dev/mapper/mytestvg-mytestlv1
                         10076       123      9441   2% /mnt
[root@centoshost ~]# ls -l /mnt
total 102616
drwx------. 2 root root    16384 Jul  6 16:19 lost+found
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero0.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero1.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero2.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero3.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero4.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero5.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero6.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero7.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero8.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero9.bin
[root@centoshost ~]# (cd /mnt; for x in $(seq 9); do cmp --verbose  zero0.bin zero${x}.bin && echo "lucky... $x == 0"; done)
lucky... 1 == 0
lucky... 2 == 0
lucky... 3 == 0
lucky... 4 == 0
lucky... 5 == 0
lucky... 6 == 0
lucky... 7 == 0
lucky... 8 == 0
lucky... 9 == 0
[root@centoshost ~]#

CONVERTING A LOGICAL VOLUME - ADDING ONE MIRROR

[root@centoshost ~]# vgdisplay mytestvg -v
    Using volume group(s) on command line
    Finding volume group "mytestvg"
  --- Volume group ---
  VG Name               mytestvg
  System ID
  Format                lvm2
  Metadata Areas        4
  Metadata Sequence No  32
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                4
  Act PV                4
  VG Size               39.98 GiB
  PE Size               4.00 MiB
  Total PE              10236
  Alloc PE / Size       2559 / 10.00 GiB
  Free  PE / Size       7677 / 29.99 GiB
  VG UUID               VuOgyc-w2NO-wZ7j-dDnn-Hy77-OOgN-rLjXOt

  --- Logical volume ---
  LV Path                /dev/mytestvg/mytestlv1
  LV Name                mytestlv1
  VG Name                mytestvg
  LV UUID                v5Btut-Kxod-g9Zm-KqtK-9HRr-pddL-7ziFOM
  LV Write Access        read/write
  LV Creation host, time centoshost, 2013-07-06 16:14:58 +0200
  LV Status              available
  # open                 1
  LV Size                10.00 GiB
  Current LE             2559
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:3

  --- Physical volumes ---
  PV Name               /dev/sdb
  PV UUID               cwLnS8-bDiV-OoXC-p6Mt-QxqT-WDLr-JjgjNZ
  PV Status             allocatable
  Total PE / Free PE    2559 / 0

  PV Name               /dev/sdc
  PV UUID               ChG7YS-Lpfu-606z-E5Vq-hrux-qxxx-HYEupJ
  PV Status             allocatable
  Total PE / Free PE    2559 / 2559

  PV Name               /dev/sdd
  PV UUID               KL8MMX-L6tl-hdIm-PLko-11Nh-xpPg-MwIqBT
  PV Status             allocatable
  Total PE / Free PE    2559 / 2559

  PV Name               /dev/sde
  PV UUID               MoLGEY-7J3e-YIdI-GPP1-50n2-F57e-ofu6Hu
  PV Status             allocatable
  Total PE / Free PE    2559 / 2559

[root@centoshost ~]# lvconvert -m1 /dev/mytestvg/mytestlv1
  mytestvg/mytestlv1: Converted: 0.0%
...
  mytestvg/mytestlv1: Converted: 100.0%
[root@centoshost ~]# vgdisplay mytestvg -v
    Using volume group(s) on command line
    Finding volume group "mytestvg"
  --- Volume group ---
  VG Name               mytestvg
  System ID
  Format                lvm2
  Metadata Areas        4
  Metadata Sequence No  34
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                4
  Act PV                4
  VG Size               39.98 GiB
  PE Size               4.00 MiB
  Total PE              10236
  Alloc PE / Size       5119 / 20.00 GiB
  Free  PE / Size       5117 / 19.99 GiB
  VG UUID               VuOgyc-w2NO-wZ7j-dDnn-Hy77-OOgN-rLjXOt

  --- Logical volume ---
  LV Path                /dev/mytestvg/mytestlv1
  LV Name                mytestlv1
  VG Name                mytestvg
  LV UUID                v5Btut-Kxod-g9Zm-KqtK-9HRr-pddL-7ziFOM
  LV Write Access        read/write
  LV Creation host, time centoshost, 2013-07-06 16:14:58 +0200
  LV Status              available
  # open                 1
  LV Size                10.00 GiB
  Current LE             2559
  Mirrored volumes       2
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:3

  --- Physical volumes ---
  PV Name               /dev/sdb
  PV UUID               cwLnS8-bDiV-OoXC-p6Mt-QxqT-WDLr-JjgjNZ
  PV Status             allocatable
  Total PE / Free PE    2559 / 0

  PV Name               /dev/sdc
  PV UUID               ChG7YS-Lpfu-606z-E5Vq-hrux-qxxx-HYEupJ
  PV Status             allocatable
  Total PE / Free PE    2559 / 0

  PV Name               /dev/sdd
  PV UUID               KL8MMX-L6tl-hdIm-PLko-11Nh-xpPg-MwIqBT
  PV Status             allocatable
  Total PE / Free PE    2559 / 2559

  PV Name               /dev/sde
  PV UUID               MoLGEY-7J3e-YIdI-GPP1-50n2-F57e-ofu6Hu
  PV Status             allocatable
  Total PE / Free PE    2559 / 2558

[root@centoshost ~]# pvscan
  PV /dev/sdb    VG mytestvg        lvm2 [10.00 GiB / 0    free]
  PV /dev/sdc    VG mytestvg        lvm2 [10.00 GiB / 0    free]
  PV /dev/sdd    VG mytestvg        lvm2 [10.00 GiB / 10.00 GiB free]
  PV /dev/sde    VG mytestvg        lvm2 [10.00 GiB / 9.99 GiB free]
  PV /dev/sda2   VG vg_centoshost   lvm2 [126.51 GiB / 0    free]
  Total: 5 [166.49 GiB] / in use: 5 [166.49 GiB] / in no VG: 0 [0   ]
[root@centoshost ~]# df -m
Filesystem           1M-blocks      Used Available Use% Mounted on
...
/dev/mapper/mytestvg-mytestlv1
                         10076       123      9441   2% /mnt
[root@centoshost ~]# 

DOING A SNAPSHOT BACKUP OF A LOGICAL VOLUME

[root@centoshost ~]# lvcreate -l 2559 -s /dev/mapper/mytestvg-mytestlv1 -n mytestlv1-snap /dev/sdd
  WARNING: Snapshots of mirrors can deadlock under rare device failures.
  WARNING: Consider using the raid1 mirror type to avoid this.
  WARNING: See global/mirror_segtype_default in lvm.conf.
  Logical volume "mytestlv1-snap" created
[root@centoshost ~]# lvscan
  ACTIVE   Original '/dev/mytestvg/mytestlv1' [10.00 GiB] inherit
  ACTIVE   Snapshot '/dev/mytestvg/mytestlv1-snap' [10.00 GiB] inherit
  ACTIVE            '/dev/vg_centoshost/lv_root' [50.00 GiB] inherit
  ACTIVE            '/dev/vg_centoshost/lv_home' [72.60 GiB] inherit
  ACTIVE            '/dev/vg_centoshost/lv_swap' [3.91 GiB] inherit
[root@centoshost ~]# mkdir /mnt2
[root@centoshost ~]# mount /dev/mytestvg/mytestlv1-snap /mnt2
[root@centoshost ~]# ls -l /mnt2
total 102616
drwx------. 2 root root    16384 Jul  6 16:19 lost+found
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero0.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero1.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero2.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero3.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero4.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero5.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero6.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero7.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero8.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero9.bin
[root@centoshost ~]#
Then you may eventually backup the files to tape using you preferred software (tar for example) and remove the snapshot.
[root@centoshost ~]# pvscan
  PV /dev/sdb    VG mytestvg        lvm2 [10.00 GiB / 0    free]
  PV /dev/sdc    VG mytestvg        lvm2 [10.00 GiB / 0    free]
  PV /dev/sdd    VG mytestvg        lvm2 [10.00 GiB / 0    free]
  PV /dev/sde    VG mytestvg        lvm2 [10.00 GiB / 9.99 GiB free]
  PV /dev/sda2   VG vg_centoshost   lvm2 [126.51 GiB / 0    free]
  Total: 5 [166.49 GiB] / in use: 5 [166.49 GiB] / in no VG: 0 [0   ]
[root@centoshost ~]# umount /mnt2
[root@centoshost ~]# lvremove /dev/mytestvg/mytestlv1-snap
Do you really want to remove active logical volume mytestlv1-snap? [y/n]: y
  Logical volume "mytestlv1-snap" successfully removed
[root@centoshost ~]# pvscan
  PV /dev/sdb    VG mytestvg        lvm2 [10.00 GiB / 0    free]
  PV /dev/sdc    VG mytestvg        lvm2 [10.00 GiB / 0    free]
  PV /dev/sdd    VG mytestvg        lvm2 [10.00 GiB / 10.00 GiB free]
  PV /dev/sde    VG mytestvg        lvm2 [10.00 GiB / 9.99 GiB free]
  PV /dev/sda2   VG vg_centoshost   lvm2 [126.51 GiB / 0    free]
  Total: 5 [166.49 GiB] / in use: 5 [166.49 GiB] / in no VG: 0 [0   ]
[root@centoshost ~]#

RELATED COMMANDS, MANUALS AND OTHER FILES

[root@centoshost ~]# rpm -qd lvm2
/usr/share/doc/lvm2-2.02.98/COPYING
/usr/share/doc/lvm2-2.02.98/COPYING.LIB
/usr/share/doc/lvm2-2.02.98/INSTALL
/usr/share/doc/lvm2-2.02.98/README
/usr/share/doc/lvm2-2.02.98/VERSION
/usr/share/doc/lvm2-2.02.98/WHATS_NEW
/usr/share/man/man5/lvm.conf.5.gz
/usr/share/man/man8/blkdeactivate.8.gz
/usr/share/man/man8/fsadm.8.gz
/usr/share/man/man8/lvchange.8.gz
/usr/share/man/man8/lvconvert.8.gz
/usr/share/man/man8/lvcreate.8.gz
/usr/share/man/man8/lvdisplay.8.gz
/usr/share/man/man8/lvextend.8.gz
/usr/share/man/man8/lvm.8.gz
/usr/share/man/man8/lvmchange.8.gz
/usr/share/man/man8/lvmconf.8.gz
/usr/share/man/man8/lvmdiskscan.8.gz
/usr/share/man/man8/lvmdump.8.gz
/usr/share/man/man8/lvmetad.8.gz
/usr/share/man/man8/lvmsadc.8.gz
/usr/share/man/man8/lvmsar.8.gz
/usr/share/man/man8/lvreduce.8.gz
/usr/share/man/man8/lvremove.8.gz
/usr/share/man/man8/lvrename.8.gz
/usr/share/man/man8/lvresize.8.gz
/usr/share/man/man8/lvs.8.gz
/usr/share/man/man8/lvscan.8.gz
/usr/share/man/man8/pvchange.8.gz
/usr/share/man/man8/pvck.8.gz
/usr/share/man/man8/pvcreate.8.gz
/usr/share/man/man8/pvdisplay.8.gz
/usr/share/man/man8/pvmove.8.gz
/usr/share/man/man8/pvremove.8.gz
/usr/share/man/man8/pvresize.8.gz
/usr/share/man/man8/pvs.8.gz
/usr/share/man/man8/pvscan.8.gz
/usr/share/man/man8/vgcfgbackup.8.gz
/usr/share/man/man8/vgcfgrestore.8.gz
/usr/share/man/man8/vgchange.8.gz
/usr/share/man/man8/vgck.8.gz
/usr/share/man/man8/vgconvert.8.gz
/usr/share/man/man8/vgcreate.8.gz
/usr/share/man/man8/vgdisplay.8.gz
/usr/share/man/man8/vgexport.8.gz
/usr/share/man/man8/vgextend.8.gz
/usr/share/man/man8/vgimport.8.gz
/usr/share/man/man8/vgimportclone.8.gz
/usr/share/man/man8/vgmerge.8.gz
/usr/share/man/man8/vgmknodes.8.gz
/usr/share/man/man8/vgreduce.8.gz
/usr/share/man/man8/vgremove.8.gz
/usr/share/man/man8/vgrename.8.gz
/usr/share/man/man8/vgs.8.gz
/usr/share/man/man8/vgscan.8.gz
/usr/share/man/man8/vgsplit.8.gz