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共享

相关推荐
丰色木夕1 小时前
Ubuntu下的tcl/tk编程快速入门
ubuntu·tcl·tk
大妞1 小时前
ubuntu20.04 install vscode[ROS]
ubuntu
ac.char2 小时前
在 Ubuntu 下使用 Tauri 打包 EXE 应用
linux·运维·ubuntu
小燚~3 小时前
ubuntu开机进入initramfs状态
linux·运维·ubuntu
hhhhhhh_hhhhhh_3 小时前
ubuntu18.04连接不上网络问题
linux·运维·ubuntu
White_Mountain13 小时前
在Ubuntu中配置mysql,并允许外部访问数据库
数据库·mysql·ubuntu
coder_pig14 小时前
📝小记:Ubuntu 部署 Jenkins 打包 Flutter APK
flutter·ubuntu·jenkins
mit6.82415 小时前
Ubuntu 系统下性能剖析工具: perf
linux·运维·ubuntu
watermelonoops16 小时前
Windows安装Ubuntu,Deepin三系统启动问题(XXX has invalid signature 您需要先加载内核)
linux·运维·ubuntu·deepin
YRr YRr18 小时前
解决Ubuntu 20.04上编译OpenCV 3.2时遇到的stdlib.h缺失错误
linux·opencv·ubuntu