l008com

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

Close

Q: `hdiutil` Option "-notremovable" Doesn't Work

  • All replies
  • Helpful answers

Previous Page 2
  • by l008com,

    l008com l008com Jun 16, 2012 8:10 AM in response to snow-punk
    Level 1 (43 points)
    Notebooks
    Jun 16, 2012 8:10 AM in response to snow-punk

    The icon itself means nothing, it's the behavior that the icon implies. I appreciate the effort but I'm just going to go ram diskless on this server. It's too bad apple never fixed this bug in snow leopard.

  • by snow-punk,

    snow-punk snow-punk Jul 11, 2012 9:24 AM in response to snow-punk
    Level 1 (5 points)
    Jul 11, 2012 9:24 AM in response to snow-punk

    snow-punk wrote:

     

    But now with the notremovable flag, the volume still gets unmounted when the magic system event network-change happens.

     

    I also experimented with the command

     

         sudo diskutil enableOwnership /dev/disk<some_number>

     

    after creating the ramdisk with hdid.

    It seems to make the ramdrive mount more robust against the magic system event network-change and lets the mount survives better (more often, until now always) after having my mac in sleep mode.

    Its not perfectly tested so far, but I have the goog feeling, that this setting helps.

    It could also be the following command, which I tried during my tests:

     

         sudo hdiutil mount -owners on /dev/disk<some_number>

     

    So I am not quite sure atm, which one did the trick.

     

    At least, I found, if I got the ramdrive mounted somehow, that only root can unmount it, then we have the situation we want: in that case it survives sleeps by lid closes. I can test that state by trying to unmount the drive in Finder. If the OS asks for auth, then it is mounted the "stronger" way.

     

    Maybe someone else or me will test this again, and can post more exact findings.

     

    Cheers,

    snow-punk

  • by ikwanzan,

    ikwanzan ikwanzan Jun 3, 2015 9:54 PM in response to snow-punk
    Level 1 (0 points)
    Jun 3, 2015 9:54 PM in response to snow-punk

    snow-punk:

     

    Lots of folks looking for an answer to this problem, and as far as my experience, you solved it.

     

    I'm running 10.6.8, on intel iMac circa 2009. Problem same as for many I found on the 'net: ram disk ejected after wake from sleep. You seemed to have found the solution.

     

    What I did:

     

    In Terminal (of course), logged on to my machine as non-admin user (my main account is non-admin):

     

    First command                sudo /usr/bin/hdid  -notremovable -nomount -kernel ram://128000            (128000 is size of ram disk)

     

    This command returns a result after completion. I call it DEVICE_NAME.

     

    Second command            sudo /usr/sbin/diskutil erasevolume HFS+ "RamDisk2"  DEVICE_NAME    (to create a ram disk named RamDisk2)

     

    Third command                sudo diskutil enableOwnership DEVICE_NAME

     

    I then put my machine to sleep. Waited a moment or two, then awakened. Ram disk was not ejected. Yay! I don't know if it made a difference, but I also copied a simple file to the ram disk before putting the machine to sleep, so it would not be empty. Very doubtful that had any effect.

     

    So, your steps worked, given the exact situation (machine, OS, user) I described.

     

    Thank you, thank you.

Previous Page 2