无法通过 Wi-Fi 正确安装网络驱动器

无法通过 Wi-Fi 正确安装网络驱动器

我正在尝试在 Lubuntu 16.4 Raspberry Pi 版本上安装网络驱动器。我想澄清的是我可以使用 mount 命令。问题在于启动时安装它。我已经修改了/etc/fstab。它在以太网上正常工作。

但是,当仅安装 USB 无线适配器时,网络驱动器无法安装(错误代码 -101)

我怀疑这是因为 Lubuntu 从 fstab 安装驱动器之前没有初始化 Wi-Fi 适配器造成的。

我能做些什么?

答案1

我遇到了同样的问题,我发现使用 automount 是一个很好的解决方案systemd。解释如下:https://ppfeufer.de/linux-on-demand-nfs-and-samba-cifs-connections-with-systemd-automount/

  1. 安装所需的软件包:

    sudo apt-get install samba cifs-utils nfs-common 
    
  2. 创建挂载点:

    sudo mkdir -p /mnt/network/myshare
    
  3. 创建凭证文件:

    sudo nano /etc/samba/credentials
    

    其中包含以下几行:

    username=your_username
    password=your_password
    
  4. 然后运行:

    sudo chmod 600 /etc/samba/credentials
    
  5. 创建systemd单元文件:

    sudo nano /etc/systemd/system/mnt-network-myshare.mount
    

    例如:CIFS

    [Unit]
    Description = My Share mount
    Requires = dbus-org.freedesktop.nm-dispatcher.service
    After = network-online.target
    Wants = network-online.target
    
    [Mount]
    What = //example.server/myshare
    Where = /mnt/network/myshare
    Options = credentials=/etc/samba/credentials,vers=3.1.1,uid=your_username,iocharset=utf8,file_mode=0655,dir_mode=0655,noperm
    Type = cifs
    TimeoutSec = 30
    
    [Install]
    WantedBy = multi-user.target
    

    例如:NFS

    [Unit]
    Description = My Share mount
    Requires = dbus-org.freedesktop.nm-dispatcher.service
    After = network-online.target
    Wants = network-online.target
    
    [Mount]
    What = example.server:/myshare
    Where = /mnt/network/myshare
    Options = defaults
    Type = nfs
    TimeoutSec = 30
    
    [Install]
    WantedBy = multi-user.target
    
  6. 创建自动挂载文件:

    sudo nano /etc/systemd/system/mnt-network-myshare.automount
    

    内容如下:

    [Unit]
    Description = Automount for My Share
    ConditionPathExists = /mnt/network/myshare
    
    [Automount]
    Where = /mnt/network/myshare
    TimeoutIdleSec = 0
    
    [Install]
    WantedBy = multi-user.target
    
  7. 测试它是否有效:

    sudo systemctl daemon-reload
    sudo systemctl start mnt-network-myshare.mount
    sudo systemctl status mnt-network-myshare.mount
    

    输出应该是这样的:

    mnt-network-myshare.mount - My Share mount
       Loaded: loaded (/etc/systemd/system/mnt-network-myshare.moun; static; vendor preset: enabled)
       Active: active (running) since Fri 2022-04-29 10:10:03 CEST; 1min 1s ago
        Where: /mnt/network/myshare
         What: //example.server/myshare
      Process: 13005 ExecMount=/bin/mount //example.server/myshare /mnt/network/myshare -t cifs -o vers=3.1.1,credentials=/home/your_username/.mount-credentials/myshare,iocharset=utf8,rw,x-systemd.automount,uid=1000 (code=exited, status=0/SUCCESS)
        Tasks: 0 (limit: 4915)
       CGroup: /system.slice/mnt-smb-sambashare.mount
    
    Apr 29 10:10:03 your_pc systemd[1]: Mounting My Share mount...
    Apr 29 10:10:03 your_pc systemd[1]: Mounted My Share mount.
    
  8. 您也可以测试自动挂载:

    sudo systemctl start mnt-network-myshare.automount
    sudo systemctl status mnt-network-myshare.automount
    
  9. 启用自动挂载文件在启动时启动:

    sudo systemctl enable mnt-network-myshare.automount
    

相关内容