OSX 创建 randisk(或称 tmpfs)

创建步骤:

#!/bin/bash

ramdisk_size_in_mb=24000
mount_point=/private/tmp
 
ramdisk_size_in_sectors=$((${ramdisk_size_in_mb}*1024*1024/512))
 
ramdisk_dev_file=`hdid -nomount ram://${ramdisk_size_in_sectors}`
newfs_hfs -v 'Ramdisk' ${ramdisk_dev_file}
mkdir -p ${mount_point}
mount -o rw,noatime,nobrowse -t hfs ${ramdisk_dev_file} ${mount_point}
chown root:wheel ${mount_point}
chmod 1777 ${mount_point}

开机自启:

sh-3.2# cat /Library/LaunchDaemons/com.none.randisk.plist 

"1.0" encoding="UTF-8"?>
"-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
"1.0">
    
        Label
        <string>com.emitial.ramdiskstring>
        ProgramArguments
        
            <string>/var/root/ramdisk.shstring>
        
        RunAtLoad
        <true/>
    

 

你可能感兴趣的:(OSX 创建 randisk(或称 tmpfs))