大网数据广告活动
服务器运维问答

Cannot remove LVM snapshot

· 52CE 我爱测

I am running Debian 11, using LVM. The root partition is /dev/mainvg/lvroot. I created a snapshot of the root partition by doing lvcreate -L5G -n bkp_lvroot -s /dev/mainvg/lvroot . My system was in this state for a few days. Now …

问题原文

原帖链接 · archygriswald · CC BY-SA 4.0

I am running Debian 11, using LVM.
The root partition is /dev/mainvg/lvroot.
I created a snapshot of the root partition by doing lvcreate -L5G -n bkp_lvroot -s /dev/mainvg/lvroot.

My system was in this state for a few days.

Now I wanted to remove the snapshot, like so:

lvremove /dev/mainvg/bkp_lvroot
  Logical volume mainvg/bkp_lvroot in use.

Looks like the snapshot is in 'active' state, so I tried to deactivate it:

lvchange -an -v  /dev/mainvg/bkp_lvroot
Change of snapshot mainvg/bkp_lvroot will also change its origin mainvg/lvroot. Proceed? [y/n]: n
  Accepted input: [n]
  Logical volume mainvg/bkp_lvroot not changed.

I cannot set the root partition to deactivated, can I???

Also: The snapshot is not mounted,
and lsof | grep /dev/mainvg/bkp_lvroot brings no results

My actual question is: How can I safely remove the snapshot? (I don't know how, and I don't want to break my system)

已采纳解答

原帖链接 · archygriswald · CC BY-SA 4.0

I already checked if the snapshot is mounted, and if there is still some open files. Turns out there is another way to check to see if something has a "hold" on the snapshot:
Use the major and minor disk number with lsof

user:/$ sudo dmsetup info -c | grep bkp_lvroot
mainvg-bkp_lvroot     254   3 L--w    1    1      0 LVM-BYqsUKtfOGMnR2
mainvg-bkp_lvroot-cow 254   2 L--w    1    1      0 LVM-BYqsUKtfOGMnR2-cow

user:/$ sudo lsof | grep "254,3"
grub-moun 430214  root    3r      BLK   254,3 0t37847040    250 /dev/dm-3

user:/$ sudo lsof | grep "254,2"
user:/$

Solution to my problem: grub-mount still accesses the snapshot

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2023-02-06)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。