The behavior of partprobe or sgdisk may be subtly different if given a
symbolic link to a device instead of an actual device. The debug output
is also more confusing when the symlink shows instead of the device it
points to.
Always dereference the symlink before running destroy and zap.
Signed-off-by: Loic Dachary <loic@dachary.org>
"""
Destroy the partition table and content of a given disk.
"""
+ dev = os.path.realpath(dev)
dmode = os.stat(dev).st_mode
if not stat.S_ISBLK(dmode) or is_partition(dev):
raise Error('not full block device; cannot zap', dev)
dmcrypt = False
target_dev = None
- if path and not is_partition(path):
- raise Error("It should input the partition dev!!")
+ if path:
+ if not is_partition(path):
+ raise Error(path + " must be a partition device")
+ path = os.path.realpath(path)
devices = list_devices([])
for device in devices: