Q: `hdiutil` Option "-notremovable" Doesn't Work
I don't mean to repost my similar question, but what I thought was an OS X Server RAM disk based problem, I have come to find out is a general 10.6 problem with `hdiutil`.
So the -notremovable option in hdiutil is a pretty obscure feature. I don't think many people use it which is why you don't get much when you google it. You get a few threads from other people trying to use it in 10.6, for different things than I'm trying to use it for, but with the same result.
I'm using it to mount a RAM disk. I've been using this RAM disk script for a few years in 10.5 and it works great. I've also tested it in 10.7 and 10.8, it works great in both of those too. The only problem is 10.6. From what I can tell, -notremovable fails in every version of 10.6, server or not server. If you take out the -notremovable flag from your not-working hdiutil command, it will work fine.
The problem for me is that without that option, your RAM disk gets mounted as a "removable" disk, like a mounted disk image. With that option, it gets mounted as a non removable disk, like a hard drive. That is what I need for two reasons. One, it lets me back up the RAM disk using Time Machine, which is very useful. And two, disk images are ejected before shutdown scripts are run, but hard drives are ejected afterwards. So my shutdown script to copy the contents of the RAM disk doesn't work, because the RAM disk is gone before script even runs.
The exact command I'm using (that runs as root) is this:
/usr/sbin/diskutil erasevolume HFS+ "web-ram" `/usr/bin/hdiutil attach -notremovable -nomount ram://2200000`
In 10.5, 10.7 and 10.8, that creates an ~1GB RAM disk, that gets mounted to the desktop as if it was a physical disk.
A little more background info. The 10.5 machine I have now is a G5 Xserve. It is being replaced by an early 2008 Xserve running 10.6. Upgrading to 10.7 isn't an option for me, because the primary purpose of this server is web serving, and Apple really gutted the web server functionality of 10.7. I'd have to totally bypass the server admin tools and manually manage apache which 1) I don't want to do and 2) if I'm going to do that, why run OS X Server at all?
My usage is quite simple, I store all of my web folders on the RAM disk (except a few folders of larger rarely accessed documents, which live on disk). It works very well, especially since even with a bunch of sites, we're only talking about approximately 40 MB of files. So keeping it all in RAM is very easy, and provides the ultimate in high speed, low seek time access.
So if I have to, I can move my web folder back to the hard disk, and run the server with that more traditional setup. But I'm really hoping there is some way to make this work. Some other way to mount the RAM disk, or some undocumented way hdiutil works in 10.6 that is somehow different. It wouldn't be the first time that has happened.
FYI I benchmarked this Xserver's RAM disk and I was able to get about 1 GB/sec read speed and 2 GB/sec write speed. The general idea is I want to remove the slow bottleneck that is hard disk speed from my server's time sensitive functions, so the web sites can flow out of this thing like a flood. I need my server to be able to take in stride, the huge burst of traffic that I'm always hoping I get
Xserve, Mac OS X (10.6.8), 8 x 3.0 GHz, 8 GB RAM, Early 2008
Posted on May 16, 2012 3:26 AM