]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
ceph-disk: Write 10M to all partitions before zapping
authorWido den Hollander <wido@42on.com>
Thu, 16 Feb 2017 21:53:51 +0000 (22:53 +0100)
committerLoic Dachary <ldachary@redhat.com>
Wed, 8 Mar 2017 11:20:49 +0000 (12:20 +0100)
By writing 10M of zeroes to each partition of the device we prevent that
old data causes troubles if exactly the same partition scheme is created
on the disk again and is read by the OSD.

This mainly involves the OSD's journal which will contain data from the
previous OSD and results in a assert of the OSD.

Fixes: http://tracker.ceph.com/issues/18962
Signed-off-by: Wido den Hollander <wido@42on.com>
src/ceph-disk/ceph_disk/main.py

index 4a5e1af518a7b4bc58134baf248bba0aba48e480..9137e1843cb37ec45e844b457afc42330c04daae 100755 (executable)
@@ -1519,6 +1519,36 @@ def zap(dev):
     if not stat.S_ISBLK(dmode) or is_partition(dev):
         raise Error('not full block device; cannot zap', dev)
     try:
+        # Thoroughly wipe all partitions of any traces of
+        # Filesystems or OSD Journals
+        #
+        # In addition we need to write 10M of data to each partition
+        # to make sure that after re-creating the same partition
+        # there is no trace left of any previous Filesystem or OSD
+        # Journal
+
+        LOG.debug('Writing zeros to existing partitions on %s', dev)
+
+        for partname in list_partitions(dev):
+            partition = get_dev_path(partname)
+            command_check_call(
+                [
+                    'wipefs',
+                    '--all',
+                    partition,
+                ],
+            )
+
+            command_check_call(
+                [
+                    'dd',
+                    'if=/dev/zero',
+                    'of={path}'.format(path=partition),
+                    'bs=1M',
+                    'count=10',
+                ],
+            )
+
         LOG.debug('Zapping partition table on %s', dev)
 
         # try to wipe out any GPT partition table backups.  sgdisk