[Linux] PV,VG,LV相關
2016.5.21
pv,vg,lv
[root@iphone dev]# rpm -qa | grep lvm
lvm2-2.02.98-9.el6.x86_64
lvm2-libs-2.02.98-9.el6.x86_64
1.pvcreate --physical volume create
[root@iphone dev]# pvcreate /dev/sdb
Physical volume "/dev/sdb" successfully created
[root@iphone dev]# pvcreate /dev/sdc
Physical volume "/dev/sdc" successfully created
[root@iphone dev]# pvcreate /dev/sdd
Physical volume "/dev/sdd" successfully created
2.vgcreate --vg create
[root@iphone dev]# vgcreate vg00 /dev/sdb /dev/sdc
Volume group "vg00" successfully created
[root@iphone dev]# vgdisplay -v vg00
Using volume group(s) on command line
Finding volume group "vg00"
--- Volume group ---
VG Name vg00
System ID
Format lvm2
Metadata Areas 2
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 2
Act PV 2
VG Size 15.99 GiB
PE Size 4.00 MiB
Total PE 4094
Alloc PE / Size 0 / 0
Free PE / Size 4094 / 15.99 GiB
VG UUID Ui6Kbe-yuAV-KxTB-rIwc-BqQo-0nag-AvNfRF
--- Physical volumes ---
PV Name /dev/sdb
PV UUID B2K17I-fed9-sOCq-rbbK-r9EJ-4bdQ-V392a8
PV Status allocatable
Total PE / Free PE 2047 / 2047
PV Name /dev/sdc
PV UUID rPIiBP-8NRC-JzCH-4ghf-2Ef1-SZtV-P1mOo5
PV Status allocatable
Total PE / Free PE 2047 / 2047
[root@iphone dev]# pv
pvchange pvck pvcreate pvdisplay pvmove pvremove pvresize pvs pvscan pv.sh
[root@iphone dev]# pvscan
PV /dev/sdb VG vg00 lvm2 [8.00 GiB / 8.00 GiB free]
PV /dev/sdc VG vg00 lvm2 [8.00 GiB / 8.00 GiB free]
PV /dev/sda2 VG vg_iphone lvm2 [199.51 GiB / 0 free]
PV /dev/sdd lvm2 [8.00 GiB]
Total: 4 [223.50 GiB] / in use: 3 [215.50 GiB] / in no VG: 1 [8.00 GiB]
3.vgextend vg擴充套件
[root@iphone dev]# pvcreate /dev/sdd
Physical volume "/dev/sdd" successfully created
[root@iphone dev]# vgextend vg00 /dev/sdd
Volume group "vg00" successfully extended
[root@iphone dev]#
[root@iphone dev]# vgdisplay -v vg00
Using volume group(s) on command line
Finding volume group "vg00"
--- Volume group ---
VG Name vg00
System ID
Format lvm2
Metadata Areas 3
Metadata Sequence No 2
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 3
Act PV 3
VG Size 23.99 GiB
PE Size 4.00 MiB
Total PE 6141
Alloc PE / Size 0 / 0
Free PE / Size 6141 / 23.99 GiB
VG UUID Ui6Kbe-yuAV-KxTB-rIwc-BqQo-0nag-AvNfRF
--- Physical volumes ---
PV Name /dev/sdb
PV UUID B2K17I-fed9-sOCq-rbbK-r9EJ-4bdQ-V392a8
PV Status allocatable
Total PE / Free PE 2047 / 2047
PV Name /dev/sdc
PV UUID rPIiBP-8NRC-JzCH-4ghf-2Ef1-SZtV-P1mOo5
PV Status allocatable
Total PE / Free PE 2047 / 2047
PV Name /dev/sdd
PV UUID g92aTC-MK7x-29g8-GsEC-P3ax-GK3z-AA2FRX
PV Status allocatable
Total PE / Free PE 2047 / 2047
[root@iphone dev]#
[root@iphone dev]# vgscan
Reading all physical volumes. This may take a while...
Found volume group "vg00" using metadata type lvm2
Found volume group "vg_iphone" using metadata type lvm2
[root@iphone dev]#
[root@iphone dev]#
[root@iphone dev]# pvscan
PV /dev/sdb VG vg00 lvm2 [8.00 GiB / 8.00 GiB free]
PV /dev/sdc VG vg00 lvm2 [8.00 GiB / 8.00 GiB free]
PV /dev/sdd VG vg00 lvm2 [8.00 GiB / 8.00 GiB free]
PV /dev/sda2 VG vg_iphone lvm2 [199.51 GiB / 0 free]
Total: 4 [223.50 GiB] / in use: 4 [223.50 GiB] / in no VG: 0 [0 ]
4.lvcreate --logical volume create & 掛載檔案系統
[root@iphone dev]# lvcreate -L 2G -n lv00 vg00
Logical volume "lv00" created
[root@iphone vg00]# mkfs.ext3 /dev/vg00/lv00
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
131072 inodes, 524288 blocks
26214 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=536870912
16 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 34 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@iphone ~]# cd /mnt
[root@iphone mnt]# mkdir fs1
[root@iphone mnt]# mount /dev/vg00/lv00 /mnt/fs1/
[root@iphone mnt]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/vg_iphone-lv_root
51606140 43510436 5474264 89% /
tmpfs 1962952 1028528 934424 53% /dev/shm
/dev/sda1 495844 37919 432325 9% /boot
/dev/mapper/vg_iphone-lv_home
150309116 192344 142481420 1% /home
/dev/mapper/vg00-lv00
2064208 68676 1890676 4% /mnt/fs1
[root@iphone temp_dir]# cp bu2_20160331.dmp /mnt/fs1/
5.lvextend --logical volumne extend
[root@iphone fs1]# lvextend -L +1G /dev/vg00/lv00
Extending logical volume lv00 to 3.00 GiB
Logical volume lv00 successfully resized
[root@iphone fs1]# lvdisplay /dev/vg00/lv00
--- Logical volume ---
LV Path /dev/vg00/lv00
LV Name lv00
VG Name vg00
LV UUID TZ60jS-wT93-G5ym-n6yf-4g77-ng2S-3owaC3
LV Write Access read/write
LV Creation host, time iphone, 2016-05-21 05:11:25 +0800
LV Status available
# open 1
LV Size 3.00 GiB
Current LE 768
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:3
[root@iphone fs1]# df --lv extend,but filesystem is not change
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/vg_iphone-lv_root
51606140 43510460 5474240 89% /
tmpfs 1962952 1028528 934424 53% /dev/shm
/dev/sda1 495844 37919 432325 9% /boot
/dev/mapper/vg_iphone-lv_home
150309116 192344 142481420 1% /home
/dev/mapper/vg00-lv00
2064208 141636 1817716 8% /mnt/fs1
--so we need run below script
[root@iphone ~]# resize2fs /mnt/fs1/
resize2fs 1.41.12 (17-May-2010)
open: Is a directory while opening /mnt/fs1/
[root@iphone ~]#
[root@iphone ~]# resize2fs /dev/vg00/lv00
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/vg00/lv00 is mounted on /mnt/fs1; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 1
Performing an on-line resize of /dev/vg00/lv00 to 786432 (4k) blocks.
The filesystem on /dev/vg00/lv00 is now 786432 blocks long.
[root@iphone ~]# df --after run scripts,filesystem is change as logical volume.
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/vg_iphone-lv_root
51606140 43510464 5474236 89% /
tmpfs 1962952 1028528 934424 53% /dev/shm
/dev/sda1 495844 37919 432325 9% /boot
/dev/mapper/vg_iphone-lv_home
150309116 192344 142481420 1% /home
/dev/mapper/vg00-lv00
3096336 141636 2797428 5% /mnt/fs1
6.lvreduce --logical volume reduce
[root@iphone ~]# resize2fs /dev/vg00/lv00 2G --before we reduce the logical volumne,we need run some script.
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/vg00/lv00 is mounted on /mnt/fs1; on-line resizing required
On-line shrinking from 786432 to 524288 not supported.
[root@iphone ~]#
[root@iphone ~]# umount /mnt/fs1/
[root@iphone ~]# resize2fs /dev/vg00/lv00 2G
resize2fs 1.41.12 (17-May-2010)
Please run 'e2fsck -f /dev/vg00/lv00' first.
[root@iphone ~]# e2fsck -f /dev/vg00/lv00
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/vg00/lv00: 12/196608 files (8.3% non-contiguous), 47757/786432 blocks
[root@iphone ~]#
[root@iphone ~]# resize2fs /dev/vg00/lv00 2G
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/vg00/lv00 to 524288 (4k) blocks.
The filesystem on /dev/vg00/lv00 is now 524288 blocks long.
[root@iphone ~]# mount /dev/vg00/lv00 /mnt/fs1/
[root@iphone ~]#
[root@iphone ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/vg_iphone-lv_root
51606140 43510492 5474208 89% /
tmpfs 1962952 1028528 934424 53% /dev/shm
/dev/sda1 495844 37919 432325 9% /boot
/dev/mapper/vg_iphone-lv_home
150309116 192344 142481420 1% /home
/dev/mapper/vg00-lv00
2064208 141636 1817724 8% /mnt/fs1
[root@iphone fs1]# lvreduce -L 2G /dev/vg00/lv00
WARNING: Reducing active and open logical volume to 2.00 GiB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lv00? [y/n]: y
Reducing logical volume lv00 to 2.00 GiB
Logical volume lv00 successfully resized
7.vgreduce --vg reduce
[root@iphone fs1]# vgreduce vg00 /dev/sdd
Removed "/dev/sdd" from volume group "vg00"
[root@iphone fs1]#
[root@iphone fs1]#
[root@iphone fs1]# vgdisplay -v vg00
Using volume group(s) on command line
Finding volume group "vg00"
--- Volume group ---
VG Name vg00
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 8
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 15.99 GiB
PE Size 4.00 MiB
Total PE 4094
Alloc PE / Size 512 / 2.00 GiB
Free PE / Size 3582 / 13.99 GiB
VG UUID Ui6Kbe-yuAV-KxTB-rIwc-BqQo-0nag-AvNfRF
--- Logical volume ---
LV Path /dev/vg00/lv00
LV Name lv00
VG Name vg00
LV UUID TZ60jS-wT93-G5ym-n6yf-4g77-ng2S-3owaC3
LV Write Access read/write
LV Creation host, time iphone, 2016-05-21 05:11:25 +0800
LV Status available
# open 1
LV Size 2.00 GiB
Current LE 512
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:3
--- Physical volumes ---
PV Name /dev/sdb
PV UUID B2K17I-fed9-sOCq-rbbK-r9EJ-4bdQ-V392a8
PV Status allocatable
Total PE / Free PE 2047 / 1535
PV Name /dev/sdc
PV UUID rPIiBP-8NRC-JzCH-4ghf-2Ef1-SZtV-P1mOo5
PV Status allocatable
Total PE / Free PE 2047 / 2047
8.pvremove --physical volume remove
[root@iphone fs1]# pvremove /dev/sdd
Labels on physical volume "/dev/sdd" successfully wiped
9.pvmove --move physical extent
[root@iphone ~]# pvmove /dev/sdb
/dev/sdb: Moved: 0.4%
/dev/sdb: Moved: 55.0%
/dev/sdb: Moved: 99.8%
/dev/sdb: Moved: 100.0%
10.vgcfgbackup & vgcfgrestore
[root@iphone ~]# vgcfgbackup
Volume group "vg00" successfully backed up.
Volume group "vg_iphone" successfully backed up.
[root@iphone ~]# cd /etc/lvm
[root@iphone lvm]# ll
total 52
drwx------. 2 root root 4096 May 21 06:24 archive
drwx------. 2 root root 4096 May 21 06:30 backup
drwx------. 2 root root 4096 Jan 24 2013 cache
-rw-r--r--. 1 root root 37554 Jan 24 2013 lvm.conf
[root@iphone lvm]# cd backup
[root@iphone backup]# ll
total 8
-rw-------. 1 root root 2300 May 21 06:30 vg00
-rw-------. 1 root root 2091 May 21 06:30 vg_iphone
[root@iphone backup]# vgcfgrestore
Please specify a *single* volume group to restore.
[root@iphone backup]# vgcfgrestore vg00
Restored volume group vg00
11.vgchange (http://blog.chinaunix.net/uid-14418690-id-2812380.html)
a.單節點
vgchange –a y vgXX #啟用卷組
vgchange –a n vgXX #去啟用卷組
b.cluster
vgchange –c y /dev/vgXX #設定VG的exclusive屬性,設定之後VG無法以vgchange –a y 啟用
vgchange –c n /dev/vgXX #去掉VG的exclusive屬性,當然設定之後就無法用vgchange –a e來啟用這個VG了。
vgchange –a e /dev/vgXX #以exclusive模式啟用卷組,只在cluster環境下有效,需要首先vgchange –c y /dev/vgXX
vgchange –a n /dev/vgXX #在cluster模式下去啟用一個VG,仍然是用這個命令。
c.shared
vgchange –c y –S y /dev/vgXX #設定VG為共享模式,設定成功後VG只能用vgchange –a s啟用,如果要用vgchange –a y啟用,則必須先將VG的共享模式去掉(用vgchange –S n /dev/vgxx). #vgchange –a s /dev/vgXX #以共享方式啟用VG
vgchange –a n /dev/vgXX #在共享模式下去啟用方法不變
pv,vg,lv
[root@iphone dev]# rpm -qa | grep lvm
lvm2-2.02.98-9.el6.x86_64
lvm2-libs-2.02.98-9.el6.x86_64
1.pvcreate --physical volume create
[root@iphone dev]# pvcreate /dev/sdb
Physical volume "/dev/sdb" successfully created
[root@iphone dev]# pvcreate /dev/sdc
Physical volume "/dev/sdc" successfully created
[root@iphone dev]# pvcreate /dev/sdd
Physical volume "/dev/sdd" successfully created
2.vgcreate --vg create
[root@iphone dev]# vgcreate vg00 /dev/sdb /dev/sdc
Volume group "vg00" successfully created
[root@iphone dev]# vgdisplay -v vg00
Using volume group(s) on command line
Finding volume group "vg00"
--- Volume group ---
VG Name vg00
System ID
Format lvm2
Metadata Areas 2
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 2
Act PV 2
VG Size 15.99 GiB
PE Size 4.00 MiB
Total PE 4094
Alloc PE / Size 0 / 0
Free PE / Size 4094 / 15.99 GiB
VG UUID Ui6Kbe-yuAV-KxTB-rIwc-BqQo-0nag-AvNfRF
--- Physical volumes ---
PV Name /dev/sdb
PV UUID B2K17I-fed9-sOCq-rbbK-r9EJ-4bdQ-V392a8
PV Status allocatable
Total PE / Free PE 2047 / 2047
PV Name /dev/sdc
PV UUID rPIiBP-8NRC-JzCH-4ghf-2Ef1-SZtV-P1mOo5
PV Status allocatable
Total PE / Free PE 2047 / 2047
[root@iphone dev]# pv
pvchange pvck pvcreate pvdisplay pvmove pvremove pvresize pvs pvscan pv.sh
[root@iphone dev]# pvscan
PV /dev/sdb VG vg00 lvm2 [8.00 GiB / 8.00 GiB free]
PV /dev/sdc VG vg00 lvm2 [8.00 GiB / 8.00 GiB free]
PV /dev/sda2 VG vg_iphone lvm2 [199.51 GiB / 0 free]
PV /dev/sdd lvm2 [8.00 GiB]
Total: 4 [223.50 GiB] / in use: 3 [215.50 GiB] / in no VG: 1 [8.00 GiB]
3.vgextend vg擴充套件
[root@iphone dev]# pvcreate /dev/sdd
Physical volume "/dev/sdd" successfully created
[root@iphone dev]# vgextend vg00 /dev/sdd
Volume group "vg00" successfully extended
[root@iphone dev]#
[root@iphone dev]# vgdisplay -v vg00
Using volume group(s) on command line
Finding volume group "vg00"
--- Volume group ---
VG Name vg00
System ID
Format lvm2
Metadata Areas 3
Metadata Sequence No 2
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 3
Act PV 3
VG Size 23.99 GiB
PE Size 4.00 MiB
Total PE 6141
Alloc PE / Size 0 / 0
Free PE / Size 6141 / 23.99 GiB
VG UUID Ui6Kbe-yuAV-KxTB-rIwc-BqQo-0nag-AvNfRF
--- Physical volumes ---
PV Name /dev/sdb
PV UUID B2K17I-fed9-sOCq-rbbK-r9EJ-4bdQ-V392a8
PV Status allocatable
Total PE / Free PE 2047 / 2047
PV Name /dev/sdc
PV UUID rPIiBP-8NRC-JzCH-4ghf-2Ef1-SZtV-P1mOo5
PV Status allocatable
Total PE / Free PE 2047 / 2047
PV Name /dev/sdd
PV UUID g92aTC-MK7x-29g8-GsEC-P3ax-GK3z-AA2FRX
PV Status allocatable
Total PE / Free PE 2047 / 2047
[root@iphone dev]#
[root@iphone dev]# vgscan
Reading all physical volumes. This may take a while...
Found volume group "vg00" using metadata type lvm2
Found volume group "vg_iphone" using metadata type lvm2
[root@iphone dev]#
[root@iphone dev]#
[root@iphone dev]# pvscan
PV /dev/sdb VG vg00 lvm2 [8.00 GiB / 8.00 GiB free]
PV /dev/sdc VG vg00 lvm2 [8.00 GiB / 8.00 GiB free]
PV /dev/sdd VG vg00 lvm2 [8.00 GiB / 8.00 GiB free]
PV /dev/sda2 VG vg_iphone lvm2 [199.51 GiB / 0 free]
Total: 4 [223.50 GiB] / in use: 4 [223.50 GiB] / in no VG: 0 [0 ]
4.lvcreate --logical volume create & 掛載檔案系統
[root@iphone dev]# lvcreate -L 2G -n lv00 vg00
Logical volume "lv00" created
[root@iphone vg00]# mkfs.ext3 /dev/vg00/lv00
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
131072 inodes, 524288 blocks
26214 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=536870912
16 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 34 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@iphone ~]# cd /mnt
[root@iphone mnt]# mkdir fs1
[root@iphone mnt]# mount /dev/vg00/lv00 /mnt/fs1/
[root@iphone mnt]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/vg_iphone-lv_root
51606140 43510436 5474264 89% /
tmpfs 1962952 1028528 934424 53% /dev/shm
/dev/sda1 495844 37919 432325 9% /boot
/dev/mapper/vg_iphone-lv_home
150309116 192344 142481420 1% /home
/dev/mapper/vg00-lv00
2064208 68676 1890676 4% /mnt/fs1
[root@iphone temp_dir]# cp bu2_20160331.dmp /mnt/fs1/
5.lvextend --logical volumne extend
[root@iphone fs1]# lvextend -L +1G /dev/vg00/lv00
Extending logical volume lv00 to 3.00 GiB
Logical volume lv00 successfully resized
[root@iphone fs1]# lvdisplay /dev/vg00/lv00
--- Logical volume ---
LV Path /dev/vg00/lv00
LV Name lv00
VG Name vg00
LV UUID TZ60jS-wT93-G5ym-n6yf-4g77-ng2S-3owaC3
LV Write Access read/write
LV Creation host, time iphone, 2016-05-21 05:11:25 +0800
LV Status available
# open 1
LV Size 3.00 GiB
Current LE 768
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:3
[root@iphone fs1]# df --lv extend,but filesystem is not change
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/vg_iphone-lv_root
51606140 43510460 5474240 89% /
tmpfs 1962952 1028528 934424 53% /dev/shm
/dev/sda1 495844 37919 432325 9% /boot
/dev/mapper/vg_iphone-lv_home
150309116 192344 142481420 1% /home
/dev/mapper/vg00-lv00
2064208 141636 1817716 8% /mnt/fs1
--so we need run below script
[root@iphone ~]# resize2fs /mnt/fs1/
resize2fs 1.41.12 (17-May-2010)
open: Is a directory while opening /mnt/fs1/
[root@iphone ~]#
[root@iphone ~]# resize2fs /dev/vg00/lv00
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/vg00/lv00 is mounted on /mnt/fs1; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 1
Performing an on-line resize of /dev/vg00/lv00 to 786432 (4k) blocks.
The filesystem on /dev/vg00/lv00 is now 786432 blocks long.
[root@iphone ~]# df --after run scripts,filesystem is change as logical volume.
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/vg_iphone-lv_root
51606140 43510464 5474236 89% /
tmpfs 1962952 1028528 934424 53% /dev/shm
/dev/sda1 495844 37919 432325 9% /boot
/dev/mapper/vg_iphone-lv_home
150309116 192344 142481420 1% /home
/dev/mapper/vg00-lv00
3096336 141636 2797428 5% /mnt/fs1
6.lvreduce --logical volume reduce
[root@iphone ~]# resize2fs /dev/vg00/lv00 2G --before we reduce the logical volumne,we need run some script.
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/vg00/lv00 is mounted on /mnt/fs1; on-line resizing required
On-line shrinking from 786432 to 524288 not supported.
[root@iphone ~]#
[root@iphone ~]# umount /mnt/fs1/
[root@iphone ~]# resize2fs /dev/vg00/lv00 2G
resize2fs 1.41.12 (17-May-2010)
Please run 'e2fsck -f /dev/vg00/lv00' first.
[root@iphone ~]# e2fsck -f /dev/vg00/lv00
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/vg00/lv00: 12/196608 files (8.3% non-contiguous), 47757/786432 blocks
[root@iphone ~]#
[root@iphone ~]# resize2fs /dev/vg00/lv00 2G
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/vg00/lv00 to 524288 (4k) blocks.
The filesystem on /dev/vg00/lv00 is now 524288 blocks long.
[root@iphone ~]# mount /dev/vg00/lv00 /mnt/fs1/
[root@iphone ~]#
[root@iphone ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/vg_iphone-lv_root
51606140 43510492 5474208 89% /
tmpfs 1962952 1028528 934424 53% /dev/shm
/dev/sda1 495844 37919 432325 9% /boot
/dev/mapper/vg_iphone-lv_home
150309116 192344 142481420 1% /home
/dev/mapper/vg00-lv00
2064208 141636 1817724 8% /mnt/fs1
[root@iphone fs1]# lvreduce -L 2G /dev/vg00/lv00
WARNING: Reducing active and open logical volume to 2.00 GiB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lv00? [y/n]: y
Reducing logical volume lv00 to 2.00 GiB
Logical volume lv00 successfully resized
7.vgreduce --vg reduce
[root@iphone fs1]# vgreduce vg00 /dev/sdd
Removed "/dev/sdd" from volume group "vg00"
[root@iphone fs1]#
[root@iphone fs1]#
[root@iphone fs1]# vgdisplay -v vg00
Using volume group(s) on command line
Finding volume group "vg00"
--- Volume group ---
VG Name vg00
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 8
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 15.99 GiB
PE Size 4.00 MiB
Total PE 4094
Alloc PE / Size 512 / 2.00 GiB
Free PE / Size 3582 / 13.99 GiB
VG UUID Ui6Kbe-yuAV-KxTB-rIwc-BqQo-0nag-AvNfRF
--- Logical volume ---
LV Path /dev/vg00/lv00
LV Name lv00
VG Name vg00
LV UUID TZ60jS-wT93-G5ym-n6yf-4g77-ng2S-3owaC3
LV Write Access read/write
LV Creation host, time iphone, 2016-05-21 05:11:25 +0800
LV Status available
# open 1
LV Size 2.00 GiB
Current LE 512
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:3
--- Physical volumes ---
PV Name /dev/sdb
PV UUID B2K17I-fed9-sOCq-rbbK-r9EJ-4bdQ-V392a8
PV Status allocatable
Total PE / Free PE 2047 / 1535
PV Name /dev/sdc
PV UUID rPIiBP-8NRC-JzCH-4ghf-2Ef1-SZtV-P1mOo5
PV Status allocatable
Total PE / Free PE 2047 / 2047
8.pvremove --physical volume remove
[root@iphone fs1]# pvremove /dev/sdd
Labels on physical volume "/dev/sdd" successfully wiped
9.pvmove --move physical extent
[root@iphone ~]# pvmove /dev/sdb
/dev/sdb: Moved: 0.4%
/dev/sdb: Moved: 55.0%
/dev/sdb: Moved: 99.8%
/dev/sdb: Moved: 100.0%
10.vgcfgbackup & vgcfgrestore
[root@iphone ~]# vgcfgbackup
Volume group "vg00" successfully backed up.
Volume group "vg_iphone" successfully backed up.
[root@iphone ~]# cd /etc/lvm
[root@iphone lvm]# ll
total 52
drwx------. 2 root root 4096 May 21 06:24 archive
drwx------. 2 root root 4096 May 21 06:30 backup
drwx------. 2 root root 4096 Jan 24 2013 cache
-rw-r--r--. 1 root root 37554 Jan 24 2013 lvm.conf
[root@iphone lvm]# cd backup
[root@iphone backup]# ll
total 8
-rw-------. 1 root root 2300 May 21 06:30 vg00
-rw-------. 1 root root 2091 May 21 06:30 vg_iphone
[root@iphone backup]# vgcfgrestore
Please specify a *single* volume group to restore.
[root@iphone backup]# vgcfgrestore vg00
Restored volume group vg00
11.vgchange (http://blog.chinaunix.net/uid-14418690-id-2812380.html)
a.單節點
vgchange –a y vgXX #啟用卷組
vgchange –a n vgXX #去啟用卷組
b.cluster
vgchange –c y /dev/vgXX #設定VG的exclusive屬性,設定之後VG無法以vgchange –a y 啟用
vgchange –c n /dev/vgXX #去掉VG的exclusive屬性,當然設定之後就無法用vgchange –a e來啟用這個VG了。
vgchange –a e /dev/vgXX #以exclusive模式啟用卷組,只在cluster環境下有效,需要首先vgchange –c y /dev/vgXX
vgchange –a n /dev/vgXX #在cluster模式下去啟用一個VG,仍然是用這個命令。
c.shared
vgchange –c y –S y /dev/vgXX #設定VG為共享模式,設定成功後VG只能用vgchange –a s啟用,如果要用vgchange –a y啟用,則必須先將VG的共享模式去掉(用vgchange –S n /dev/vgxx). #vgchange –a s /dev/vgXX #以共享方式啟用VG
vgchange –a n /dev/vgXX #在共享模式下去啟用方法不變
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24237320/viewspace-2104968/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- AIX中PV,VG,LV及FS常用相關命令AI
- Linux中的建立PV-VG-LVLinux
- AIX PV VG LV詳解AI
- LVM原理及PV、VG、LV、PE、LE關係圖LVM
- LVM原理及PV、VG、LV、PE、LE關係圖【轉】LVM
- [HPUX] HP Unix pv,vg,lv操作UX
- aix 的pv vg lv 命令實踐AI
- unix中lun、pv、vg、lv等之間的關係
- linux 磁碟分割槽掛載-LVM-物理卷PV,卷組VG,邏輯卷LVLinuxLVM
- Linux作業系統中分割槽格式轉換LVM格式及多磁碟建立PV、VG、LVLinux作業系統LVM
- AIX系統LVM管理PV/VG/LV常用命令總結與實戰AILVM
- linux 磁碟自動化分割槽掛載-LVM-物理卷PV,卷組VG,邏輯卷LV-shellLinuxLVM
- lvm extend vg_centos-lv_root 大小LVMCentOS
- aix lvm big vgAILVM
- UNIX.AIX.檔案系統.儲存管理.邏輯卷管理.PV.VG.PP.LV.LPAI
- AIX同步映象VG中的新LV,手工映象LVAI
- UNIX.AIX.檔案系統.儲存管理.邏輯卷管理.PV.VG.PP.LV.LP --轉自網路AI
- lvm管理之pv遷移與lv擴充套件LVM套件
- Linux相關Linux
- Silverlight安裝相關問題
- Linux 相關2Linux
- linux相關記錄Linux
- [Linux]——程式管理相關Linux
- Linux 相關scsi命令Linux
- linux 安全相關命令Linux
- Linux 核心相關命令Linux
- Arch Linux ARM相關Linux
- 【LINUX】linux相關資源限制Linux
- Linux 、docker 、nginx 相關命令LinuxDockerNginx
- 【linux】命令-網路相關Linux
- Linux相關的操作指令Linux
- hadoop linux inode 相關HadoopLinux
- Linux口令相關知識Linux
- Linux網路相關命令Linux
- HP-ux.關於LUN,Vdisk,VG,LV,掛載點,裝置檔案等查詢例項描述UX
- ScrollView巢狀RecyclerView滑動衝突相關問題View巢狀
- Linux檔案管理相關命令Linux
- [Linux]字元處理相關命令Linux字元