SEO
结束占用磁盘设备的进程
结束读取磁盘无法umount的进程
背景
在Ubuntu上完全卸载snap后一直残留一个loop device无法移除
# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop34 7:34 0 105.8M 1 loop
# udisksctl loop-delete -b /dev/loop34
Error deleting loop device /dev/loop34: GDBus.Error:org.gtk.GDBus.UnmappedGError.Quark._g_2dbd_2dloop_2derror_2dquark.Code1: Error deleting /dev/loop34: Failed to detach the backing file from the /dev/loop34 device: No such device or address
使用losetup -l
显示背后的文件已经删除,且设备为只读状态
# losetup -l
NAME SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE DIO LOG-SEC
/dev/loop34 0 0 1 1 /var/lib/snapd/snaps/core_16202.snap (deleted) 0 512
使用lsof
查看占用却无法kill -9
# ps aux | grep loop34
root 18578 0.0 0.0 0 0 ? SN 2023 0:31 [loop34]
root 24300 0.0 0.0 17904 1052 pts/0 S+ 14:14 0:00 grep --color=auto loop34
# kill -9 18578
希望删除这个loop device并解除占用
解决
尝试了一系列方法,最后使用fuser
解决
# fuser -km /dev/loop34
/dev/loop34: 16924e
再运行lsblk
已经看不到占用了
参考
linux - Can't unmount a loop backed file but there's no open files? - Server Fault
标签:loop34,占用,dev,fuser,device,loop From: https://www.cnblogs.com/azureology/p/17969995