i am trying to mount /private/tmp as ram disk. I have this "ramfs.sh" script, which i found from the internet:
#!/bin/bash
ramfs_size_mb=1024
mount_point=/private/tmp
ramfs_size_sectors=$((${ramfs_size_mb}*1024*1024/512))
ramdisk_dev=`hdid -nomount ram://${ramfs_size_sectors}`
newfs_hfs -v 'Volatile HD' ${ramdisk_dev}
mkdir -p ${mount_point}
mount -o noatime -t hfs ${ramdisk_dev} ${mount_point}
chown root:wheel ${mount_point}
chmod 1777 ${mount_point}
It is working fine, if i run it manually from terminal. However i have problem running it from LaunchDemon. I have this contents in the file "/Library/LaunchDaemons/com.kalugin.ramfs-for-db.plist":
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.kalugin.ramfs-for-db</string>
<key>Program</key>
<string>/var/root/ramfs.sh</string>
<key>RunAtLoad</key>
<true/>
<key>StandardOutPath</key>
<string>/var/log/ramfs_for_db.log</string>
<key>StandardErrorPath</key>
<string>/var/log/ramfs_for_db_error.log</string>
<key>Debug</key>
<true/>
</dict>
</plist>
After system load i have:
/dev/disk1
#: TYPE NAME SIZE IDENTIFIER
0: Volatile HD *1.1 GB disk1
But "mount" doesn't show /private/tmp as mounted on disk1. Logs show only this: "Initialized /dev/rdisk1 as a 1024 MB case-insensitive HFS Plus volume".
So definitely script is executed during system start up, but looks like mount command does not work. Any ideas? Thank you.
EDIT
I added some "echo" in script and make "mount" verbose. Here is output:
Creating ram disk...
Initialized /dev/rdisk1 as a 1024 MB case-insensitive HFS Plus volume
Mounting ram disk...
/dev/disk1 on /private/tmp (hfs, local, noatime)
Setting permissions...
So looks like script is doing fine, and even mounted disk. But looks like during boot "tmp" folder is overwritten?
EDIT2
Looks like everything is fine, except something unmounts my mounted disk on system start up. Also someone noticed this behavior too link.
I solved my problem by following plist file:
Looks like "RunAtLoad" is not enough or it doesn't work, i don't know. But with "KeepAlive" it is working fine.