Two ways to create RAM disks

May 30, '02 08:46:07AM

Contributed by: bombich

Creating a RAM disk was easy in 9, and, until now, "undocumented" in X. There is a utility called ramBunctious that brings this functionality back to X (well, at least it puts a GUI on it).

Rambunctious has excellent documentation on the state of RAM disks in X and when you should/should not use them. The reason I mention it here is because it could have a huge positive impact on the functionality of a bootable X CD.

Read the rest of the article if you'd like to know how to create your own RAM disk from the command line...

For those of you interested in how this works from the command line, it's pretty simple. First, create a read/write disk image (you can do this in Disk Copy). Next, create the /dev entry for RAM using the hdid tool. Finally, copy the contents of the disk image to the RAM /dev entry and mount it. Because the disk image is mounted from the /dev entry, any changes occur in RAM. Here are the Terminal commands:

First, calculate the number of 512K blocks you need: numblocks = (image size in MB) * 2048; for example: 5MB = 10240 blocks. Open a terminal and type:

% hdid -nomount ram://numblocks
[result: /dev/disk1]
Replace numblocks with the number you calculated in the first step. Next type:
% dd if=/path/to/image/file.dmg of=/dev/disk1 bs=512
[result:2866+0 records in
2866+0 records out
1467392 bytes transferred in 1 secs (1467392 bytes/sec)]
% hdiutil mount /dev/rdisk1
You need to change the "1" in disk1 and rdisk1 to whatever number is returned by the first command.

[Editor's note: I have not tried this myself.]

Comments (24)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20020530084607311