Ubuntu添加网络映射路径

news/2024/9/23 6:15:53/

参考资料

linux挂在阿里云盘(webdav协议)给服务器扩容、备份数据等_davfs2-CSDN博客

Linux将WebDAV为本地磁盘 - 夏日冰菓 (lincloud.pro)

systemd系统开机运行rc.local_rc-local.service: failed to execute command: exec -CSDN博客

系统版本:

Welcome to Ubuntu 22.04.3 LTS (GNU/Linux 5.15.0-105-generic x86_64)

现有webdev地址:http://192.168.3.2:5005/185xxxx/very-mount/linuxServer,以及webdev账号密码

欲挂载在linux的\home\kono707da\nas-mount路径下

  1. 安装davfs2

    apt-get install davfs2
    
  2. 挂载网络磁盘

    sudo mount -t davfs http://192.168.3.2:5005/185xxxx/very-mount/linuxServer /home/kono707da/nas-mount
  3. 输入账密

  4. 配置开机自启

    1. 修改use_locks

      sudo vim /etc/davfs2/davfs2.conf 
      

      # use_locks 1改为use_locks 0

    2. 修改secrets文件,添加账号信息

      vim /etc/davfs2/secrets
      
    3. 文件底部添加账号信息

      http://192.168.3.2:5005/185xxxx/very-mount/linuxServer myAccount myPassword
      
    4. 配置rc-local

      1. 检查rc-local状态

        sudo systemctl status rc-local
        

        可能的报错:

        ● rc-local.service - /etc/rc.local CompatibilityLoaded: loaded (/lib/systemd/system/rc-local.service; enabled-runtime; vendor preset: enabled)Drop-In: /lib/systemd/system/rc-local.service.d└─debian.confActive: failed (Result: exit-code) since Thu 2018-11-01 10:56:36 CST; 1h 59min agoDocs: man:systemd-rc-local-generator(8)Process: 1961 ExecStart=/etc/rc.local start (code=exited, status=203/EXEC)11月 01 10:56:36 ubuntu systemd[1]: Starting /etc/rc.local Compatibility...
        11月 01 10:56:36 ubuntu systemd[1961]: rc-local.service: Failed to execute command: Exec format error
        11月 01 10:56:36 ubuntu systemd[1961]: rc-local.service: Failed at step EXEC spawning /etc/rc.local: Exec format e
        11月 01 10:56:36 ubuntu systemd[1]: rc-local.service: Control process exited, code=exited status=203
        11月 01 10:56:36 ubuntu systemd[1]: rc-local.service: Failed with result 'exit-code'.
        11月 01 10:56:36 ubuntu systemd[1]: Failed to start /etc/rc.local Compatibility.
        
      2. 尝试开启rc-local

        sudo systemctl enable rc-local
        

        可能的报错:

        xugaoxiang@ubuntu:~$ sudo systemctl enable rc-local
        The unit files have no installation config (WantedBy, RequiredBy, Also, Alias
        settings in the [Install] section, and DefaultInstance for template units).
        This means they are not meant to be enabled using systemctl.
        Possible reasons for having this kind of units are:
        1) A unit may be statically enabled by being symlinked from another unit's.wants/ or .requires/ directory.
        2) A unit's purpose may be to act as a helper for some other unit which hasa requirement dependency on it.
        3) A unit may be started when needed via activation (socket, path, timer,D-Bus, udev, scripted systemctl call, ...).
        4) In case of template units, the unit is meant to be enabled with someinstance name specified.
        
      3. 修复问题:The unit files have no installation config

        复制一份rc-local文件到目标目录

        sudo cp /lib/systemd/system/rc-local.service /etc/systemd/system/rc-local.service
        

        修改rc-local.service文件,加入[Install]的内容

        #  SPDX-License-Identifier: LGPL-2.1+
        #
        #  This file is part of systemd.
        #
        #  systemd is free software; you can redistribute it and/or modify it
        #  under the terms of the GNU Lesser General Public License as published by
        #  the Free Software Foundation; either version 2.1 of the License, or
        #  (at your option) any later version.# This unit gets pulled automatically into multi-user.target by
        # systemd-rc-local-generator if /etc/rc.local is executable.
        [Unit]
        Description=/etc/rc.local Compatibility
        Documentation=man:systemd-rc-local-generator(8)
        ConditionFileIsExecutable=/etc/rc.local
        After=network.target[Service]
        Type=forking
        ExecStart=/etc/rc.local start
        TimeoutSec=0
        RemainAfterExit=yes
        GuessMainPID=no[Install]
        WantedBy=multi-user.target
        
    5. 创建/etc/rc.local文件,输入开机运行脚本

      #!/bin/bashmount -t davfs http://192.168.3.2:5005/185xxxx/very-mount/linuxServer /home/kono707da/nas-mount
    6. 重启即可自动挂载。

  5. 测试

    输入df -h检查服务是否自启动

    在这里插入图片描述


