From: Andrew Schoen Date: Thu, 19 Oct 2017 16:44:11 +0000 (-0500) Subject: ceph-volume: adds utilites to wipe the fs and clear data when zapping X-Git-Tag: v13.0.1~367^2~10 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2f64d4a0abd41afbcb9eba6a237642502d9a9135;p=ceph.git ceph-volume: adds utilites to wipe the fs and clear data when zapping These should eventually move to a disk api. Signed-off-by: Andrew Schoen --- diff --git a/src/ceph-volume/ceph_volume/devices/lvm/zap.py b/src/ceph-volume/ceph_volume/devices/lvm/zap.py index df44753d93e8..e8dfb5eec2cf 100644 --- a/src/ceph-volume/ceph_volume/devices/lvm/zap.py +++ b/src/ceph-volume/ceph_volume/devices/lvm/zap.py @@ -3,12 +3,41 @@ import logging from textwrap import dedent -from ceph_volume import decorators, terminal +from ceph_volume import decorators, terminal, process from ceph_volume.api import lvm as api logger = logging.getLogger(__name__) +def wipefs(path): + """ + Removes the filesystem from an lv or partition. + """ + process.run([ + 'sudo', + 'wipefs', + '--all', + path + ]) + + +def zap_data(path): + """ + Clears all data from the given path. Path should be + an absolute path to an lv or partition. + + 10M of data is written to the path to make sure that + there is no trace left of any previous Filesystem. + """ + process.run([ + 'dd', + 'if=/dev/zero', + 'of={path}'.format(path=path), + 'bs=1M', + 'count=10', + ]) + + class Zap(object): help = 'Destroy a logical volume or partition.'