Mac Share Memory

hdiutil

Example

创建一个1024MB的ramdisk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# 返回一个ramdisk路径,假设返回的路径是 /dev/disk3
# hdiutil attach -nomount ram://$((2 * 1024 * SIZE_IN_MB))
hdiutil attach -nomount ram://$((2 * 1024 * 1024))

# 格式化
# diskutil eraseVolume HFS+ RAMDisk NAME_OF_DISK
# 访问路径:/Volumes/RAMDisk
diskutil eraseVolume HFS+ RAMDisk /dev/disk3

# 命令执行输出样例
# Started erase on disk3
# Unmounting disk
# Erasing
# Initialized /dev/rdisk3 as a 1024 MB case-insensitive HFS Plus volume
# Mounting disk
# Finished erase on disk3 RAMDisk