当前位置: 首页 > news >正文

Ubuntu 虚拟机挂接 Windows 目录

Windows 共享目录

首先 Windows 下共享目录

我这里偷懒直接直接 Everyone ,也可以指定用户啥的

在这里插入图片描述

Ubuntu 挂接

挂接命令,类似如下:

sudo mount -o 'username=fananchong,password=xxxx,uid=1000,gid=1000,file_mode=0644,dir_mode=0755,dynperm' //xx.xx.xx.xx/dep2 /home/fananchong/xxxx/gameserver/dep

对上面命令做下说明:

内容说明
usernameWindows 系统的登录账号
passwordWindows 系统的登录密码
uidUbuntu 系统账号的 uid 。执行 id -u 可以获得
gidUbuntu 系统账号的 gid 。执行 id -g 可以获得
file_mode创建文件时,设置文件权限是什么
dir_mode创建目录时,设置目录权限是什么
dynpermUbuntu 下可以更改文件、目录权限
//xx.xx.xx.xx/dep2Windows 要共享的目录
/home/fananchong/xxxx/gameserver/depUbuntu 下挂接到哪个目录

这里重点说下dynperm
如果没有这个参数,Ubuntu 下会无法更改文件目录的权限,导致 chmod 命令执行无效
这对于 git 库下的文件会导致都有 diff 差异

设置开机启动

这里使用在/etc/rc.local里配置挂接命令
Ubuntu 默认没开启 /etc/rc.local 的功能

步骤1:查看服务是否开启

>systemctl status rc-local.service                                                                                             
● rc-local.service - /etc/rc.local CompatibilityLoaded: loaded (/lib/systemd/system/rc-local.service; enabled; vendor preset: enabled)Drop-In: /usr/lib/systemd/system/rc-local.service.d└─debian.confActive: active (exited) since Sat 2024-01-06 02:32:46 UTC; 5h 2min agoDocs: man:systemd-rc-local-generator(8)Process: 739 ExecStart=/etc/rc.local start (code=exited, status=0/SUCCESS)CPU: 11ms

这里打印的是已开启的

步骤2:开启服务

如果没有开启,修改/lib/systemd/system/rc-local.service

在该文件内添加Install的内容。修改后,完整文件内容如下:

cat /lib/systemd/system/rc-local.service                                                                          ✔  took 1m 12s  with fananchong@myubuntu  at 07:36:33 
#  SPDX-License-Identifier: LGPL-2.1-or-later
#
#  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  
Alias=rc-local.service

然后设置开机启动:

sudo systemctl enable rc-local.service

步骤3:创建/etc/rc.local

sudo touch /etc/rc.local
sudo chmod +x /etc/rc.local

步骤4:设置开机启动内容

然后把刚才的 mount 命令写到/etc/rc.local

步骤5:启动服务

sudo systemctl start rc-local.service
http://www.lryc.cn/news/275514.html

相关文章:

  • 机器学习模型可解释性的结果分析
  • 静态网页设计——环保网(HTML+CSS+JavaScript)(dw、sublime Text、webstorm、HBuilder X)
  • 【HarmonyOS】装饰器下的状态管理与页面路由跳转实现
  • 学习笔记——C++中数据的输入 cin
  • Filter Options in Select Field
  • 【React系列】Hook(二)高级使用
  • 编程笔记 html5cssjs 018 HTML颜色
  • C++_继承
  • Java-IO流-15
  • java中使用redis
  • Mongodb的可重试读操作
  • 2024年1月2日-1月7日(ue5底层渲染+ue arpg+项目需求)
  • MySQL中的视图和触发器
  • uView-UI v2.x常见问题整理
  • MBTI职业性格测试 28题(免费版)
  • Springcloud 微服务实战笔记 Ribbon
  • CSS基础笔记-04cascade-specificity-inheritance
  • Spring应用的部署与管理
  • B端产品经理学习-需求挖掘
  • 整数规划基本原理
  • 秋招复习之堆
  • 算法训练营Day36(贪心-重叠区间)
  • 如何利用Oracle官方网站不登录账号下载和安装非最新版本的JDK(版本自由选择)
  • 税法相关的基础知识
  • ListNode 2487. 从链表中移除节点,单调栈的应用
  • vue3中pdf打印问题处理
  • 如何向嵌入式设备中添加tcpdump工具
  • 伦茨科技Apple Find My认证芯片-ST17H6x芯片
  • uni-app 前后端调用实例 基于Springboot 数据列表显示实现
  • python渗透工具编写学习笔记:10、网络爬虫基础/多功能编写