• ubuntu挂载共享目录的方法


    ubuntu挂载共享目录的方法

    安装NFS

    sudo apt-get install nfs-kernel-server
    
    • 1

    配置NFS

    创建work共享目录:(本人将此文件放在桌面)
    
    • 1
    sudo mkdir work
    
    • 1
    sudo gedit /etc/exports
    
    • 1

    添加:

    /home/zynq/Desktop/work  *(rw,sync,no_root_squash,no_subtree_check)
    
    • 1

    运行以下命令:

    sudo systemctl restart rpcbind
    		sudo systemctl restart nfs-kernel-server
    		sudo systemctl status nfs-kernel-server
    
    • 1
    • 2
    • 3

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

    ● 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.
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13

    挂载work目录:

    sudo mount -t nfs 127.0.0.1:/home/zynq/Desktop/work /mnt
    
    • 1

    运行:

    sudo mount
    
    • 1

    结果显示:

    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)
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    cd /mnt
    sudo mkdir test.txt
    
    • 1
    • 2

    发现在work目录里边也会出现test.txt
    也可以设置共享目录,将windows文件,映射到此 work目录进行ubuntu和windows共享

  • 相关阅读:
    oppo前端开发一面
    程序员的悲哀
    Vue中使用百度地图引发内存泄露的分析与解决方案
    java 数组一维转二维
    全国的科技创新情况数据分享,涵盖2020-2022年三年情况
    RK3399平台开发系列讲解(内核调试篇)USB摄像头快速测试
    无人机实践:DJI A3 飞控---使用
    Prometheus(普罗米修斯)+grafana(3)
    常见响应头,请求头
    来了,永久免费的图床服务
  • 原文地址:https://blog.csdn.net/yekui006/article/details/134235708