Files
nexus/wiki/concepts/NFS永久挂载.md
2026-04-16 20:05:13 +08:00

47 lines
1.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: "NFS永久挂载"
type: concept
tags: [mount, nfs, fstab]
date: 2026-04-16
---
## Definition
NFS 永久挂载是指通过配置文件实现网络文件系统NFS在系统开机时自动挂载而不是依赖手动执行 mount 命令。Linux 系统通过 /etc/fstab 文件管理所有文件系统挂载点。
## Implementation
在 /etc/fstab 中添加配置行:
```
192.168.3.17:/volume2/backup /mnt/nas_backup nfs defaults,timeo=900,retrans=5,_netdev 0 0
```
## Key Parameters
- **defaults**使用默认挂载参数rw, suid, dev, exec, auto, nouser, async
- **timeo=900**:超时时间 90 秒(单位 1/10 秒)
- **retrans=5**:超时重试次数 5 次
- **_netdev**:关键参数,指定为网络设备,等待网络服务启动后再挂载
## Why _netdev is Critical
_netdev 参数告诉系统:
1. 这是一个网络文件系统
2. 必须等到网络服务完全启动后再尝试挂载
3. 防止开机过程因网络未就绪而卡死
## Testing
```bash
# 卸载当前挂载
sudo umount /mnt/nas_backup
# 模拟开机挂载
sudo mount -a
# 验证挂载
df -h | grep nas_backup
```
## Common Issues
- **挂载失效**nfs-common 服务启动慢于 mount -a 执行
- **解决**:启用 remote-fs.target 服务:`sudo systemctl enable remote-fs.target`
## Related Entities
- [[NFS]]:网络文件系统协议
- [[NAS]]:网络附加存储设备