在 Linux 中,“mount 缓存”一般指几类不同层面的缓存,清除方式也不同。下面按常见场景说明。
这是最常见的“缓存”,由内核统一管理。
free -h
# 或
cat /proc/meminfo | grep -E 'Cached|Buffers'
# 清理 pagecache
echo 1 > /proc/sys/vm/drop_caches
# 清理 dentries + inodes
echo 2 > /proc/sys/vm/drop_caches
# 全部清理
echo 3 > /proc/sys/vm/drop_caches
⚠️ 需要 root 权限:
sync && echo 3 > /proc/sys/vm/drop_caches
sync 用于先写回脏数据,避免数据丢失。
如果是 NFS mount,客户端会缓存文件属性和目录。
mount | grep nfs
actimeo=:属性缓存时间(秒)noac:禁用属性缓存lookupcache=none:禁用目录项缓存mount -o remount,noac /mnt/nfs
或修改 /etc/fstab 后:
umount /mnt/nfs
mount /mnt/nfs
mount | grep cifs
清除方式通常是重新挂载:
umount /mnt/share
mount -a
可在挂载时禁用缓存:
mount -t cifs //server/share /mnt/share -o cache=none,username=xxx
属于内核通用缓存,用前面的:
echo 2 > /proc/sys/vm/drop_caches
如果是 autofs:
systemctl restart autofs
或:
automount -k /mnt/auto
如果只是“挂载信息看起来不对”:
mount -a
# 或
systemctl daemon-reload
| 场景 | 清除方式 |
|---|---|
| 文件缓存 | echo 3 > /proc/sys/vm/drop_caches |
| NFS 缓存 | remount / noac |
| CIFS 缓存 | remount / cache=none |
| 目录缓存 | echo 2 > /proc/sys/vm/drop_caches |
| autofs | systemctl restart autofs |
如果你能说明 具体文件系统类型(ext4 / NFS / CIFS / overlay 等)和“缓存”现象(如 ls 不刷新、df 不对),我可以给更精确的方法。