Skip to content

Instantly share code, notes, and snippets.

@aldavud
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aldavud/e5e2f47234135fe193b3 to your computer and use it in GitHub Desktop.
Save aldavud/e5e2f47234135fe193b3 to your computer and use it in GitHub Desktop.
def zap(dev)
# try to wipe out any GPT partition table backups.
# sgdisk isn't too thorough.
lba_size = 4096
size = 33 * lba_size
begin
dev_file = open(dev, 'wb'):
dev_file.seek(-size, IO::SEEK_END)
dev_file.write("\0" * size)
ensure
dev_file.close
end
`sgdisk --zap-all --clear --mbrtogpt -- #{dev}`
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment