RHCE:LVM创建,扩容,缩小,删除

LVM定义:
考试内容:创建和扩展LVM   (xfs,ext4)


创建流程:
1>物理卷:PV
最小单位:PE,是PV上最小的块
#pvcreate #将实体partition建立成PV
#pvscan
#pvdisplay
#pvremote
#pvmove #缩小




2>卷组:VG
#vgcreate -s 16m|g|t #指定PE块的大小
#vgscan
#vgdisplay
#vgs


3>逻辑卷:LV
#lvcreate -L
#lvcreate -l 


4>格式化文件系统




创建PV:
新创建一个分区,修改分区类型为LVM类型:
[root@foundation0 ~]# fdisk /dev/sdb
修改分区类型为LVM类型:
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'


Command (m for help): p


Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000a61c0


   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048      616447      307200   8e  Linux LVM
/dev/sdb2          616448     1435647      409600   8e  Linux LVM
/dev/sdb3         1435648     2459647      512000   8e  Linux LVM
Command (m for help): w
The partition table has been altered!


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


加载到系统内核:
[root@foundation0 ~]# partprobe
[root@foundation0 ~]# ll /dev/sdb
sdb   sdb1  sdb2  sdb3  sdb4  sdb5  


批量创建PV,将分区打到PV的标签:
[root@foundation0 ~]# pvcreate /dev/sdb{1,2,3,5}
WARNING: xfs signature detected on /dev/sdb1 at offset 0. Wipe it? [y/n] y
  Wiping xfs signature on /dev/sdb1.
  Physical volume "/dev/sdb1" successfully created
  Physical volume "/dev/sdb2" successfully created
  Physical volume "/dev/sdb3" successfully created
  Physical volume "/dev/sdb5" successfully created


查看创建的PV:
[root@foundation0 ~]# pvscan 
  PV /dev/sdb1                      lvm2 [300.00 MiB]
  PV /dev/sdb3                      lvm2 [500.00 MiB]
  PV /dev/sdb2                      lvm2 [400.00 MiB]
  PV /dev/sdb5                      lvm2 [500.00 MiB]
  Total: 4 [1.66 GiB] / in use: 0 [0   ] / in no VG: 4 [1.66 GiB]


现在的PV不属于任何VG:,VG栏目为空
[root@foundation0 ~]# pvs
  PV         VG   Fmt  Attr PSize   PFree  
  /dev/sdb1       lvm2 a--  300.00m 300.00m
  /dev/sdb2       lvm2 a--  400.00m 400.00m
  /dev/sdb3       lvm2 a--  500.00m 500.00m
  /dev/sdb5       lvm2 a--  500.00m 500.00m


显示所有PV的详细信息:
[root@foundation0 ~]# pvdisplay 
  "/dev/sdb1" is a new physical volume of "300.00 MiB"
  --- NEW Physical volume ---
  PV Name               /dev/sdb1
  VG Name               
  PV Size               300.00 MiB
  Allocatable           NO
  PE Size               0   
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               7b1Dml-krjm-XRrI-z0sT-hKHz-t17t-BtoIXY
   
  "/dev/sdb3" is a new physical volume of "500.00 MiB"
  --- NEW Physical volume ---
  PV Name               /dev/sdb3
  VG Name               
  PV Size               500.00 MiB
  Allocatable           NO
  PE Size               0   
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               yAQ0Ri-sqRD-reSf-sd0M-BjLL-vDfF-cOrk5a
   
  "/dev/sdb2" is a new physical volume of "400.00 MiB"
  --- NEW Physical volume ---
  PV Name               /dev/sdb2
  VG Name               
  PV Size               400.00 MiB
  Allocatable           NO
  PE Size               0   
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               UmShT1-VVkL-Yi31-ik61-Au4p-ggN7-de8ZKy
   
  "/dev/sdb5" is a new physical volume of "500.00 MiB"
  --- NEW Physical volume ---
  PV Name               /dev/sdb5
  VG Name               
  PV Size               500.00 MiB
  Allocatable           NO
  PE Size               0   
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               5HtMt9-ahgr-AOAG-ud2H-rM6k-I66x-6MV5VE






创建VG,创建VG后才会生成PE块
[root@foundation0 ~]# vgcreate vgsdb  /dev/sdb{1,2,3,5}
  Volume group "vgsdb" successfully created
[root@foundation0 ~]# pvdisplay /dev/sdb1 #现在生成了PE
  --- Physical volume ---
  PV Name               /dev/sdb1
  VG Name               vgsdb #pv 现在属于vgsdb组
  PV Size               300.00 MiB / not usable 4.00 MiB
  Allocatable           yes 
  PE Size               4.00 MiB #创建VG后生成了PE块的大小,这个可以通过参数指定块的大小
  Total PE              74
  Free PE               74
  Allocated PE          0
  PV UUID               7b1Dml-krjm-XRrI-z0sT-hKHz-t17t-BtoIXY


查看系统上的VG组以及组名
[root@foundation0 ~]# vgscan 
  Reading all physical volumes.  This may take a while...
  Found volume group "vgsdb" using metadata type lvm2




查看VG详细的信息:
[root@foundation0 ~]# vgdisplay
  --- Volume group ---
  VG Name               vgsdb
  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               1.64 GiB
  PE Size               4.00 MiB
  Total PE              421
  Alloc PE / Size       0 / 0   
  Free  PE / Size       421 / 1.64 GiB
  VG UUID               x3RmVx-7hL4-WJJz-kV9u-BCUR-F3pW-UCAO0H


查看VG与PV的对应关系:
[root@foundation0 ~]# vgs
  VG    #PV #LV #SN Attr   VSize VFree
  vgsdb   4   0   0 wz--n- 1.64g 1.64g




查看PV与VG的对应关系:
[root@foundation0 ~]# pvs
  PV         VG    Fmt  Attr PSize   PFree  
  /dev/sdb1  vgsdb lvm2 a--  296.00m 296.00m
  /dev/sdb2  vgsdb lvm2 a--  396.00m 396.00m
  /dev/sdb3  vgsdb lvm2 a--  496.00m 496.00m
  /dev/sdb5  vgsdb lvm2 a--  496.00m 496.00m






创建LV
[root@foundation0 ~]# lvcreate -L 350M -n LVM01  vgsdb 
  Rounding up size to full physical extent 352.00 MiB
  Logical volume "LVM01" created
[root@foundation0 ~]# lvs
  LV    VG    Attr       LSize   Pool Origin Data%  Move Log Cpy%Sync Convert
  LVM01 vgsdb -wi-a----- 352.00m  


在lv上创建文件系统:
[root@foundation0 ~]# mkfs.xfs /dev/mapper/vgsdb-LVM01 
meta-data=/dev/mapper/vgsdb-LVM01 isize=256    agcount=4, agsize=22528 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0
data     =                       bsize=4096   blocks=90112, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal log           bsize=4096   blocks=853, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0


[root@foundation0 ~]# mkdir /mnt/lvm
[root@foundation0 ~]# mount /dev/mapper/vgsdb-LVM01 /mnt/lvm
[root@foundation0 ~]# cd /mnt/lvm/
[root@foundation0 lvm]# ls






扩展LVM
 
查看VG的空间:
[root@foundation0 mapper]# vgs
  VG    #PV #LV #SN Attr   VSize VFree
  vgsdb   4   1   0 wz--n- 1.64g 1.30g


[root@foundation0 mapper]# vgdisplay 
  --- Volume group ---
  VG Name               vgsdb
  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               1
  Max PV                0
  Cur PV                4
  Act PV                4
  VG Size               1.64 GiB
  PE Size               4.00 MiB
  Total PE              421
  Alloc PE / Size       88 / 352.00 MiB
  Free  PE / Size       333 / 1.30 GiB
  VG UUID               x3RmVx-7hL4-WJJz-kV9u-BCUR-F3pW-UCAO0H


创建新分区:
Command (m for help): n
All primary partitions are in use
Adding logical partition 6
First sector (3487744-41943039, default 3487744): 
Using default value 3487744
Last sector, +sectors or +size{K,M,G} (3487744-41943039, default 41943039): +500M
Partition 6 of type Linux and of size 500 MiB is set


Command (m for help): t
Partition number (1-6, default 6): 
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'


Command (m for help): p


Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000a61c0


   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048      616447      307200   8e  Linux LVM
/dev/sdb2          616448     1435647      409600   8e  Linux LVM
/dev/sdb3         1435648     2459647      512000   8e  Linux LVM
/dev/sdb4         2459648    41943039    19741696    5  Extended
/dev/sdb5         2461696     3485695      512000   8e  Linux LVM
/dev/sdb6         3487744     4511743      512000   8e  Linux LVM


创建PV
[root@foundation0 mapper]# pvcreate /dev/sdb6
  Physical volume "/dev/sdb6" successfully created


扩展VG:
[root@foundation0 mapper]# vgextend vgsdb /dev/sdb6
  Volume group "vgsdb" successfully extended




[root@foundation0 mapper]# vgdisplay 
  --- Volume group ---
  VG Name               vgsdb
  System ID             
  Format                lvm2
  Metadata Areas        5
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                5
  Act PV                5
  VG Size               2.13 GiB
  PE Size               4.00 MiB
  Total PE              545
  Alloc PE / Size       88 / 352.00 MiB
  Free  PE / Size       457 / 1.79 GiB
  VG UUID               x3RmVx-7hL4-WJJz-kV9u-BCUR-F3pW-UCAO0H


扩展LV
[root@foundation0 mapper]# lvs
  LV    VG    Attr       LSize   Pool Origin Data%  Move Log Cpy%Sync Convert
  LVM01 vgsdb -wi-ao---- 352.00m   
      
调整lv的大小,可以扩大,也可以缩小,但缩小的值不能超过数据占用的最大值                                    
[root@foundation0 mapper]# lvextend -L 800M /dev/vgsdb/LVM01 
  Extending logical volume LVM01 to 800.00 MiB
  Logical volume LVM01 successfully resized




扩展文件系统:
[root@foundation0 mapper]# df -Th
Filesystem              Type      Size  Used Avail Use% Mounted on
/dev/sda1               xfs       118G   14G  104G  12% /
devtmpfs                devtmpfs  909M     0  909M   0% /dev
tmpfs                   tmpfs     918M  8.0K  918M   1% /dev/shm
tmpfs                   tmpfs     918M  8.6M  909M   1% /run
tmpfs                   tmpfs     918M     0  918M   0% /sys/fs/cgroup
/dev/loop0              iso9660   3.5G  3.5G     0 100% /content/rhel7.0/x86_64/dvd
/dev/loop1              xfs       509M   26M  483M   6% /run/media/root/0ea2b5d5-4f68-4abe-ae81-ea9a0175a730
/dev/mapper/vgsdb-LVM01 xfs       349M   18M  331M   6% /mnt/lvm




xfs文件系统扩展:
xfs文件系统的调整命令是xfs_growfs(只支持增大)


lvextend -L 120G /dev/mapper/centos-home    //增大至120G
lvextend -L +20G /dev/mapper/centos-home    //增加20G
xfs_growfs /dev/mapper/centos-home          //执行调整


[root@foundation0 mapper]# xfs_growfs /mnt/lvm/
meta-data=/dev/mapper/vgsdb-LVM01 isize=256    agcount=4, agsize=22528 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0
data     =                       bsize=4096   blocks=90112, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal               bsize=4096   blocks=853, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 90112 to 204800
[root@foundation0 mapper]# df -Th
Filesystem              Type      Size  Used Avail Use% Mounted on
/dev/sda1               xfs       118G   14G  104G  12% /
devtmpfs                devtmpfs  909M     0  909M   0% /dev
tmpfs                   tmpfs     918M  8.0K  918M   1% /dev/shm
tmpfs                   tmpfs     918M  8.6M  909M   1% /run
tmpfs                   tmpfs     918M     0  918M   0% /sys/fs/cgroup
/dev/loop0              iso9660   3.5G  3.5G     0 100% /content/rhel7.0/x86_64/dvd
/dev/loop1              xfs       509M   26M  483M   6% /run/media/root/0ea2b5d5-4f68-4abe-ae81-ea9a0175a730
/dev/mapper/vgsdb-LVM01 xfs       797M   18M  779M   3% /mnt/lvm




ext4文件系统扩展:


ext2/ext3/ext4文件系统的调整命令是resize2fs(增大和减小都支持)


lvextend -L 120G /dev/mapper/centos-home     //增大至120G
lvextend -L +20G /dev/mapper/centos-home     //增加20G
lvreduce -L 50G /dev/mapper/centos-home      //减小至50G
lvreduce -L -8G /dev/mapper/centos-home      //减小8G
resize2fs /dev/mapper/centos-home            //执行调整


创建PV:
创建PV分区
Command (m for help): t
Partition number (1-7, default 7): 
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'


Command (m for help): n
All primary partitions are in use
Adding logical partition 8
First sector (5539840-41943039, default 5539840): 
Using default value 5539840
Last sector, +sectors or +size{K,M,G} (5539840-41943039, default 41943039): +1G
Partition 8 of type Linux and of size 1 GiB is set


Command (m for help): t
Partition number (1-8, default 8): 8e
Partition number (1-8, default 8): 
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'


Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000a61c0


   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048      616447      307200   8e  Linux LVM
/dev/sdb2          616448     1435647      409600   8e  Linux LVM
/dev/sdb3         1435648     2459647      512000   8e  Linux LVM
/dev/sdb4         2459648    41943039    19741696    5  Extended
/dev/sdb5         2461696     3485695      512000   8e  Linux LVM
/dev/sdb6         3487744     4511743      512000   8e  Linux LVM
/dev/sdb7         4513792     5537791      512000   8e  Linux LVM
/dev/sdb8         5539840     7636991     1048576   8e  Linux LVM


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


Calling ioctl() to re-read partition table.


WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.






[root@foundation0 ~]# pvcreate /dev/sdb{7,8}
  Physical volume "/dev/sdb7" successfully created
  Physical volume "/dev/sdb8" successfully created






 
[root@foundation0 ~]# vgcreate lvm2 /dev/sdb{7,8}
  Volume group "lvm2" successfully created
[root@foundation0 ~]# lvcreate -L 350M -n exam lvm2 
  Rounding up size to full physical extent 352.00 MiB
  Logical volume "exam" created




[root@foundation0 ~]# lvs
  LV    VG    Attr       LSize   Pool Origin Data%  Move Log Cpy%Sync Convert
  exam  lvm2  -wi-a----- 352.00m                                             
  LVM01 vgsdb -wi-ao---- 800.00m


[root@foundation0 ~]# mkfs.ext4 /dev/mapper/lvm2-exam 
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
90112 inodes, 360448 blocks
18022 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=33947648
44 block groups
8192 blocks per group, 8192 fragments per group
2048 inodes per group
Superblock backups stored on blocks: 
8193, 24577, 40961, 57345, 73729, 204801, 221185


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


[root@foundation0 ~]# mkdir /mnt/lvm2
[root@foundation0 ~]# mount /dev/mapper/lvm2-exam /mnt/lvm2/
 
[root@foundation0 vgsdb]# df -Th
Filesystem              Type      Size  Used Avail Use% Mounted on
/dev/sda1               xfs       118G   14G  104G  12% /
devtmpfs                devtmpfs  909M     0  909M   0% /dev
tmpfs                   tmpfs     918M  8.0K  918M   1% /dev/shm
tmpfs                   tmpfs     918M  8.7M  909M   1% /run
tmpfs                   tmpfs     918M     0  918M   0% /sys/fs/cgroup
/dev/loop0              iso9660   3.5G  3.5G     0 100% /content/rhel7.0/x86_64/dvd
/dev/loop1              xfs       509M   26M  483M   6% /run/media/root/0ea2b5d5-4f68-4abe-ae81-ea9a0175a730
/dev/mapper/vgsdb-LVM01 xfs       797M   18M  779M   3% /mnt/lvm
/dev/mapper/lvm2-exam   ext4      333M  2.1M  310M   1% /mnt/lvm2






缩小lvm
 xfs不支持:
 
ext2/ext3/ext4文件系统的调整命令是resize2fs(增大和减小都支持)


lvextend -L 120G /dev/mapper/centos-home     //增大至120G
lvextend -L +20G /dev/mapper/centos-home     //增加20G
lvreduce -L 50G /dev/mapper/centos-home      //减小至50G
lvreduce -L -8G /dev/mapper/centos-home      //减小8G
resize2fs /dev/mapper/centos-home            //执行调整




[root@foundation0 vgsdb]# lvs
  LV    VG    Attr       LSize   Pool Origin Data%  Move Log Cpy%Sync Convert
  exam  lvm2  -wi-a----- 352.00m                                             
  LVM01 vgsdb -wi-ao---- 800.00m  


[root@foundation0 ~]# e2fsck -f /dev/mapper/lvm2-exam 
e2fsck 1.42.9 (28-Dec-2013)
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/lvm2-exam: 11/90112 files (0.0% non-contiguous), 21639/360448 blocks
缩小文件系统:
[root@foundation0 ~]# resize2fs /dev/mapper/lvm2-exam  200M
resize2fs 1.42.9 (28-Dec-2013)
Resizing the filesystem on /dev/mapper/lvm2-exam to 204800 (1k) blocks.
The filesystem on /dev/mapper/lvm2-exam is now 204800 blocks long.
缩小LV 
缩小至200M
[root@foundation0 ~]# lvreduce -L 200M /dev/mapper/lvm2-exam 
  WARNING: Reducing active logical volume to 200.00 MiB
  THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce exam? [y/n]: y
  Reducing logical volume exam to 200.00 MiB
  Logical volume exam successfully resized




[root@foundation0 ~]# lvs
  LV    VG    Attr       LSize   Pool Origin Data%  Move Log Cpy%Sync Convert
  exam  lvm2  -wi-a----- 200.00m                                             
  LVM01 vgsdb -wi-ao---- 800.00m 


[root@foundation0 ~]# vgs
  VG    #PV #LV #SN Attr   VSize VFree
  lvm2    2   1   0 wz--n- 1.48g 1.29g
  vgsdb   5   1   0 wz--n- 2.13g 1.35g


[root@foundation0 ~]# vgremove exam  /dev/sdb7
[root@foundation0 ~]# pvmove /dev/sdb7
  /dev/sdb7: Moved: 6.0%
  /dev/sdb7: Moved: 100.0%


[root@foundation0 ~]# pvs
  PV         VG    Fmt  Attr PSize    PFree  
  /dev/sdb1  vgsdb lvm2 a--   296.00m 296.00m
  /dev/sdb2  vgsdb lvm2 a--   396.00m      0 
  /dev/sdb3  vgsdb lvm2 a--   496.00m  92.00m
  /dev/sdb5  vgsdb lvm2 a--   496.00m 496.00m
  /dev/sdb6  vgsdb lvm2 a--   496.00m 496.00m
  /dev/sdb7  lvm2  lvm2 a--   496.00m 496.00m #上面已没有数据了
  /dev/sdb8  lvm2  lvm2 a--  1020.00m 820.00m


[root@foundation0 ~]# vgreduce lvm2 /dev/sdb7
  Removed "/dev/sdb7" from volume group "lvm2"


[root@foundation0 ~]# pvremove /dev/sdb7
  Labels on physical volume "/dev/sdb7" successfully wiped




删除LVM
卸载文件系统:
 umount /mnt/sdc1
 umount /mnt/sdc3


