Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Manually mount HFS shares on OSX
#!/usr/bin/env ruby
require 'fileutils'
MOUNTZ = %w(
some-server.company.local:/mnt/raiddisk/commercial /mnt/commercial
)
SERVERS = Hash[*MOUNTZ]
MAGIC_OPTS = %w( soft resvport intr rsize=8192 wsize=8192 timeo=900 retrans=3 proto=tcp )
def unmount
SERVERS.each_value do | mountpoint |
`sudo umount #{mountpoint}`
# Make sure the mountpoint is removed for the next launch
FileUtils.rmdir(mountpoint) if File.exist?(mountpoint)
end
end
def mount
unmount
SERVERS.each_pair do | host, mountpoint |
FileUtils.mkdir_p(mountpoint)
# Make sure its mega-writable
File.chmod(0777, mountpoint)
`sudo mount -t nfs -o #{MAGIC_OPTS.join(',')} #{host} #{mountpoint}`
end
end
if ARGV.to_s.include?("unmount")
unmount
else
unmount
mount
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.