Created
August 5, 2011 06:48
-
-
Save shokai/1127041 to your computer and use it in GitHub Desktop.
mount ramdisk on Mac OSX
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
mount = '/Volumes/ramdisk' | |
newfs = '/dev/disk1' | |
if !ARGV.empty? and ARGV.first =~ /^-+u$/i | |
system "umount #{mount} && hdiutil detach #{newfs}" | |
else | |
if File.exists? newfs | |
STDERR.puts "already mounted - #{mount}" | |
STDERR.puts "use \"#{$0.split('/').last} -u\"" | |
exit 1 | |
end | |
size = 200000 | |
size = ARGV.first.to_i if !ARGV.empty? and ARGV.first =~ /^\d+$/ | |
puts "mount RAM #{size*512} bytes" | |
Dir.mkdir mount unless File.exists? mount | |
system "hdid -nomount ram://#{size} && newfs_hfs #{newfs} && mount -t hfs #{newfs} #{mount}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment