Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Mac OS X > Mounting RAM Disks as -notremovable in 10.6

Mounting RAM Disks as -notremovable in 10.6
Thread Tools
Addicted to MacNN
Join Date: Jan 2000
Location: Stoneham, MA, USA
Status: Offline
Reply With Quote
May 14, 2012, 04:52 AM
 
I am replacing my G5 (10.5) Xserve with a late 2008 Xserve (10.6). This server is primarily a web server, with a small amount of mail traffic.

I keep my 'webfolder' on a RAM disk. All of my pages are dymanic php/mysql, so they can't be cached. But reading from RAM is so fast, you'd never know it.

This is the command I used in 10.5 to create a 1 GB RAM disk at boot:
Code:
/usr/sbin/diskutil erasevolume HFS+ "web-ram" `/usr/bin/hdiutil attach -notremovable -nomount ram://2200000`
Not the "notremovable", that flag makes the system treat the mounted disk image (or in this case, the RAM disk), like a real physical disk, and not a mounted disk image. When you use this flag, the ram disk will actually show up with a regular hard drive icon. Without this flag, it shows up as a white disk image.

But this flag doesn't work in 10.6. According to the man page, it's still there. But when I use it, I get permissions errors. I am using it with sudo (from the command line, or as root via lanuchdeamons). As I look closer at my errors, It appears that what might be happening is that the diskutil command is being run as root, but the hdiutil command inside of it, is not.

Anyway this is about more than just the icon. When the ram disk is mounted as a real disk, its harder to eject, which is good because it's my web folder and I don't want it going anywhere. AND when its mounted that way, I can use time machine to back it up. Which works out to be a great system for that.
     
P
Moderator
Join Date: Apr 2000
Location: Gothenburg, Sweden
Status: Offline
Reply With Quote
May 14, 2012, 05:09 AM
 
What happens if you set the setuid flag on the hdiutil executable?
The new Mac Pro has up to 30 MB of cache inside the processor itself. That's more than the HD in my first Mac. Somehow I'm still running out of space.
     
l008com  (op)
Addicted to MacNN
Join Date: Jan 2000
Location: Stoneham, MA, USA
Status: Offline
Reply With Quote
May 14, 2012, 05:58 AM
 
I just read through it's man page and I didn't see any setuid flags?
     
P
Moderator
Join Date: Apr 2000
Location: Gothenburg, Sweden
Status: Offline
Reply With Quote
May 14, 2012, 06:45 AM
 
No, I mean in the modbits. Setuid is a flag that lets a certain executable run as the owner of the file, no matter who starts it. If the hdiutil is owned by root and the setuid flag is set, it will always execute with root privileges. Note that this may or may not solve your problem, because the executable could simply be dropping to a lower privilege level as a matter of security, but it's worth a shot.

First backup, just in case. Then check the status of the file so you can undo any changes as required. To check, navigate to the hdiutil command in the terminal and make a long list (ls -l). Check the owner and the permissions for the hdiutil command. If the setuid (or setgid) bit is set, there will be an s instead of an x in the permissions - like this:

rwsr-xr-x

One possible root cause is that the setuid bit is set, but that the owner is not root. If the owner is not root, change the owner to root with chown (sudo chown root:wheel hdiutil) and then set the setuid bit with chmod u+s hdiutil.
The new Mac Pro has up to 30 MB of cache inside the processor itself. That's more than the HD in my first Mac. Somehow I'm still running out of space.
     
l008com  (op)
Addicted to MacNN
Join Date: Jan 2000
Location: Stoneham, MA, USA
Status: Offline
Reply With Quote
May 14, 2012, 03:54 PM
 
It is owned by root / wheel. The permissions are "-rwxr-xr-x" I'll set the setuid bit and see if that has any effect.
     
l008com  (op)
Addicted to MacNN
Join Date: Jan 2000
Location: Stoneham, MA, USA
Status: Offline
Reply With Quote
May 14, 2012, 03:59 PM
 
Nope still no luck. I get a different error, but still I only get it when "-notremovable" is set.

Code:
Started erase on disk6 Unmounting disk Erasing newfs_hfs: write (sector 0): Cannot allocate memory Mounting disk Could not mount disk6 with name (null) after erase Error: -9944: File system formatter failed
     
l008com  (op)
Addicted to MacNN
Join Date: Jan 2000
Location: Stoneham, MA, USA
Status: Offline
Reply With Quote
May 14, 2012, 04:00 PM
 
Also, how do I unset that setuid bit with chmod?
     
l008com  (op)
Addicted to MacNN
Join Date: Jan 2000
Location: Stoneham, MA, USA
Status: Offline
Reply With Quote
May 14, 2012, 04:08 PM
 
It looks like I want to be using `hdid` in 10.6, not `hdiutil`. I'll have to read more to see exactly how to make this script work.
     
P
Moderator
Join Date: Apr 2000
Location: Gothenburg, Sweden
Status: Offline
Reply With Quote
May 14, 2012, 05:29 PM
 
Originally Posted by l008com View Post
Also, how do I unset that setuid bit with chmod?
chmod u-s hdiutil
The new Mac Pro has up to 30 MB of cache inside the processor itself. That's more than the HD in my first Mac. Somehow I'm still running out of space.
     
l008com  (op)
Addicted to MacNN
Join Date: Jan 2000
Location: Stoneham, MA, USA
Status: Offline
Reply With Quote
May 15, 2012, 07:03 PM
 
I'm getting nowhere fast with this search.

Aside from using Time Machine to back up the ram disk, the other reason I need the notremovable option is this: Removable media is ejected BEFORE shutdown scripts are run. Not Removable media is not. So my RAM disk is gone before my shutdown script can save it's contents.
     
l008com  (op)
Addicted to MacNN
Join Date: Jan 2000
Location: Stoneham, MA, USA
Status: Offline
Reply With Quote
May 15, 2012, 07:05 PM
 
But I'm starting to suspect that the problem isn't with `hdiutil` after all. It seems like the problem is that `newfs_hfs` can't seem to write to a RAM disk to format it, when it's created as a not removable disk.
     
l008com  (op)
Addicted to MacNN
Join Date: Jan 2000
Location: Stoneham, MA, USA
Status: Offline
Reply With Quote
May 15, 2012, 11:34 PM
 
I just tested it for the hell of it. This command works in 10.5, 10.7 and 10.8 to create a nonremovable ram disk aka a ram disk that mounts like a hard drive on your desktop. Only 10.6 seems to have this bug.
     
P
Moderator
Join Date: Apr 2000
Location: Gothenburg, Sweden
Status: Offline
Reply With Quote
May 16, 2012, 07:50 AM
 
Then it's clearly a bug. What happens if you copy one of the utilities from 10.7?
The new Mac Pro has up to 30 MB of cache inside the processor itself. That's more than the HD in my first Mac. Somehow I'm still running out of space.
     
l008com  (op)
Addicted to MacNN
Join Date: Jan 2000
Location: Stoneham, MA, USA
Status: Offline
Reply With Quote
May 16, 2012, 02:26 PM
 
I haven't tried that yet. I could potentially try copying the framework from 10.7 or 10.5. But I want to see if theres a "better" solution that comes up before I start messing around with that stuff. I don't want to end up breaking something that becomes very hard to fix once this server is in a data center 1000 miles away.
     
l008com  (op)
Addicted to MacNN
Join Date: Jan 2000
Location: Stoneham, MA, USA
Status: Offline
Reply With Quote
May 16, 2012, 10:52 PM
 
I've been thinking about the idea of trying to get 10.5 or 10.7's image framework to run in 10.6 all day, and I've decided I'm not even going to try. The risk of having some obscure software update interfere with something as vital as my webserver's web folder isn't worth it. If I can't get this working natively in 10.6, I'll just go the old fashioned route and stick the web folder on the hard disk drive. I am using APC cacher which should help in times of extreme traffic any way. I'd rather do it that way and have it be more stable and reliable, vs getting a different OS's framework working, then forget all about it, then run some software updates, then have no web sites.
     
Fresh-Faced Recruit
Join Date: Jul 2012
Status: Offline
Reply With Quote
Jul 11, 2012, 08:04 AM
 
Hi,

I sucessfully created a notremovable ramdisk by adding the option -kernel when using the tool hdid. Tested on Mac OS X 10.6.8.

Cheers,
snow-punk

see also: https://discussions.apple.com/message/18652360#18652360
     
l008com  (op)
Addicted to MacNN
Join Date: Jan 2000
Location: Stoneham, MA, USA
Status: Offline
Reply With Quote
Jul 11, 2012, 10:30 AM
 
Yeah that's my thread too
Adding -kernel doesn't make it truly nonremovable. It's more of a weird hybrid.
     
Posting Junkie
Join Date: Oct 2005
Location: Houston, TX
Status: Offline
Reply With Quote
Jul 11, 2012, 03:03 PM
 
Shouldn't the OS take care of caching frequently accessed files in RAM?
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -4. The time now is 08:43 PM.
All contents of these forums © 1995-2014 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2014, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2