Linux 如何停用 LVM2 物理卷以移除驱动器?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18042216/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to deactivate a LVM2 physical volume to remove the drive?
提问by user2650268
How can I shut down/"unmount" a Linux lvm2 physical volume?
如何关闭/“卸载”Linux lvm2 物理卷?
I plugged an external had drive to my computer. On the drive is a LVM2 PV with one volume group which has some logical volumes. I now want to remove this drive again properly.
我在我的电脑上插入了一个外部驱动器。驱动器上是一个 LVM2 PV,带有一个包含一些逻辑卷的卷组。我现在想再次正确删除此驱动器。
I unmounted the filesystems, deactivated all logical volumes and the volume group.
我卸载了文件系统,停用了所有逻辑卷和卷组。
How can I deactivate the physical volume? Or make the PV and the VG unknown to Linux again? Like just the opposite of lvmdiskscan and vgchange -a y ?
如何停用物理卷?或者让 Linux 再次不知道 PV 和 VG?就像 lvmdiskscan 和 vgchange -ay 刚好相反?
I want to leave the PV/VG and LVs on the disk intact.
我想保持磁盘上的 PV/VG 和 LV 完好无损。
回答by StianE
lvchange -an <lvpath>
vgchange -an <vgname>
If you also want to remove the device maps you can use
如果您还想删除可以使用的设备地图
dmsetup ls
dmsetup remove <name>
回答by zonksoft
I do
我愿意
vgchange -an <vgpath>
vgchange -an <vgpath>
before I remove the disk and
在我移除磁盘之前
vgchange -ay <vgpath>
vgchange -ay <vgpath>
after I connected it again. Otherwise, any LVM display command will produce input/output errors, and the partition will not be mountable.
我再次连接后。否则,任何 LVM 显示命令都会产生输入/输出错误,并且该分区将无法挂载。