038-LVM配置过程详解
038-LVM配置过程详解
侠客行之石头 发表于3个月前
038-LVM配置过程详解
  • 发表于 3个月前
  • 阅读 30
  • 收藏 1
  • 点赞 0
  • 评论 0

腾讯云 技术升级10大核心产品年终让利>>>   

1. 理解LVM概念

 

LVM:logical Volume Manager 逻辑卷管理器

VG:Volume Group  卷组,是单个或多个物理卷的集合

PV:physical volume 物理卷,物理卷是LVM的逻辑存储块,物理卷是磁盘分区的逻辑对应关系,LVM提供的命令可以使物理磁盘进行物理卷的分区,之后多个物理卷形成卷组

LV:Logical Volume 逻辑卷,就是LVM逻辑上的分区,我们可以指定从卷组中提取多少容量来创建逻辑卷,最后对逻辑卷格式化并挂载使用

PE:physical Extent,物理长度是将物理卷组合成为卷组后,所划分的最小存储单位,即逻辑意义上磁盘的最小存储单元,LVM默认PE大小为4MB

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

之前一小节理解了概念,那么如何理论加实践?pvcreate将分区转换为物理卷的命令。vgcreate是将物理卷整合成卷组,lvcreate是将卷组中提取的容量创建逻辑卷 ,创建完成之后用pvdisplay,vgdisplay,lvdisplay 可以查看状态。

pvcreate: pvcreate /dev/sda 

vgcreate:vgcreate VGgroup00 /dev/sda1 /dev/sda2

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

lvcreate: lvcreate -L 1G -n test-lv test-vg   #创建容量为1G的逻辑卷

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 将物理卷转化成普通分区。

共有 人打赏支持
粉丝 5
博文 84
码字总数 25675
×
侠客行之石头
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
* 金额(元)
¥1 ¥5 ¥10 ¥20 其他金额
打赏人
留言
* 支付类型
微信扫码支付
打赏金额:
已支付成功
打赏金额: