macos OS X 是否与 /dev/shm 等效?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2033362/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Does OS X have an equivalent to /dev/shm?
提问by Andrew Grimm
Does OS X (Snow Leopard in particular) have an equivalent to (some versions of) Linux's /dev/shm
, ie something where you can write to and read from a file without necessarily touching the hard drive?
OS X(特别是Snow Leopard)是否与(某些版本的)Linux 等效/dev/shm
,即您可以在不接触硬盘驱动器的情况下写入和读取文件的东西?
回答by adamse
You can create and mount a ram based disk as follows:
您可以创建和挂载基于 ram 的磁盘,如下所示:
Create a disk
$ hdiutil attach -nomount ram://$((2 * 1024 * SIZE_IN_MB))
hdiutil
will return the name of the ramdisk.Format and mount the disk
diskutil eraseVolume HFS+ RAMDisk NAME_OF_DISK
Access the disk under
/Volumes/<diskname>
cd /Volumes/RAMDisk && touch testfile.txt && ls
创建磁盘
$ hdiutil attach -nomount ram://$((2 * 1024 * SIZE_IN_MB))
hdiutil
将返回 ramdisk 的名称。格式化并挂载磁盘
diskutil eraseVolume HFS+ RAMDisk NAME_OF_DISK
访问下的磁盘
/Volumes/<diskname>
cd /Volumes/RAMDisk && touch testfile.txt && ls
Creating a 100MB ramdisk:
创建一个 100MB 的 ramdisk:
$ hdiutil attach -nomount ram://$((2 * 1024 * 100))
/dev/disk3
$ diskutil eraseVolume HFS+ RAMDisk /dev/disk3
Started erase on disk3
Unmounting disk
Erasing
Initialized /dev/rdisk3 as a 100 MB case-insensitive HFS Plus volume
Mounting disk
Finished erase on disk3 RAMDisk
Original source: http://www.frederico-araujo.com/2008/12/18/blazing-fast-firefox-using-osx-ramdisk/
原始来源:http: //www.frederico-araujo.com/2008/12/18/blazing-fast-firefox-using-osx-ramdisk/