Last active
February 9, 2020 11:24
-
-
Save erikdoe/1b501bccc87bdf43e457a8a6dfbf672f to your computer and use it in GitHub Desktop.
Mounts the EFI partition of the disk identified by the search string
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 | |
search = "*1.0 TB" | |
efimnt = "/Volumes/EFI" | |
def run(cmd, &block) | |
puts "** #{cmd}" | |
if block == nil | |
system(cmd) | |
else | |
return IO.popen(cmd, &block) | |
end | |
end | |
def efi_dev(lines, search) | |
disk = nil | |
lines.each do |line| | |
match = /#{Regexp.escape(search)}.*(disk[0-9])/.match(line) | |
if match | |
disk = match[1] | |
end | |
end | |
slice = nil | |
lines.each do |line| | |
match = /EFI.*#{disk}(s[0-9])/.match(line) | |
if match | |
slice = match[1] | |
end | |
end | |
return "/dev/#{disk}#{slice}" | |
end | |
run("mkdir #{efimnt}") | |
efidev = run("diskutil list") { |out| efi_dev(out.readlines, search) } | |
puts "found #{efidev}" | |
run("mount -t msdos #{efidev} #{efimnt}") | |
run("open #{efimnt}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment