在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
请根据实际情况修改 User
、Group
、ExecStart
和 ExecStop
中的 Ubuntu
和路径。
sudo systemctl daemon-reloads
sudo systemctl enable auto_start_ubuntu.service
sudo systemctl disable auto_start_ubuntu.service
请注意,以上步骤可能会因VirtualBox版本或Ubuntu版本的不同而有所差异。如果遇到问题,建议查阅VirtualBox和Ubuntu的官方文档或寻求社区帮助。