温馨提示×

centos mount远程目录咋弄

小樊
48
2026-09-18 05:40:24
栏目: 智能运维

在 CentOS 上 mount 远程目录,常见有几种方式,最常用的是 NFSSSHFS,下面分别说。


一、使用 NFS(推荐,性能好,适合内网)

1️⃣ 服务端(远程机器)

# 安装
yum install -y nfs-utils

# 启动服务
systemctl enable --now nfs-server

# 创建共享目录
mkdir -p /data/share

# 配置共享
vi /etc/exports

加入:

/data/share 192.168.1.0/24(rw,sync,no_root_squash)
# 生效
exportfs -r

2️⃣ 客户端(CentOS 本地)

yum install -y nfs-utils
mkdir -p /mnt/remote

mount -t nfs 192.168.1.100:/data/share /mnt/remote

✅ 测试:

df -h
ls /mnt/remote

开机自动挂载:

vi /etc/fstab
192.168.1.100:/data/share /mnt/remote nfs defaults 0 0

二、使用 SSHFS(最简单,不用配服务)

适合 临时挂载 / 跨公网

yum install -y epel-release
yum install -y sshfs
mkdir -p /mnt/sshremote

sshfs user@remote_ip:/remote/path /mnt/sshremote

卸载:

fusermount -u /mnt/sshremote

三、使用 SMB/CIFS(Windows 共享)

yum install -y cifs-utils

mount -t cifs //192.168.1.100/share /mnt/smb \
-o username=xxx,password=xxx

四、常见问题

  • No route to host → 防火墙 / 网络问题
  • ❌ NFS 挂载卡住 → 检查 nfs-server 是否启动
  • ✅ 推荐内网用 NFS,公网用 SSHFS

如果你告诉我:

  • 远程系统是 CentOS / Ubuntu / Windows
  • 是否 内网
  • 是否要 开机自动挂载

我可以直接给你一套完整命令。

0