Ramdisk backup & restore on MacOS X Lion



mount |grep /Volumes/RamDisk > /dev/null
if [ $? -eq 0 ]; then
    echo saving /Volumes/RamDisk in /var/spool/rdimage
    sudo rsync -av --delete /Volumes/RamDisk/ /var/spool/rdimage/
    sudo diskutil unmount /Volumes/RamDisk



mount |grep /Volumes/RamDisk > /dev/null
if [ $? -ne 0 ]; then
    # 2GB
    sudo diskutil erasevolume HFS+ "RamDisk" `hdiutil attach -owners on -nomount ram://4194304`
    sudo diskutil enableOwnership /Volumes/RamDisk

    #restore ramdisk image from disk
    sudo rsync -a /var/spool/rdimage/ /Volumes/RamDisk/

And use it as a temporary area in Xcode etc.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.