MacOS – Problem with startup `rc.local` script

macosscriptstartup

Until OS X 10.9 I could also run Bootcamp within Virtualbox (through a .vmdk file). In order to do this, I needed to unmount the Bootcamp partition after changing the permissions during the OS X startup process in the rc.local file. Now, with OS X 10.10 rc.local does not seem to work anymore and I cannot start my virtual machine without first manually execute the terminal commands that are in my rc.local script.

Here is my rc.local content:

sudo chmod 777 /dev/disk0s4
diskutil unmount /dev/disk0s4

I understood that rc.local is not supported anymore in Yosemite and launchd should be used instead. Source:: How To: Run Windows 7 (Bootcamp) in VirtualBox.

Can someone help me with a valid script and show me how to use it?

Best Answer

I was using those commands for VirtualBox in rc.local, and I ran into the same problem. I don't if this is the right way to do this, but it works for me.

I created /Library/LaunchDaemons/local.localhost.startup.plist containing the code below. It runs the rc.local script once at start up.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>             <string>local.localhost.startup</string>
    <key>Disabled</key>          <false/>
    <key>RunAtLoad</key>         <true/>
    <key>KeepAlive</key>         <false/>
    <key>LaunchOnlyOnce</key>    <true/>
    <key>ProgramArguments</key>
        <array>
            <string>/etc/rc.local</string>
        </array>
</dict>
</plist>