Skip to content

Instantly share code, notes, and snippets.

@shadeslayer
Created August 12, 2015 23:12
Show Gist options
  • Save shadeslayer/5d1cfcdf4bcddf3ae11d to your computer and use it in GitHub Desktop.
Save shadeslayer/5d1cfcdf4bcddf3ae11d to your computer and use it in GitHub Desktop.
Mount things inside of other things
require 'tmpdir'
class Mount
def self.mount(path)
@mntdir = Dir.mktmpdir
fail 'Mounting boot partition failed!' unless system('sudo',
'mount',
path,
@mntdir)
puts "Mounted #{path} on #{@mntdir}"
yield @mntdir
ensure
puts "Unmounting #{path}"
system('sudo',
'umount',
@mntdir)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment