linux系统中完整删除逻辑卷、卷组、物理劵

 

  • 删除逻辑卷前备份数据
  • 逻辑卷删除顺序为逻辑卷、卷组、物理劵,不可颠倒

1、查看系统中当前的逻辑卷

[root@PC1linuxprobe /]# lvscan 
  ACTIVE            '/dev/rhel/swap' [2.00 GiB] inherit
  ACTIVE            '/dev/rhel/root' [17.51 GiB] inherit
  ACTIVE            '/dev/vg1/lv1' [100.00 MiB] inherit
  ACTIVE            '/dev/vg1/lv2' [300.00 MiB] inherit

 

2、查看逻辑卷挂载情况

复制代码
[root@PC1linuxprobe /]# df -h
Filesystem             Size  Used Avail Use% Mounted on
/dev/mapper/rhel-root   18G  2.9G   15G  17% /
devtmpfs               985M     0  985M   0% /dev
tmpfs                  994M  140K  994M   1% /dev/shm
tmpfs                  994M  8.8M  986M   1% /run
tmpfs                  994M     0  994M   0% /sys/fs/cgroup
/dev/sda1              497M  119M  379M  24% /boot
/dev/sr0               3.5G  3.5G     0 100% /run/media/root/RHEL-7.0 Server.x86_64
/dev/mapper/vg1-lv2    283M  2.1M  262M   1% /lvmounttest
复制代码

 

3、卸载逻辑卷

[root@PC1linuxprobe /]# umount /lvmounttest

 

4、删除逻辑卷

复制代码
[root@PC1linuxprobe /]# lvscan 
  ACTIVE            '/dev/rhel/swap' [2.00 GiB] inherit
  ACTIVE            '/dev/rhel/root' [17.51 GiB] inherit
  ACTIVE            '/dev/vg1/lv1' [100.00 MiB] inherit
  ACTIVE            '/dev/vg1/lv2' [300.00 MiB] inherit
[root@PC1linuxprobe /]# lvremove /dev/vg1/lv1
Do you really want to remove active logical volume lv1? [y/n]: y
  Logical volume "lv1" successfully removed
[root@PC1linuxprobe /]# lvremove /dev/vg1/lv2
Do you really want to remove active logical volume lv2? [y/n]: y
  Logical volume "lv2" successfully removed
[root@PC1linuxprobe /]# lvscan 
  ACTIVE            '/dev/rhel/swap' [2.00 GiB] inherit
  ACTIVE            '/dev/rhel/root' [17.51 GiB] inherit
复制代码

 

5、删除卷组

复制代码
[root@PC1linuxprobe /]# vgscan 
  Reading all physical volumes.  This may take a while...
  Found volume group "rhel" using metadata type lvm2
  Found volume group "vg1" using metadata type lvm2
[root@PC1linuxprobe /]# vgremove vg1 
  Volume group "vg1" successfully removed
[root@PC1linuxprobe /]# vgscan 
  Reading all physical volumes.  This may take a while...
  Found volume group "rhel" using metadata type lvm2
复制代码

 

6、删除物理劵

复制代码
[root@PC1linuxprobe /]# pvscan 
  PV /dev/sda2   VG rhel            lvm2 [19.51 GiB / 0    free]
  PV /dev/sdb                       lvm2 [20.00 GiB]
  PV /dev/sdc                       lvm2 [20.00 GiB]
  PV /dev/sdd                       lvm2 [20.00 GiB]
  Total: 4 [79.51 GiB] / in use: 1 [19.51 GiB] / in no VG: 3 [60.00 GiB]
[root@PC1linuxprobe /]# pvremove /dev/sdb /dev/sdc /dev/sdd
  Labels on physical volume "/dev/sdb" successfully wiped
  Labels on physical volume "/dev/sdc" successfully wiped
  Labels on physical volume "/dev/sdd" successfully wiped
[root@PC1linuxprobe /]# pvscan 
  PV /dev/sda2   VG rhel   lvm2 [19.51 GiB / 0    free]
  Total: 1 [19.51 GiB] / in use: 1 [19.51 GiB] / in no VG: 0 [0   ]
复制代码

 

总结,完整删除逻辑卷步骤:

  • 卸载,示例:umount /mountpoint
  • 删除逻辑卷,示例:lvremove /dev/vgname/lvname
  • 删除卷组,示例:vgremove vgname
  • 删除物理劵,示例:pvremove /dev/disk*

 注:

  • 逻辑卷部署顺序:物理劵→卷组→逻辑卷
  • 逻辑卷删除顺序:逻辑卷→卷组→物理劵
posted @   小鲨鱼2018  阅读(2565)  评论(0编辑  收藏  举报
编辑推荐:
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
点击右上角即可分享
微信分享提示