ubuntu server 20.04 设置虚拟机共享目录命令开机启动

vim打开/lib/systemd/system/rc-local.service添加install项
vi /lib/systemd/system/rc-local.service
#  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

# added by yourself
[Install]
WantedBy=multi-user.target
Alias=rc-local.service

保存退出。

把刚保存的文件链接到/etc/systemd/system/目录下:

ln -s /lib/systemd/system/rc-local.service /etc/systemd/system/rc-local.service


打开 /etc/rc.local 输入
vi /etc/rc.local
#!/bin/bash
/usr/bin/vmhgfs-fuse .host:/www /www/web -o subtype=vmhgfs-fuse,allow_other -o nonempty
exit 0

保存,退出,赋权限

chmod 755 /etc/rc.local

重启系统

 
posted @ 2020-08-15 22:18  龙影123  阅读(537)  评论(0)    收藏  举报