Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Great news! Plus an easier way.' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Great news! Plus an easier way.
Authored by: Anonymous on May 30, '02 01:44:50PM
This is fantastic. Good work.

I've found (based on bombich's findings) easier ways of doing this.

Easiest way: from the terminal, run the command:
hdid ram://disksize
In the finder, a message pops up "This disk is unreadable"
Click "Initialize..." and then use disk utility to format the new ram disk you've created. Now just drag files onto the ram disk that you need.

Here's an all-terminal way of doing the same: (output is in bold).
hdid -nomount ram://disksize
/dev/diskN
newfs_hfs /dev/rdiskN
Initialized /dev/rdiskN as a [disksize]MB HFS Plus volume
hdiutil mount /dev/diskN


where N is the disk number returned by hdid in step 1.
Note the change to rdiskN from disk in in the newfs step: this is because rdisks are "raw disks" that can be formatted.
/dev/disk entries are only useful after the corresponding raw entry has been formatted.

Note that I have had problems in getting the ram disks to actually go away after ejecting them in the finder. On a few occasions I have had to use Disk Utility to eject the ram disks, even though their icons were gone after I "ejected" them from within the finder.

[ Reply to This | # ]
Great news! Plus an easier way.
Authored by: deleted_user17 on May 30, '02 04:36:32PM

There is no point for a RAM disk in a Virtual Memory System like OS X!



[ Reply to This | # ]
Great news! Plus an easier way. BUT...
Authored by: cleofus on May 30, '02 04:58:15PM

It is true that in a high speed virtual memory system there is no NEED for a RAM disk, but there is a USE for one! I still turn my Mac off when I'm not home (where it is) so I use a RAM disk for my cache for Netscape or IE. That way when I turn the computer off, my cache simply dissappears instead of remaining on the machine. When you create a RAM disk, you can point your cache to that "disk" and then the cache will run at RAM speeds, which is still faster than the virtual memory that ANY system has, and it will not stay with the computer and eventually need clearing out. If you simply quit Netscape or IE, you can clear it out manually (or with some script) as well as the history, and any other database that gets created whenever you run the web browsers. So for a security reason, it is easier to delete lots of unwanted tracking files with a RAM disk.



[ Reply to This | # ]
Great news! Plus an easier way. BUT...
Authored by: geohar on May 31, '02 04:41:39AM

I see the point for killing the IE cache, but, it might well not be faster than doing it other ways. The point is, that all file i/o in unix is buffered via memory. This is done in such a way that with a good quantity of ram, the disk is very rarely written to. The vm system takes care of paging the 'dirty' file buffers to disk. I very much doubt if in osx the ram disk gets guaranteed ram residency. Therefore, when the system has need for extra pages, it too will be paged out to disk (and will sit there until paged in again). I may be wrong, but I think the only non-pagable part of the memory will be a set of core kernel code.

Cool hint though. I've been asked that a couple of times and couldn't work it out.



[ Reply to This | # ]
Great news! Plus an easier way.
Authored by: robh on May 30, '02 06:22:25PM

Ram disks improve efficiency enormously for applications that manipulate hundreds or thousands of temporary files, when disk I/O becomes a bottleneck due to the limited hardware bandwidth.



[ Reply to This | # ]
There is no point???
Authored by: paulio on May 31, '02 01:56:33PM
Just startup in single user mode (command-s at startup) and try using the man command:
man ls
You will get an error message because /tmp is not writable. This is the perfect time for a ramdisk. Linux does this for installation and for a bootable CD.

[ Reply to This | # ]
There is no point???
Authored by: sjk on Jun 03, '02 07:16:21PM

/tmp and /var/run are candidates to mount as RAM disks.



[ Reply to This | # ]
Sad news! UMA still has no bootable/persistent RAMDISKS!
Authored by: Anonymous on May 30, '02 07:44:36PM

Some while ago , Apple started using cheap memory parts -- and thus obsoleted a VERY cool feature that has been an essential life-saver many times when a system became toally unbootable otherwise (from cdrom or dasd or zipdisk) ...

namely a persistent/bootable ramdisk!

it is a shame that apple cant restore thi feature, considering the premium they charge over comodity hardware!

not the fault of rambunctios at all.



[ Reply to This | # ]
Sad news! UMA still has no bootable/persistent RAMDISKS!
Authored by: THEM on May 30, '02 11:27:37PM

I thought it was because the newer memory systems lose contents a lot faster when not getting power than the old memory. Not "cheaper" parts.



[ Reply to This | # ]
Sad news! UMA still has no bootable/persistent RAMDISKS!
Authored by: geohar on May 31, '02 04:47:18AM

I'm fairly certain that bootable ram disks were never preserved in ram over a shutdown. Instead, they got written to disk and read back into ram at startup by bootstrap code. I remember seeing the files (invisible on early SE/ Plus systems). New ram technology does loose information faster than old technology, but then its also faster to access and bigger capacity and higher bandwidth. And whilst it is cheaper than ram used to be this is due to increased quality production processes (which create higher chip yeild, and hence are lower overhead in terms of cost) and because ram is comoditized (and the market has surplus - remember when a fire in Japan wiped out a whole crop, ram went ceiling high then).



[ Reply to This | # ]
Great news! Plus an easier way.
Authored by: vonleigh on May 31, '02 04:22:43AM

That's a really easy way to make the ram disk, only one command (hdid ram://disksize). Couple of questions though

1. In what format is the size? I put in 50 and it created a 25KB image.
2. How do you remove it once you're done? I used hdid eject /dev/disk3 (what the first command gave back).


Vonleigh



[ Reply to This | # ]
Great news! Plus an ApleScript way!!
Authored by: dashard on May 31, '02 04:23:35PM
I took the hints from 'zpincus' and modified them to AppleScript.
Here's what I came up with (you may have to reformat the script from the copy/paste).
tell application "Finder"
activate
display dialog "This script will create a RAM Disk on your desktop.
How many megabytes would you like it to be?" default answer "" buttons {"OK", "Cancel"} default button 1
set diskSize to (text returned of the result)
set diskSize to diskSize * 2048
do shell script "hdid -nomount ram://" & diskSize
set dskImg to the result

set prevTextDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to {"/"}
set myDevDisk to the last text item of dskImg
log result
set myShellCmd to "/sbin/newfs_hfs /dev/r" & myDevDisk as text
do shell script myShellCmd
display dialog result
do shell script "hdiutil mount /dev/" & myDevDisk
set AppleScript's text item delimiters to prevTextDelims
end tell

Hope it works for you.
For those of you who may have been getting an error at the 'new_hfs'... part, I added the full path to the command, as mine was giving me an error.

Please also note that you will very likely have to unmount the disk from the Disk Utility. It disappeared fine from my desktop with the drag-to-trash method, but didn't really go away. FWIW.

Feel free to email me with questions.
Enjoy.

[ Reply to This | # ]
AppleScript To Create RAM Disks
Authored by: nick2588 on May 31, '02 04:26:47PM
You can download an AppleScript Application to create a RAM Disk at my web site:
http://homepage.mac.com/nick2588/

It is pretty much uses the code above, but an AppleScript is nice because it is all automated. :)

[ Reply to This | # ]
Great news! Plus an easier way.
Authored by: GaelicWizard on Jun 01, '02 08:29:15PM

this is a great tip, but here's my problem:
how can I make this all happen automatically?
and not with an applescript, from the command line. I want to make this happen at boot, so I can set my browsers to default ot this and so I can build on it all without having to do it manually beforehand.
Thanx in advance.

JP



[ Reply to This | # ]
UNIX script --This is what happens when i'm REALLY bored.
Authored by: GaelicWizard on Jun 02, '02 01:55:59AM

Me again, I answered my own question. I don't know how efficient it is, but here's my script:


#!/bin/sh

echo -n "/dev/r" > /tmp/RamDisk.raw
hdid -nomount ram://10240 | awk -F / '{print $3}' > /tmp/RamDisk
cat /tmp/RamDisk >> /tmp/RamDisk.raw
newfs_hfs `cat /tmp/RamDisk.raw`
echo -n "/dev/" > /tmp/RamDisk.mount
cat /tmp/RamDisk >> /tmp/RamDisk.mount
hdiutil mount `cat /tmp/RamDisk.mount`



obviously, replace the 10240 with the size you want for your disk.

JP



[ Reply to This | # ]
UNIX script --This is what happens when i'm REALLY bored.
Authored by: robh on Jun 03, '02 09:28:03AM
I've made a Perl script to call the necessary commands: download it here Unlike the other suggestions so far, this one also lets you specify the name of the disk and does some error simple error checking. Usage: ramdisk MB_size [name] e.g. ramdisk 10 mydisk ramdisk 20 If you don't give a name, it defaults to "untitled".

[ Reply to This | # ]