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

相关推荐
写点什么啦7 小时前
[debug]不同的window连接ubuntu的vscode后无法正常加载kernel
linux·vscode·ubuntu·debug
wellnw7 小时前
[ubuntu]编译共享内存读取出现read.c:(.text+0x1a): undefined reference to `shm_open‘问题解决方案
linux·ubuntu
oushaojun211 小时前
ubuntu中使用ffmpeg和nginx推流rtmp视频
nginx·ubuntu·ffmpeg·rtmp
命里有定数15 小时前
Ubuntu问题 -- 通过远程修改文件配置ubuntu服务器的静态IP (不需要到服务器现场) (通过NetworkManager)
运维·服务器·tcp/ip·ubuntu·网卡
命里有定数18 小时前
Ubuntu问题 - 显示ubuntu服务器上可用磁盘空间 一条命令df -h
服务器·ubuntu·数据集
命里有定数1 天前
Ubuntu问题 -- 设置ubuntu的IP为静态IP (图形化界面设置) 小白友好
linux·tcp/ip·ubuntu·ip
基极向上的三极管1 天前
【Linux学习】【Ubuntu入门】1-8 ubuntu下压缩与解压缩
linux·ubuntu
云计算运维丁丁1 天前
Linux四剑客及正则表达式
linux·运维·服务器·ubuntu
sun0077001 天前
Ubuntu networkmanager
linux·运维·ubuntu
xx小寂1 天前
ubuntu16.04在ros使用USB摄像头-解决could not open /dev/video0问题
ubuntu·机器人