1.删除LV
[root@foundation0 mapper]# lvremove --help
  lvremove: Remove logical volume(s) from the system


lvremove
[-A|--autobackup y|n]
[-d|--debug]
[-f|--force]
[-h|--help]
[--noudevsync]
[-t|--test]
[-v|--verbose]
[--version]
LogicalVolume[Path] [LogicalVolume[Path]...]


[root@foundation0 mapper]# lvs
  LV      VG      Attr       LSize Pool Origin Data%  Move Log Cpy%Sync Convert
  lvmsdc1 sdc1vg1 -wi-a----- 2.99g                                             
  lvol0   sdc3vg1 -wi-a----- 2.00g  


[root@foundation0 mapper]# lvremove /dev/mapper/sdc1vg1 
Do you really want to remove active logical volume lvmsdc1? [y/n]: y
  Logical volume "lvmsdc1" successfully removed
[root@foundation0 mapper]# lvremove /dev/mapper/sdc3vg1
Do you really want to remove active logical volume lvol0? [y/n]: y
  Logical volume "lvol0" successfully removed




删除VG:
[root@foundation0 mapper]# vgremove --help
  vgremove: Remove volume group(s)


vgremove
[-d|--debug]
[-f|--force]
[-h|--help]
[--noudevsync]
[-t|--test]
[-v|--verbose]
[--version]
VolumeGroupName [VolumeGroupName...]
[root@foundation0 mapper]# vgs
  VG      #PV #LV #SN Attr   VSize VFree
  sdc1vg1   2   0   0 wz--n- 2.99g 2.99g
  sdc3vg1   1   0   0 wz--n- 3.00g 3.00g


[root@foundation0 mapper]# vgremove sdc1vg1
  Volume group "sdc1vg1" successfully removed
[root@foundation0 mapper]# vgremove sdc3vg1
  Volume group "sdc3vg1" successfully removed
[root@foundation0 mapper]# vgs
  No volume groups found




删除PV
[root@foundation0 mapper]# pvremove --help
  pvremove: Remove LVM label(s) from physical volume(s)


pvremove 
[-d|--debug]
[-f[f]|--force [--force]] 
[-h|-?|--help] 
[-t|--test] 
[-v|--verbose] 
[--version] 
[-y|--yes]
PhysicalVolume [PhysicalVolume...]




[root@foundation0 mapper]# pvs
  PV         VG   Fmt  Attr PSize PFree
  /dev/sdc1       lvm2 a--  1.00g 1.00g
  /dev/sdc2       lvm2 a--  2.00g 2.00g
  /dev/sdc3       lvm2 a--  3.00g 3.00g


[root@foundation0 mapper]# pvremove /dev/sdc1
  Labels on physical volume "/dev/sdc1" successfully wiped
[root@foundation0 mapper]# pvremove /dev/sdc2
  Labels on physical volume "/dev/sdc2" successfully wiped
[root@foundation0 mapper]# pvremove /dev/sdc3
  Labels on physical volume "/dev/sdc3" successfully wiped


[root@foundation0 mapper]# pvs
[root@foundation0 mapper]# lvs
  No volume groups found
[root@foundation0 mapper]# vgs
  No volume groups found


删除分区:
Disk /dev/sdc: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xbee7cf6f


   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1            2048     2099199     1048576   8e  Linux LVM
/dev/sdc2         2099200     6293503     2097152   8e  Linux LVM
/dev/sdc3         6293504    12584959     3145728   8e  Linux LVM


Command (m for help): d
Partition number (1-3, default 3): 1
Partition 1 is deleted


Command (m for help): d
Partition number (2,3, default 3): 2
Partition 2 is deleted


Command (m for help): d
Selected partition 3
Partition 3 is deleted


这样服务器上所有的LVM相关的组件全部卸载完成
分割线
感谢打赏
江西数库信息技术有限公司
YWSOS.COM 平台代运维解决方案
 评论
 发表评论
姓   名:

Powered by AKCMS