删除K8S集群的/var/lib/kubelet目录报Device or resource busy错误解决方法

无法删除/var/lib/kubelet目录

[root@k8s-node2 k8s_node]# rm -rf /var/lib/kubelet
rm: cannot remove ‘/var/lib/kubelet/pods/0552a913-ea4a-4b91-84a7-87ca6d9f8611/volumes/kubernetes.io~secret/etcd-certs’: Device or resource busy
rm: cannot remove ‘/var/lib/kubelet/pods/0552a913-ea4a-4b91-84a7-87ca6d9f8611/volumes/kubernetes.io~secret/calico-node-token-7jrks’: Device or resource busy
rm: cannot remove ‘/var/lib/kubelet/pods/ea2b55a3-0891-4965-a64d-2f27b7d29bf6/volumes/kubernetes.io~secret/etcd-certs’: Device or resource busy
rm: cannot remove ‘/var/lib/kubelet/pods/ea2b55a3-0891-4965-a64d-2f27b7d29bf6/volumes/kubernetes.io~secret/calico-kube-controllers-token-sgpr9’: Device or resource busy
rm: cannot remove ‘/var/lib/kubelet/pods/cc699261-f1a5-4c8d-913f-9af943bc4117/volumes/kubernetes.io~secret/coredns-token-rnb5t’: Device or resource busy
rm: cannot remove ‘/var/lib/kubelet/pods/4533016b-95bf-4376-a3a0-57d8c2b37fc8/volumes/kubernetes.io~secret/kubernetes-dashboard-token-nzqr8’: Device or resource busy
rm: cannot remove ‘/var/lib/kubelet/pods/2b1e0ff1-23e7-412a-a1f3-a6b6d8c5c991/volumes/kubernetes.io~secret/kubernetes-dashboard-certs’: Device or resource busy
rm: cannot remove ‘/var/lib/kubelet/pods/2b1e0ff1-23e7-412a-a1f3-a6b6d8c5c991/volumes/kubernetes.io~secret/kubernetes-dashboard-token-nzqr8’: Device or resource busy

查看挂载信息

[root@k8s-node2 k8s_node]# df -HT | grep '/var/lib/kubelet/pods'
tmpfs                   tmpfs     1.5G     0  1.5G   0% /var/lib/kubelet/pods/0552a913-ea4a-4b91-84a7-87ca6d9f8611/volumes/kubernetes.io~secret/etcd-certs
tmpfs                   tmpfs     1.5G   13k  1.5G   1% /var/lib/kubelet/pods/0552a913-ea4a-4b91-84a7-87ca6d9f8611/volumes/kubernetes.io~secret/calico-node-token-7jrks
tmpfs                   tmpfs     1.5G   13k  1.5G   1% /var/lib/kubelet/pods/cc699261-f1a5-4c8d-913f-9af943bc4117/volumes/kubernetes.io~secret/coredns-token-rnb5t
tmpfs                   tmpfs     1.5G   13k  1.5G   1% /var/lib/kubelet/pods/ea2b55a3-0891-4965-a64d-2f27b7d29bf6/volumes/kubernetes.io~secret/etcd-certs
tmpfs                   tmpfs     1.5G   13k  1.5G   1% /var/lib/kubelet/pods/ea2b55a3-0891-4965-a64d-2f27b7d29bf6/volumes/kubernetes.io~secret/calico-kube-controllers-token-sgpr9
tmpfs                   tmpfs     1.5G     0  1.5G   0% /var/lib/kubelet/pods/2b1e0ff1-23e7-412a-a1f3-a6b6d8c5c991/volumes/kubernetes.io~secret/kubernetes-dashboard-certs
tmpfs                   tmpfs     1.5G   13k  1.5G   1% /var/lib/kubelet/pods/2b1e0ff1-23e7-412a-a1f3-a6b6d8c5c991/volumes/kubernetes.io~secret/kubernetes-dashboard-token-nzqr8
tmpfs                   tmpfs     1.5G   13k  1.5G   1% /var/lib/kubelet/pods/4533016b-95bf-4376-a3a0-57d8c2b37fc8/volumes/kubernetes.io~secret/kubernetes-dashboard-token-nzqr8

umount这些挂在,然后再删除

[root@k8s-node2 k8s_node]# umount $(df -HT | grep '/var/lib/kubelet/pods' | awk '{print $7}')

# 已查不到挂载信息,再次删除目录则不再报错
[root@k8s-node2 k8s_node]# df -HT | grep '/var/lib/kubelet/pods'

参与评论 您还未登录,请先 登录 后发表或查看评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
©️2022 CSDN 皮肤主题:大白 设计师:CSDN官方博客 返回首页

打赏作者

liuyuinsdu

你的鼓励将是我创作的最大动力

¥2 ¥4 ¥6 ¥10 ¥20
输入1-500的整数
余额支付 (余额:-- )
扫码支付
扫码支付:¥2
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值