2
from stat import S_ISBLK
4
from subprocess import (
9
def is_block_device(path):
11
Confirm device at path is a valid block device node.
13
:returns: boolean: True if path is a block device, False if not.
15
return S_ISBLK(stat(path).st_mode)
18
def zap_disk(block_device):
20
Clear a block device of partition table. Relies on sgdisk, which is
21
installed as pat of the 'gdisk' package in Ubuntu.
23
:param block_device: str: Full path of block device to clean.
25
check_call(['sgdisk', '--zap-all', '--clear',
26
'--mbrtogpt', block_device])