MacOSXRAMDisk (memory disk) Shell
This article provides the ghost version of Mac OS X RAM Disk (memory Disk) Creation Program and practical instructions.
Concerns
When Mac thunder downloads, The IOPS is too high. It may be because the cache is not used, which causes the disk to crash. Therefore, we are worried that the disk will soon be decommissioned and cannot download it safely. The author has proposed to the developer for many times, but has not received a reply so far.
Fortunately, the memory space of the local machine is plentiful, and the concept of memory disk suddenly comes to mind.
Exploration
I tried TmpDisk for a while, and the effect was okay. However, you may find that on the activity monitor/disk page, the data written by the TmpDisk process is more than twice the actual data written. For example, if the download speed is 10 MB, it is expected that 1 MIB/s ~ will be written continuously ~ 1.25MiB/s, but the continuous write of TmpDisk reaches 3MiB/s ~ 4MiB/s.
Later, I referred to the Eyon article [Create RamDisk in Mac OS X as the cache directory] [1] and extracted the Shell program described in method 2 in this article, the following Shell utility is developed based on continuous improvement. Share now:
Share
1. Code the following code
#!/bin/sh# usage: $ramdisk.sh [capacity=4] [label=RamDisk]# default capacity=4(gb)capacity=4if [ "$1" != "" ]; thencapacity=$1fi# default label="RamDisk"label="RamDisk"if [ "$2" != "" ]; thenlabel="$2"fi# echo "capacity=$capacity\nlabel=$label"# 1(capacity)=2097152(ram)ram=$(($capacity*2097152))if ! test -e "/Volumes/$label" ; then diskutil erasevolume HFS+ "$label" `hdiutil attach -nomount ram://$ram`fi
2. Installation
Save the file to/usr/local/bin/ramdisk. sh and enable the execution permission.
$ Chmod 755/usr/local/bin/ramdisk. sh
3. Use
By default, a memory disk with a volume marked as RamDisk is created.
$ramdisk.sh
Create an 8 GB memory disk marked as TmpDisk
$ramdisk.sh 8 TmpDisk
4. Automation
To automatically create a memory disk after logging on to the system, perform the following steps:
A. Change the default memory size to a proper number based on the physical memory.
B. Open System preference settings, select users and groups, current users, and logon items. Add the previously created ramdisk. sh Shell program to the list.