Linux如何在LVM中移除PV
source link: https://halfcoke.github.io/2021/2d54e946/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Linux如何在LVM中移除PV
Linux如何在LVM中移除PV
网上很多人都在讲如何直接移除PV,但是实际过程中,很有可能我们的PV还没有空闲空间,这样也就没办法直接用pvmove
指令。
我们先介绍如何将pv空闲出来。
移除PV准备工作
通过lsblk
命令我们可以看到,当前根目录的LVM
是用了两个盘的,即sda
和sdb
。我们想将sda
从LVM
中拿出来,这样sda
就可以用来做别的事情了。
使用df -hT
查看当前分区的使用情况,我们可以看到根目录只用了72G,/home
目录空闲有249G,这个时候我们可以将/home
中的一部分空间拿出来,最好空闲直接大于72G,保证能装得下。如果小于72G的时候不确定能不能装得下,这部分需要自己试一下。
我们执行一下lvdisplay
,查看一下lv的信息,下图列出了部分内容。
这个时候我们执行lvreduce -L 150G /dev/cl/home
命令,这条命令相当于将/home
路径的空间直接缩小到150G,因为我们在上面通过df -hT
看到了/home
目录只用了144G。
这样我们相当于已经有空间用来存放根目录的数据了。
接下来我们执行移除PV的相关操作
我们执行pvs -o+pv_used
,只要/dev/sda1
的used
的是0就可以了。下面这个图忘记截了,放一个之前的数据的图。
# 然后执行下面的命令,转移PV中的数据
pvmove /dev/sda1
# 然后从vg中移除pv
vgreduce {vg组名} /dev/sda1
即:vgreduce cl /dev/sda1
# 然后移除PV
pvremove /dev/sda1
至此,所有步骤完成。
[1] How to Remove Physical Volume from a Volume Group in LVM
[2] LVM : 缩减文件系统的容量
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK