1. 程式人生 > 實用技巧 >ubuntu server 20.04 設定虛擬機器共享目錄命令開機啟動

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

重啟系統