在VirtualBox中設置Ubuntu虛擬機的啟動項,可以通過以下幾種方法實現:
/etc/systemd/system/auto_start_ubuntu.service
:[Unit]
Description=Start Ubuntu Virtual Machine After=network.target virtualbox.service Before=runlevel2.target shutdown.target
[Service]
User=your_username
Group=vboxusers
Type=forking
Restart=no
TimeoutSec=5 min
IgnoreSIGPIPE=no
KillMode=process
GuessMainPid=no
RemainAfterExit=yes
ExecStart=/usr/bin/VBoxManage startvm Ubuntu --type headless
ExecStop=/usr/bin/VBoxManage controlvm Ubuntu acpipowerbutton
sudo systemctl daemon-reloads
sudo systemctl enable auto_start_ubuntu.service
sudo systemctl disable auto_start_ubuntu.service
請注意,以上步驟可能會因VirtualBox版本或Ubuntu版本的不同而有所差異。如果遇到問題,建議查閱VirtualBox和Ubuntu的官方文檔或尋求社區幫助。