在 OS X Lion 上启动/关闭时无法启动
我按照一些在线指南尝试让一些无头虚拟机在我的 Mac 上启动/关闭时自动启动/暂停。我根本无法让它工作。这是我第一次尝试让脚本在启动/关闭时运行,所以可能我只是错过了一些非常基本的东西,如果是这种情况,我深表歉意。
以下是我遵循的步骤:
- 创建了一个目录
/Library/StartupItems/HeadlessVM
在该目录中创建了两个文件:
-rwxr--r-- 1根轮 242 二月 19 19:05 HeadlessVM -rw-r--r-- 1根轮 188 二月 20 12:42 StartupParameters.plist
HeadlessVM 的内容
$ cat HeadlessVM #!/bin/sh 。 /etc/rc.common 启动服务() { 控制台消息“正在启动 HeadlessVM” /usr/local/bin/runvmheadless } 停止服务() { 控制台消息“暂停 HeadlessVM” /usr/local/bin/suspendvmheadless } 运行服务“$1”
StartupParameters.plist 的内容
$ cat StartupParameters.plist { 描述 =“在 OS X 启动/关闭时运行/挂起无头虚拟机”; 提供 = ("HeadlessVM"); 使用=(“磁盘”); 订单偏好 = ("迟到"); }
创建了我的脚本文件,它将执行这两个操作:
-rwxr-xr-x@ 1 xxxxxxx admin 164 二月 19 日 01:06 runvmheadless -rwxr-xr-x@ 1 xxxxxxx 管理员 160 二月 19 01:19 suspendvmheadless
runvmheadless 的内容
$ cat runvmheadless #!/bin/bash “/Applications/VMware Fusion.app/Contents/Library/vmrun” -T fusion start “/Volumes/Archive/Virtual Machines/vm.vmwarevm/vm.vmx” nogui
Suspendvmheadless 的内容
$ cat suspendvmheadless #!/bin/bash “/Applications/VMware Fusion.app/Contents/Library/vmrun” -T fusion 挂起“/Volumes/StaticData/Virtual Machines/vm.vmwarevm/vm.vmx”
到目前为止我的故障排除:
- 如果我从终端运行脚本,它们就会按预期工作。
- 如果我运行
sudo /sbin/SystemStarter(启动或停止)“HeadlessVM”
它也可以工作。 在控制台上,我仅在重新启动时看到以下内容,但不知道出了什么问题。
2012 年 2 月 20 日 12:11:09.128 PM SystemStarter:在 OS X 上无头运行/暂停虚拟机启动/关闭 (100) 未成功完成
感谢任何帮助,谢谢。
I followed some online guides trying to get some headless VMs to start/suspend automatically at boot/shutdown on my Mac. I can't get it to work at all. This is my first time trying to get script runs on Startup/Shutdown, so it could be that I'm just missing something very basic and if that's the case I apologize.
These are the steps I followed:
- Created a directory
/Library/StartupItems/HeadlessVM
Created two files within that directory:
-rwxr--r-- 1 root wheel 242 Feb 19 19:05 HeadlessVM -rw-r--r-- 1 root wheel 188 Feb 20 12:42 StartupParameters.plist
Contents for HeadlessVM
$ cat HeadlessVM #!/bin/sh . /etc/rc.common StartService () { ConsoleMessage "Starting HeadlessVM" /usr/local/bin/runvmheadless } StopService () { ConsoleMessage "Suspending HeadlessVM" /usr/local/bin/suspendvmheadless } RunService "$1"
Contents for StartupParameters.plist
$ cat StartupParameters.plist { Description = "Runs/Suspends Virtual Machine Headless on OS X Startup/Shutdown"; Provides = ("HeadlessVM"); Uses = ("Disks"); OrderPreference = ("Late"); }
Created my script files, that will perform both actions:
-rwxr-xr-x@ 1 xxxxxxx admin 164 Feb 19 01:06 runvmheadless -rwxr-xr-x@ 1 xxxxxxx admin 160 Feb 19 01:19 suspendvmheadless
Contents for runvmheadless
$ cat runvmheadless #!/bin/bash "/Applications/VMware Fusion.app/Contents/Library/vmrun" -T fusion start "/Volumes/Archive/Virtual Machines/vm.vmwarevm/vm.vmx" nogui
Contents for suspendvmheadless
$ cat suspendvmheadless #!/bin/bash "/Applications/VMware Fusion.app/Contents/Library/vmrun" -T fusion suspend "/Volumes/StaticData/Virtual Machines/vm.vmwarevm/vm.vmx"
My troubleshooting so far:
- If I run the scripts from the terminal, they work as intended.
- If I run
sudo /sbin/SystemStarter (start or stop) "HeadlessVM"
it also works. On console I only see the following when I reboot, no clue on what's wrong tho.
2/20/12 12:11:09.128 PM SystemStarter: Runs/Suspends Virtual Machine Headless on OS X Startup/Shutdown (100) did not complete successfully
Appreciate any help, Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现出了什么问题。上面的代码很好,问题是我的脚本正在尝试从加密的辅助磁盘获取数据,而该数据在启动时不可用。
我用它来绕过这个问题:https://github.com/jridgewell/Unlock
谢谢
I found what was wrong. The code above is fine, the problem is that my scripts are trying to get data from an encrypted secondary disk which was not available at boot time.
I used this in order to bypass this problem:https://github.com/jridgewell/Unlock
Thanks