http://www.ppmy.cn/news/1457978.html

相关文章

20个入门级Python项目

很多刚刚入门python的同学除了书上、老师讲解的1、2个demo示例之外,基本上很难找到适合练手的入门级Python项目。 作者不辞辛苦,花了很长时间整理了20个适合练手的实例项目 下面这20个练手项目全部去是免费的,大家可以任意下载,…

git对远程和本地分支进行重命名

要同时对Git的远程和本地分支进行重命名,你需要分几个步骤操作: 重命名本地分支 切换到其他分支:在重命名当前分支之前,确保你不在你想要重命名的那个分支上。你可以通过以下命令切换到另一个分支(比如切换到master分…

存储大作战:探索Local Storage与Session Storage的奥秘

欢迎来到我的博客,代码的世界里,每一行都是一个故事 存储大作战:探索Local Storage与Session Storage的奥秘 前言Local Storage与Session Storage简介数据存储生命周期容量限制安全性 前言 在Web的世界里,数据就像是一群流浪者&a…

安泰ATA-3040C功率放大器是指什么意思

功率放大器是一种电子设备,用于将输入信号的功率放大到更高的输出功率。它是现代电子设备中非常常见的组件,广泛应用于通信系统、音响设备、无线电设备、雷达系统等领域。 功率放大器的主要作用是将弱信号放大到足够的功率,以便可以有效地传输…

AWTK 和 QT 资源占用不完全对比

因为没有开发两个完全一样的应用程序,对比的结果并不是很准确,仅供参考。 对比的程序为: AWTK demoui 演示了 AWTK 常用功能。 QT QDesktop 演示了 QT 常用功能。 运行平台为: i.MX6ULL Linux 1. 可以执行文件大小 1.1 AWTK…

【北京迅为】《iTOP-3588开发板源码编译手册》-第六章 安装编译所需要的依赖包

RK3588是一款低功耗、高性能的处理器,适用于基于arm的PC和Edge计算设备、个人移动互联网设备等数字多媒体应用,RK3588支持8K视频编解码,内置GPU可以完全兼容OpenGLES 1.1、2.0和3.2。RK3588引入了新一代完全基于硬件的最大4800万像素ISP&…

【Kali Linux工具篇】使用Aircrack-ng破解wifi密码

前期准备 1、一个无线网卡 2、密钥爆破字典 实站过程 1、设置wlan为监听模式 airmon-ng start wlan0 #开启网卡wlan0监听模式 iwconfig #查看网卡状态,发现wlan0mon,表示已开启成功2、探测附近WiFi airdump-ng wlan0monBSSID 代表…

pytorch中的transforms.resize()函数

transforms.Resize 是 PyTorch 的 torchvision.transforms 模块中的一个函数,它用于调整图像的大小。这个函数可以接收一个整数或一个元组作为参数,以指定输出图像的大小。 使用方式 当 size 参数是一个整数时,表示将图像的较短边缩放到指定…