Joey Boggs
2010-Feb-16 21:14 UTC
[Ovirt-devel] [PATCH node] remove secondary gpt header and create drive wiping function
--- scripts/ovirt-config-storage | 6 ++---- scripts/ovirt-config-uninstall | 1 + scripts/ovirt-functions | 11 +++++++++++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/scripts/ovirt-config-storage b/scripts/ovirt-config-storage index 9c3f773..f4f7e1e 100755 --- a/scripts/ovirt-config-storage +++ b/scripts/ovirt-config-storage @@ -415,8 +415,7 @@ perform_partitioning() if [ "$OVIRT_ISCSI_ENABLED" == "y" ]; then log "Partitioning drive: $BOOTDRIVE" - log "Wiping old boot sector" - dd if=/dev/zero of=$BOOTDRIVE bs=1024K count=1 + wipe_partitions $BOOTDRIVE blockdev --rereadpt $BOOTDRIVE partprobe -s $BOOTDRIVE log "Creating boot partition" @@ -434,8 +433,7 @@ perform_partitioning() log "Starting partitioning of $ROOTDRIVE" log "Partitioning drive: $ROOTDRIVE" # FIXME: save a backup copy, just in case? - log "Wiping old boot sector" - dd if=/dev/zero of=$ROOTDRIVE bs=1024K count=1 + wipe_partitions $ROOTDRIVE blockdev --rereadpt $ROOTDRIVE partprobe -s $ROOTDRIVE log "Labeling Drive: $ROOTDRIVE" diff --git a/scripts/ovirt-config-uninstall b/scripts/ovirt-config-uninstall index 820eead..f79d31c 100755 --- a/scripts/ovirt-config-uninstall +++ b/scripts/ovirt-config-uninstall @@ -41,6 +41,7 @@ if ask_yes_or_no "Do you wish to continue and uninstall this node ([Y]es/[N]o)?" parted -s $drive "rm 1" parted -s $drive "rm 2" parted -s $drive "rm 3" + wipe_partitions $drive fi printf "Finished uninstalling node." else diff --git a/scripts/ovirt-functions b/scripts/ovirt-functions index fae13e7..3959e85 100644 --- a/scripts/ovirt-functions +++ b/scripts/ovirt-functions @@ -745,6 +745,17 @@ test_ntp_configuration () { service ntpd start } +# Cleans partition tables +wipe_partitions() { + local drive=$1 + log "Wiping old boot sector" + dd if=/dev/zero of=$drive bs=1024K count=1 + # zero out the GPT secondary header + log "Wiping secondary gpt header" + local disk_kb_count=$(sfdisk -s $drive 2>/dev/null) + dd if=/dev/zero of=$drive bs=1024 seek=$(($disk_kb_count - 1)) count=1 +} + # execute a function if called as a script, e.g. # ovirt-functions ovirt_store_config /etc/hosts -- 1.6.6
Darryl L. Pierce
2010-Mar-03 20:38 UTC
[Ovirt-devel] [PATCH node] remove secondary gpt header and create drive wiping function
On Tue, Feb 16, 2010 at 04:14:41PM -0500, Joey Boggs wrote:> --- > scripts/ovirt-config-storage | 6 ++---- > scripts/ovirt-config-uninstall | 1 + > scripts/ovirt-functions | 11 +++++++++++ > 3 files changed, 14 insertions(+), 4 deletions(-) > > diff --git a/scripts/ovirt-config-storage b/scripts/ovirt-config-storage > index 9c3f773..f4f7e1e 100755 > --- a/scripts/ovirt-config-storage > +++ b/scripts/ovirt-config-storage > @@ -415,8 +415,7 @@ perform_partitioning() > > if [ "$OVIRT_ISCSI_ENABLED" == "y" ]; then > log "Partitioning drive: $BOOTDRIVE" > - log "Wiping old boot sector" > - dd if=/dev/zero of=$BOOTDRIVE bs=1024K count=1 > + wipe_partitions $BOOTDRIVE > blockdev --rereadpt $BOOTDRIVE > partprobe -s $BOOTDRIVE > log "Creating boot partition" > @@ -434,8 +433,7 @@ perform_partitioning() > log "Starting partitioning of $ROOTDRIVE" > log "Partitioning drive: $ROOTDRIVE" > # FIXME: save a backup copy, just in case? > - log "Wiping old boot sector" > - dd if=/dev/zero of=$ROOTDRIVE bs=1024K count=1 > + wipe_partitions $ROOTDRIVE > blockdev --rereadpt $ROOTDRIVE > partprobe -s $ROOTDRIVE > log "Labeling Drive: $ROOTDRIVE" > diff --git a/scripts/ovirt-config-uninstall b/scripts/ovirt-config-uninstall > index 820eead..f79d31c 100755 > --- a/scripts/ovirt-config-uninstall > +++ b/scripts/ovirt-config-uninstall > @@ -41,6 +41,7 @@ if ask_yes_or_no "Do you wish to continue and uninstall this node ([Y]es/[N]o)?" > parted -s $drive "rm 1" > parted -s $drive "rm 2" > parted -s $drive "rm 3" > + wipe_partitions $drive > fi > printf "Finished uninstalling node." > else > diff --git a/scripts/ovirt-functions b/scripts/ovirt-functions > index fae13e7..3959e85 100644 > --- a/scripts/ovirt-functions > +++ b/scripts/ovirt-functions > @@ -745,6 +745,17 @@ test_ntp_configuration () { > service ntpd start > } > > +# Cleans partition tables > +wipe_partitions() { > + local drive=$1 > + log "Wiping old boot sector" > + dd if=/dev/zero of=$drive bs=1024K count=1 > + # zero out the GPT secondary header > + log "Wiping secondary gpt header" > + local disk_kb_count=$(sfdisk -s $drive 2>/dev/null) > + dd if=/dev/zero of=$drive bs=1024 seek=$(($disk_kb_count - 1)) count=1 > +} > + > # execute a function if called as a script, e.g. > # ovirt-functions ovirt_store_config /etc/hosts > > -- > 1.6.6 > > _______________________________________________ > Ovirt-devel mailing list > Ovirt-devel at redhat.com > https://www.redhat.com/mailman/listinfo/ovirt-develACK. -- Darryl L. Pierce, Sr. Software Engineer @ Red Hat, Inc. Delivering value year after year. Red Hat ranks #1 in value among software vendors. http://www.redhat.com/promo/vendor/ -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: not available URL: <http://listman.redhat.com/archives/ovirt-devel/attachments/20100303/7798582a/attachment.sig>