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 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
        <key>Label</key>
        <string>com.emitial.ramdisk</string>
        <key>ProgramArguments</key>
        <array>
            <string>/var/root/ramdisk.sh</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
    </dict>
</plist>

 

posted @ 2019-10-02 06:25  范辉  阅读(274)  评论(0编辑  收藏  举报