在 CentOS(以及一般 Linux)里,overlay(OverlayFS)常见于两类场景:
下面按“常见错误 → 排查思路 → 解决办法”来说明。
mount | grep overlay
或
cat /proc/mounts | grep overlay
/var/lib/docker/overlay2/... → Docker overlay2mount: wrong fs type, bad option, bad superblock原因
排查
uname -r
# CentOS 7 建议 >= 3.10.0-957
确认参数格式:
mount -t overlay overlay \
-o lowerdir=/lower,upperdir=/upper,workdir=/work \
/mnt
⚠️ 注意:
workdir 必须和 upperdir 同文件系统workdir 必须为空典型日志
storage-driver overlay2 not supported
排查步骤
docker info | grep -i storage
确认:
cat /etc/docker/daemon.json
推荐配置(CentOS 7/8):
{
"storage-driver": "overlay2"
}
如果内核太老:
yum update kernel
reboot
cannot mount overlay, lowerdir does not exist原因
排查
ls -ld /lower
SELinux 检查:
getenforce
临时关闭测试:
setenforce 0
原因
验证
mount | grep overlay
ls -l /mnt
touch /mnt/test && ls -l /upper
df -h
Docker 常见:
docker system df
docker system prune -a
# 查看 overlay 挂载
mount | grep overlay
# 查看内核支持
cat /proc/filesystems | grep overlay
# 查看 Docker 存储
docker info
# 查看系统日志
journalctl -xe
dmesg | tail
# 查看 SELinux
getenforce
ausearch -m avc -ts recent
你可以把下面信息发我,我可以精准分析:
cat /etc/redhat-release)uname -r)我可以直接帮你定位到“哪一行配置错了”。