038-LVM配置過程詳解

1. 理解LVM概念

 

LVM:logical Volume Manager 邏輯卷管理器node

VG:Volume Group  卷組,是單個或多個物理卷的集合web

PV:physical volume 物理卷,物理卷是LVM的邏輯存儲塊,物理卷是磁盤分區的邏輯對應關係,LVM提供的命令可使物理磁盤進行物理卷的分區,以後多個物理卷造成卷組app

LV:Logical Volume 邏輯卷,就是LVM邏輯上的分區,咱們能夠指定從卷組中提取多少容量來建立邏輯卷,最後對邏輯卷格式化並掛載使用ide

PE:physical Extent,物理長度是將物理卷組合成爲卷組後,所劃分的最小存儲單位,即邏輯意義上磁盤的最小存儲單元,LVM默認PE大小爲4MB工具

2. 使用命令(pvcreate,vgcreate,lvcreate,pvs,vgs,lvs)

以前一小節理解了概念,那麼如何理論加實踐?pvcreate將分區轉換爲物理卷的命令。vgcreate是將物理卷整合成卷組,lvcreate是將卷組中提取的容量建立邏輯卷 ,建立完成以後用pvdisplay,vgdisplay,lvdisplay 能夠查看狀態。ui

pvcreate: pvcreate /dev/sda this

vgcreate:vgcreate VGgroup00 /dev/sda1 /dev/sda2spa

vgcreate VGgroup01 -s 16M /dev/sda1 /dev/sda2   #定義PE大小16Mcode

lvcreate: lvcreate -L 1G -n test-lv test-vg   #建立容量爲1G的邏輯卷orm

lvcreate -l 200 -n test-lv test-vg            #使用200個PE建立邏輯卷,PE大小爲16M

lvcreate -L 1G -n test-lv test-vg /dev/sda3  #指定使用/dev/sdb6這個物理卷的存儲空間

3.實戰演練

3.1 分區

[root@cnsz142728 ~]# vgs
  VG         #PV #LV #SN Attr   VSize  VFree
  VolGroup00   1   6   0 wz--n- 98.97g 8.97g
[root@cnsz142728 ~]# pvs
  PV         VG         Fmt  Attr PSize  PFree
  /dev/sda2  VolGroup00 lvm2 a--  98.97g 8.97g
[root@cnsz142728 ~]# lvs
  LV      VG         Attr       LSize  Pool Origin Data%  Move Log Cpy%Sync Convert
  LVhome  VolGroup00 -wi-ao----  2.00g                                             
  LVpalog VolGroup00 -wi-ao---- 30.00g                                             
  LVroot  VolGroup00 -wi-ao---- 20.00g                                             
  LVswap  VolGroup00 -wi-ao----  8.00g                                             
  LVtmp   VolGroup00 -wi-ao---- 10.00g                                             
  LVvar   VolGroup00 -wi-ao---- 20.00g                                             
[root@cnsz142728 ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xa4652d68.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-6527, default 1): 1
Last cylinder, +cylinders or +size{K,M,G} (1-6527, default 6527): 2000

Command (m for help): p

Disk /dev/sdb: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xa4652d68

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        2000    16064968+  83  Linux

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (2001-6527, default 2001): 
Using default value 2001
Last cylinder, +cylinders or +size{K,M,G} (2001-6527, default 6527): 4000

...重複操做...

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        2000    16064968+  83  Linux
/dev/sdb2            2001        4000    16065000   83  Linux
/dev/sdb4            4001        6527    20298127+  83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

使用fdisk工具只是將分區信息寫到磁盤,若是須要mkfs磁盤分區則須要重啓系統,而使用partprobe則可使kernel從新讀取分區信息,從而避免重啓系統。

[root@cnsz142728 ~]# partprobe /dev/sdb

3.2 使用pvdisplay查看結果 

這個時候的sda4是沒有進行物理卷的生成

[root@cnsz142728 ~]# pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda2
  VG Name               VolGroup00
  PV Size               99.00 GiB / not usable 31.00 MiB
  Allocatable           yes 
  PE Size               32.00 MiB
  Total PE              3167
  Free PE               287
  Allocated PE          2880
  PV UUID               ysQSII-3CCh-8PiV-Of3P-5iXh-kSFc-1QZb8P
   
  "/dev/sdb1" is a new physical volume of "15.32 GiB"
  --- NEW Physical volume ---
  PV Name               /dev/sdb1
  VG Name               
  PV Size               15.32 GiB
  Allocatable           NO
  PE Size               0   
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               SrPRqp-yyhm-LcX5-KVHk-upN2-A1zo-cw06T6
   
  "/dev/sdb2" is a new physical volume of "15.32 GiB"
  --- NEW Physical volume ---
  PV Name               /dev/sdb2
  VG Name               
  PV Size               15.32 GiB
  Allocatable           NO
  PE Size               0   
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               3gPnzn-m4sc-UE8K-Dq9i-hP5D-vnIm-Q0xUNf

