Project

General

Profile

Feature #3344

ceph-disk-prepare?: provide some sort of tool to clear out a disk, with prejudice

Added by Anonymous over 11 years ago. Updated about 11 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
% Done:

0%

Source:
Tags:
Backport:
Reviewed:
Affected Versions:
Pull request ID:

Description

"sgdisk --zap-all --clear" just doesn't clear out all the possible funky states a disk may be in.

A simple "dd if=/dev/zero of=/dev/sdX" is enough, but writes the whole disk.

Trying to limit the dd with count of blocks only overwrites the first copy of the GPT data, just making the tools use the copy that is near the end of the disk.

Figure out how to wipe out a disk reliably.

History

#1 Updated by Anonymous over 11 years ago

Ideally, sgdisk would be made reliable. This might be good enough to be a useful workaround: in ceph-disk-prepare, just before calling sgdisk --zap, run:

import os

def zap_backup_gpt(dev, lba_size=4096):
    """ 
    Wipe out the backup GPT on disk `dev`.

    Overwrites last 33 LBAs of the disk with zero. Real world LBA is
    normally 512 bytes, but to be safe we're going to default to 4k
    sectors here, which means we typically overwrite more than
    necessary, but still not too much for it to be slow.

    Caution: This erases data!
    """ 
    size = 33 * lba_size
    with file(dev, 'wb') as f:
        f.seek(-size, os.SEEK_END)
        f.write(size*'\0')

#2 Updated by Sage Weil over 11 years ago

  • translation missing: en.field_position set to 32

#3 Updated by Sage Weil about 11 years ago

  • Status changed from New to Resolved

added a whiel back, commit:b2ff6e8c9d96dee2c063b126de7030a5c2ae0d02

Also available in: Atom PDF