Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

执行umount /root/mnt delete /root/mnt 时报错 unlinkat /root/mnt: device or resource busy #75

Open
gxin0426 opened this issue Jul 30, 2020 · 2 comments

Comments

@gxin0426
Copy link

func DeleteMountPoint(mntURl string) {
cmd := exec.Command("umount", mntURl)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if err := cmd.Run(); err != nil {
fmt.Println(err)
return
}
if err := os.RemoveAll(mntURl); err != nil {
fmt.Println(err)
return
}
}

@doc-laowu
Copy link

我也有碰到这个问题了:
if err := os.RemoveAll(mntURl); err != nil {
fmt.Println(err)
return
}是在删除的时候报的错误,但是在上面执行umount /root/mnt的时候并没有报错出问题,希望帮忙解答下,谢谢

@doc-laowu
Copy link

我的linux内核是: CentOS Linux release 7.9.2009 (Core)
我发现出现这个原因是因为,/root/mnt被当前的容器进程给挂载了多次, 所以需要在umount的时候加上-A参数,这样就能删除/root/mnt目录。不过由于我挂载的文件系统是overlay的,不是aufs的不知道跟这个 有没有关系。
修改代码如下:
cmd := exec.Command("umount", "-A", mntURL)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants