ubuntu挂载共享目录的方法

ubuntu挂载共享目录的方法

安装NFS

powershell 复制代码
sudo apt-get install nfs-kernel-server

配置NFS

复制代码
创建work共享目录:(本人将此文件放在桌面)
powershell 复制代码
sudo mkdir work
powershell 复制代码
sudo gedit /etc/exports

添加:

powershell 复制代码
/home/zynq/Desktop/work  *(rw,sync,no_root_squash,no_subtree_check)

运行以下命令:

powershell 复制代码
sudo systemctl restart rpcbind
		sudo systemctl restart nfs-kernel-server
		sudo systemctl status nfs-kernel-server

有以下提示,表示安装成功:

powershell 复制代码
● nfs-server.service - NFS server and services
   Loaded: loaded (/lib/systemd/system/nfs-server.service; enabled; vendor prese
   Active: active (exited) since Sun 2023-11-05 05:24:37 PST; 40s ago
  Process: 8212 ExecStopPost=/usr/sbin/exportfs -f (code=exited, status=0/SUCCES
  Process: 8208 ExecStopPost=/usr/sbin/exportfs -au (code=exited, status=0/SUCCE
  Process: 8206 ExecStop=/usr/sbin/rpc.nfsd 0 (code=exited, status=0/SUCCESS)
  Process: 8226 ExecStart=/usr/sbin/rpc.nfsd $RPCNFSDARGS (code=exited, status=0
  Process: 8224 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=0/SUCCES
 Main PID: 8226 (code=exited, status=0/SUCCESS)

Nov 05 05:24:37 ubuntu systemd[1]: Starting NFS server and services...
Nov 05 05:24:37 ubuntu systemd[1]: Started NFS server and services.

挂载work目录:

powershell 复制代码
sudo mount -t nfs 127.0.0.1:/home/zynq/Desktop/work /mnt

运行:

powershell 复制代码
sudo mount

结果显示:

powershell 复制代码
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
udev on /dev type devtmpfs (rw,nosuid,relatime,size=4041564k,nr_inodes=1010391,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=814468k,mode=755)
/dev/sda1 on / type ext4 (rw,relatime,errors=remount-ro,data=ordered)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
cgroup on /sys/fs/cgroup/pids type cgroup (rw,nosuid,nodev,noexec,relatime,pids)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)
cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls,net_prio)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpu,cpuacct)
cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,hugetlb)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)
cgroup on /sys/fs/cgroup/rdma type cgroup (rw,nosuid,nodev,noexec,relatime,rdma)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=25,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=1255)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime,pagesize=2M)
mqueue on /dev/mqueue type mqueue (rw,relatime)
configfs on /sys/kernel/config type configfs (rw,relatime)
fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
vmware-vmblock on /run/vmblock-fuse type fuse.vmware-vmblock (rw,relatime,user_id=0,group_id=0,default_permissions,allow_other)
tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,size=814468k,mode=700,uid=1000,gid=1000)
gvfsd-fuse on /run/user/1000/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,relatime,user_id=1000,group_id=1000)
sunrpc on /run/rpc_pipefs type rpc_pipefs (rw,relatime)
nfsd on /proc/fs/nfsd type nfsd (rw,relatime)
127.0.0.1:/home/zynq/Desktop/work on /mnt type nfs4 (rw,relatime,vers=4.0,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=127.0.0.1,local_lock=none,addr=127.0.0.1)
powershell 复制代码
cd /mnt
sudo mkdir test.txt

发现在work目录里边也会出现test.txt

也可以设置共享目录,将windows文件,映射到此 work目录进行ubuntu和windows共享

相关推荐
CZIDC7 小时前
win11 系统环境下 新安装 WSL ubuntu + ssh + gnome 桌面环境
数据库·ubuntu·ssh
wkm9567 小时前
qt.qpa.xcb: could not connect to display解决方法
开发语言·qt·ubuntu
令狐少侠201110 小时前
Ubuntu 24.04.2 LTS 系统安装python,创建虚拟环境
linux·python·ubuntu
一只小白跳起来13 小时前
重新安装VMware tools为灰色无法点击问题解决|读取电脑文件的共享文件夹方法
运维·ubuntu·vmware
跳跳糖炒酸奶13 小时前
第四章、Isaacsim在GUI中构建机器人(2):组装一个简单的机器人
人工智能·python·算法·ubuntu·机器人
odoo-卜永13 小时前
ubuntu22.04连接爱普生打印机型号L385
linux·经验分享·ubuntu
小麦嵌入式14 小时前
Linux驱动开发实战(十一):GPIO子系统深度解析与RGB LED驱动实践
linux·c语言·驱动开发·stm32·嵌入式硬件·物联网·ubuntu
跳跳糖炒酸奶17 小时前
第四章、Isaacsim在GUI中构建机器人(1): 添加简单对象
人工智能·python·ubuntu·机器人
吃旺旺雪饼的小男孩17 小时前
Ubuntu 22.04 安装和运行 EDK2 超详细教程
linux·运维·ubuntu