3.3 建立卷組

[root@cnsz142728 ~]# vgcreate Catlron_007 /dev/sdb{1,2}
  Volume group "Catlron_007" successfully created
[root@cnsz142728 ~]# pvs
  PV         VG          Fmt  Attr PSize  PFree 
  /dev/sda2  VolGroup00  lvm2 a--  98.97g  8.97g
  /dev/sdb1  Catlron_007 lvm2 a--  15.32g 15.32g
  /dev/sdb2  Catlron_007 lvm2 a--  15.32g 15.32g
[root@cnsz142728 ~]# vgdisplay
  --- Volume group ---
  VG Name               Catlron_007
  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               30.63 GiB
  PE Size               4.00 MiB
  Total PE              7842
  Alloc PE / Size       0 / 0   
  Free  PE / Size       7842 / 30.63 GiB
  VG UUID               OQfuUj-uQAk-bMXs-CZn1-NUkg-IwTv-gNuW3o
   
  --- Volume group ---
  VG Name               VolGroup00
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  7
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                6
  Open LV               6
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               98.97 GiB
  PE Size               32.00 MiB
  Total PE              3167
  Alloc PE / Size       2880 / 90.00 GiB
  Free  PE / Size       287 / 8.97 GiB
  VG UUID               jZb7ls-eYSl-Z9a7-esT2-8EnG-GS2w-phNLyI

3.4 建立邏輯卷 

[root@cnsz142728 ~]# vgs
  VG         #PV #LV #SN Attr   VSize  VFree 
  Carlton_TT   2   0   0 wz--n- 30.63g 30.63g
  VolGroup00   1   6   0 wz--n- 98.97g  8.97g
[root@cnsz142728 ~]# lvcreate -L 1G -n test VolGroup00 
  Logical volume "test" created
[root@cnsz142728 ~]# vgs
  VG         #PV #LV #SN Attr   VSize  VFree 
  Carlton_TT   2   0   0 wz--n- 30.63g 30.63g
  VolGroup00   1   7   0 wz--n- 98.97g  7.97g
[root@cnsz142728 ~]# lvs
  LV      VG         Attr       LSize  Pool Origin Data%  Move Log Cpy%Sync Convert
  LVhome  VolGroup00 -wi-ao----  2.00g                                             
  LVpalog VolGroup00 -wi-ao---- 30.00g                                             
  LVroot  VolGroup00 -wi-ao---- 20.00g                                             
  LVswap  VolGroup00 -wi-ao----  8.00g                                             
  LVtmp   VolGroup00 -wi-ao---- 10.00g                                             
  LVvar   VolGroup00 -wi-ao---- 20.00g                                             
  test    VolGroup00 -wi-a-----  1.00g 

若是出現報錯,好比Faied to activate new LV  
能夠去看看/etc/lvm/lvm.conf 中的配置中是否是有卷組名稱
    # If any host tags exist but volume_list is not defined, a default
    # single-entry list containing "@*" is assumed.
    #
    volume_list = ["Carlton_TT" "VolGroup00", "VolGroup01", "VolGroup02", "@cnsz142728" ]
[root@cnsz142728 ~]# mkdir /test/mumu
[root@cnsz142728 ~]# mount /dev/Carlton_TT/music /test/mumu 
[root@cnsz142728 ~]# df -h
Filesystem                      Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LVroot    20G  2.5G   17G  14% /
/dev/mapper/VolGroup00-LVhome   2.0G   68M  1.9G   4% /home
/dev/mapper/VolGroup00-LVtmp    9.9G  151M  9.2G   2% /tmp
/dev/mapper/VolGroup00-LVvar     20G  292M   19G   2% /var
/dev/sda1                      1008M   63M  895M   7% /boot
tmpfs                           3.9G     0  3.9G   0% /dev/shm
/dev/mapper/VolGroup00-LVpalog   30G  182M   28G   1% /palog
/dev/mapper/VolGroup00-test    1008M   34M  924M   4% /test/web
/dev/mapper/Carlton_TT-music    9.9G  151M  9.2G   2% /test/mumu

3.5 格式化並掛載磁盤

[root@cnsz142728 ~]# mkfs.ext4 /dev/VolGroup00/test
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
65536 inodes, 262144 blocks
13107 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=268435456
8 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376

Writing inode tables: done                            
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 29 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

看提示
tune2fs -i0 -c0 /dev/VolGroup00/test


[root@cnsz142728 ~]# lvs
  LV      VG         Attr       LSize  Pool Origin Data%  Move Log Cpy%Sync Convert
  LVhome  VolGroup00 -wi-ao----  2.00g                                             
  LVpalog VolGroup00 -wi-ao---- 30.00g                                             
  LVroot  VolGroup00 -wi-ao---- 20.00g                                             
  LVswap  VolGroup00 -wi-ao----  8.00g                                             
  LVtmp   VolGroup00 -wi-ao---- 10.00g                                             
  LVvar   VolGroup00 -wi-ao---- 20.00g                                             
  test    VolGroup00 -wi-a-----  1.00g                                             
[root@cnsz142728 ~]# mount /dev/VolGroup00/test /mnt/
[root@cnsz142728 ~]# df -h
Filesystem                      Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LVroot    20G  2.5G   17G  14% /
tmpfs                           3.9G     0  3.9G   0% /dev/shm
/dev/sda1                      1008M   63M  895M   7% /boot
/dev/mapper/VolGroup00-LVhome   2.0G   68M  1.9G   4% /home
/dev/mapper/VolGroup00-LVtmp    9.9G  151M  9.2G   2% /tmp
/dev/mapper/VolGroup00-LVvar     20G  292M   19G   2% /var
/dev/mapper/VolGroup00-LVpalog   30G  182M   28G   1% /palog
/dev/mapper/VolGroup00-test    1008M   34M  924M   4% /mnt

設置自動掛載,若是沒有掛載上去, 系統能夠幫你掛載上去
[root@cnsz142728 ~]# cat >>/etc/fstab <<EOF
> /dev/VolGroup00/test  /test/web  ext4   defaults  0  0 
> EOF
[root@cnsz142728 ~]# mount -a
[root@cnsz142728 ~]# df -h
Filesystem                      Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LVroot    20G  2.5G   17G  14% /
tmpfs                           3.9G     0  3.9G   0% /dev/shm
/dev/sda1                      1008M   63M  895M   7% /boot
/dev/mapper/VolGroup00-LVhome   2.0G   68M  1.9G   4% /home
/dev/mapper/VolGroup00-LVtmp    9.9G  151M  9.2G   2% /tmp
/dev/mapper/VolGroup00-LVvar     20G  292M   19G   2% /var
/dev/mapper/VolGroup00-LVpalog   30G  182M   28G   1% /palog
/dev/mapper/VolGroup00-test    1008M   34M  924M   4% /test/web

4.磁盤碰見問題的常見處理方式

4.1 邏輯卷不夠用擴卷(由原來的1G擴到1.5G ) 

能夠線上操做,不會影響該卷的原來數據,lvextend -L +500M /dev/XXX 以後記得用resize2fs 進行生效

[root@cnsz142728 ~]# df -h
Filesystem                      Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LVroot    20G  2.5G   17G  14% /
/dev/mapper/VolGroup00-LVhome   2.0G   68M  1.9G   4% /home
/dev/mapper/VolGroup00-LVtmp    9.9G  151M  9.2G   2% /tmp
/dev/mapper/VolGroup00-LVvar     20G  292M   19G   2% /var
/dev/sda1                      1008M   63M  895M   7% /boot
tmpfs                           3.9G     0  3.9G   0% /dev/shm
/dev/mapper/VolGroup00-LVpalog   30G  182M   28G   1% /palog
/dev/mapper/VolGroup00-test    1008M   34M  924M   4% /test/web
/dev/mapper/Carlton_TT-music    9.9G  151M  9.2G   2% /test/mumu
[root@cnsz142728 ~]# lvextend -L +500M /dev/VolGroup00/test 
  Rounding size to boundary between physical extents: 512.00 MiB
  Extending logical volume test to 1.50 GiB
  Logical volume test successfully resized
[root@cnsz142728 ~]# df -h
Filesystem                      Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LVroot    20G  2.5G   17G  14% /
/dev/mapper/VolGroup00-LVhome   2.0G   68M  1.9G   4% /home
/dev/mapper/VolGroup00-LVtmp    9.9G  151M  9.2G   2% /tmp
/dev/mapper/VolGroup00-LVvar     20G  292M   19G   2% /var
/dev/sda1                      1008M   63M  895M   7% /boot
tmpfs                           3.9G     0  3.9G   0% /dev/shm
/dev/mapper/VolGroup00-LVpalog   30G  182M   28G   1% /palog
/dev/mapper/VolGroup00-test    1008M   34M  924M   4% /test/web
/dev/mapper/Carlton_TT-music    9.9G  151M  9.2G   2% /test/mumu
[root@cnsz142728 ~]# lvs
  LV      VG         Attr       LSize  Pool Origin Data%  Move Log Cpy%Sync Convert
  music   Carlton_TT -wi-ao---- 10.00g                                             
  LVhome  VolGroup00 -wi-ao----  2.00g                                             
  LVpalog VolGroup00 -wi-ao---- 30.00g                                             
  LVroot  VolGroup00 -wi-ao---- 20.00g                                             
  LVswap  VolGroup00 -wi-ao----  8.00g                                             
  LVtmp   VolGroup00 -wi-ao---- 10.00g                                             
  LVvar   VolGroup00 -wi-ao---- 20.00g                                             
  test    VolGroup00 -wi-ao----  1.50g                                             
[root@cnsz142728 ~]# resize2fs /dev/VolGroup00/test 
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/VolGroup00/test is mounted on /test/web; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 1
Performing an on-line resize of /dev/VolGroup00/test to 393216 (4k) blocks.
The filesystem on /dev/VolGroup00/test is now 393216 blocks long.

[root@cnsz142728 ~]# df -h
Filesystem                      Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LVroot    20G  2.5G   17G  14% /
/dev/mapper/VolGroup00-LVhome   2.0G   68M  1.9G   4% /home
/dev/mapper/VolGroup00-LVtmp    9.9G  151M  9.2G   2% /tmp
/dev/mapper/VolGroup00-LVvar     20G  292M   19G   2% /var
/dev/sda1                      1008M   63M  895M   7% /boot
tmpfs                           3.9G     0  3.9G   0% /dev/shm
/dev/mapper/VolGroup00-LVpalog   30G  182M   28G   1% /palog
/dev/mapper/VolGroup00-test     1.5G   34M  1.4G   3% /test/web
/dev/mapper/Carlton_TT-music    9.9G  151M  9.2G   2% /test/mumu

4.2 卷組不夠用

vgextend 卷組名  /dev/sdb*

[root@cnsz142728 ~]# pvs
  PV         VG         Fmt  Attr PSize  PFree 
  /dev/sda2  VolGroup00 lvm2 a--  98.97g  7.47g
  /dev/sdb1  Carlton_TT lvm2 a--  15.32g  5.32g
  /dev/sdb2  Carlton_TT lvm2 a--  15.32g 15.32g
[root@cnsz142728 ~]# fdisk -l |grep sdb
Disk /dev/sdb: 53.7 GB, 53687091200 bytes
/dev/sdb1               1        2000    16064968+  83  Linux
/dev/sdb2            2001        4000    16065000   83  Linux
/dev/sdb4            4001        6527    20298127+  83  Linux
[root@cnsz142728 ~]# vgextend Carlton_TT /dev/sdb4
  No physical volume label read from /dev/sdb4
  Physical volume /dev/sdb4 not found
  Physical volume "/dev/sdb4" successfully created
  Volume group "Carlton_TT" successfully extended
[root@cnsz142728 ~]# pvs
  PV         VG         Fmt  Attr PSize  PFree 
  /dev/sda2  VolGroup00 lvm2 a--  98.97g  7.47g
  /dev/sdb1  Carlton_TT lvm2 a--  15.32g  5.32g
  /dev/sdb2  Carlton_TT lvm2 a--  15.32g 15.32g
  /dev/sdb4  Carlton_TT lvm2 a--  19.36g 19.36g
[root@cnsz142728 ~]# vgs
  VG         #PV #LV #SN Attr   VSize  VFree 
  Carlton_TT   3   1   0 wz--n- 49.99g 39.99g
  VolGroup00   1   7   0 wz--n- 98.97g  7.47g

4.3 當邏輯卷不夠用時,能夠縮卷

縮卷之間先umount,

注意,邏輯卷和文件系統保持同樣的大小

[root@cnsz142728 ~]# e2fsck -f /dev/mapper/Carlton_TT-music 
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/Carlton_TT-music: 11/655360 files (0.0% non-contiguous), 79663/2621440 blocks
[root@cnsz142728 ~]# resize2fs /dev/mapper/Carlton_TT-music 500M
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/mapper/Carlton_TT-music to 128000 (4k) blocks.
The filesystem on /dev/mapper/Carlton_TT-music is now 128000 blocks long.

[root@cnsz142728 ~]# lvreduce -L 500M /dev/mapper/Carlton_TT-music 
  WARNING: Reducing active logical volume to 500.00 MiB
  THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce music? [y/n]: y
  Reducing logical volume music to 500.00 MiB
  Logical volume music successfully resized
[root@cnsz142728 ~]# mount /dev/Carlton_TT/music /test/mumu 
[root@cnsz142728 ~]# df -h
Filesystem                      Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LVroot    20G  2.5G   17G  14% /
/dev/mapper/VolGroup00-LVhome   2.0G   68M  1.9G   4% /home
/dev/mapper/VolGroup00-LVtmp    9.9G  151M  9.2G   2% /tmp
/dev/mapper/VolGroup00-LVvar     20G  292M   19G   2% /var
/dev/sda1                      1008M   63M  895M   7% /boot
tmpfs                           3.9G     0  3.9G   0% /dev/shm
/dev/mapper/VolGroup00-LVpalog   30G  182M   28G   1% /palog
/dev/mapper/VolGroup00-test     1.5G   34M  1.4G   3% /test/web
/dev/mapper/Carlton_TT-music    492M  136M  332M  30% /test/mumu

4.4 若是某一塊磁盤或者分區故障瞭如何將數據快速轉移到相同的卷組其餘的空間去

a、經過pvmove命令轉移空間數據

b、經過vgreduce命令將即將壞的磁盤或者分區從卷組vgdata裏面移除除去。

c、經過pvremove命令將即將壞的磁盤或者分區從系統中刪除掉。

d、手工拆除硬盤或者經過一些工具修復分區。

[root@cnsz142728 ~]# pvs
  PV         VG         Fmt  Attr PSize  PFree 
  /dev/sda2  VolGroup00 lvm2 a--  98.97g  7.47g
  /dev/sdb1  Carlton_TT lvm2 a--  15.32g 14.83g
  /dev/sdb2  Carlton_TT lvm2 a--  15.32g 15.32g
  /dev/sdb4  Carlton_TT lvm2 a--  19.36g 19.36g
[root@cnsz142728 ~]# pvmove /dev/sdb1 /dev/sdb2
  /dev/sdb1: Moved: 0.0%
  /dev/sdb1: Moved: 100.0%
[root@cnsz142728 ~]# pvs
  PV         VG         Fmt  Attr PSize  PFree 
  /dev/sda2  VolGroup00 lvm2 a--  98.97g  7.47g
  /dev/sdb1  Carlton_TT lvm2 a--  15.32g 15.32g
  /dev/sdb2  Carlton_TT lvm2 a--  15.32g 14.83g
  /dev/sdb4  Carlton_TT lvm2 a--  19.36g 19.36g
[root@cnsz142728 ~]# vgs        
  VG         #PV #LV #SN Attr   VSize  VFree 
  Carlton_TT   3   1   0 wz--n- 49.99g 49.50g
  VolGroup00   1   7   0 wz--n- 98.97g  7.47g
[root@cnsz142728 ~]# vgreduce  Carlton_TT  /dev/sdb1
  Removed "/dev/sdb1" from volume group "Carlton_TT"
[root@cnsz142728 ~]# vgs
  VG         #PV #LV #SN Attr   VSize  VFree 
  Carlton_TT   2   1   0 wz--n- 34.67g 34.18g
  VolGroup00   1   7   0 wz--n- 98.97g  7.47g

[root@cnsz142728 ~]# pvremove /dev/sdb1 
  Labels on physical volume "/dev/sdb1" successfully wiped
[root@cnsz142728 ~]# fdisk -l |grep sdb
Disk /dev/sdb: 53.7 GB, 53687091200 bytes
/dev/sdb1               1        2000    16064968+  83  Linux
/dev/sdb2            2001        4000    16065000   83  Linux
/dev/sdb4            4001        6527    20298127+  83  Linux
[root@cnsz142728 ~]# pvs
  PV         VG         Fmt  Attr PSize  PFree 
  /dev/sda2  VolGroup00 lvm2 a--  98.97g  7.47g
  /dev/sdb2  Carlton_TT lvm2 a--  15.32g 14.83g
  /dev/sdb4  Carlton_TT lvm2 a--  19.36g 19.36g

4.5 刪除整個邏輯卷 

a、先經過umount命令卸載掉邏輯卷test

b、修改/etc/fstab裏面邏輯卷的掛載信息,不然系統有可能啓動不起來。

c、經過lvremove 刪除邏輯卷test

d、經過vgremove 刪除卷組Carlton_TT

e、經過pvremove 將物理卷轉化成普通分區。

相關文章
相關標籤/搜索