From owner-svn-src-stable-10@freebsd.org Mon Mar 28 09:35:30 2016 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5E7B5ADFC17; Mon, 28 Mar 2016 09:35:30 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 357511BAC; Mon, 28 Mar 2016 09:35:30 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u2S9ZTSj005408; Mon, 28 Mar 2016 09:35:29 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u2S9ZTll005407; Mon, 28 Mar 2016 09:35:29 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201603280935.u2S9ZTll005407@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Mon, 28 Mar 2016 09:35:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r297345 - stable/10/usr.sbin/pc-sysinstall/backend X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2016 09:35:30 -0000 Author: mav Date: Mon Mar 28 09:35:29 2016 New Revision: 297345 URL: https://svnweb.freebsd.org/changeset/base/297345 Log: MFC r296655, r296673, r296776: Unify and improve metadata wiping. Modified: stable/10/usr.sbin/pc-sysinstall/backend/functions-disk.sh Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.sbin/pc-sysinstall/backend/functions-disk.sh ============================================================================== --- stable/10/usr.sbin/pc-sysinstall/backend/functions-disk.sh Mon Mar 28 09:34:14 2016 (r297344) +++ stable/10/usr.sbin/pc-sysinstall/backend/functions-disk.sh Mon Mar 28 09:35:29 2016 (r297345) @@ -257,12 +257,7 @@ delete_all_gpart() # Destroy the disk geom rc_nohalt "gpart destroy ${DISK}" - # Make sure we clear any hidden gpt tables - clear_backup_gpt_table "${DISK}" - - # Wipe out front of disk - rc_nohalt "dd if=/dev/zero of=${DISK} count=3000" - + wipe_metadata "${DISK}" }; # Function to export all zpools before starting an install @@ -292,7 +287,7 @@ stop_all_gmirror() then echo_log "Stopping mirror $gprov $DISK" rc_nohalt "gmirror remove $gprov $DISK" - rc_nohalt "dd if=/dev/zero of=/dev/${DISK} count=4096" + wipe_metadata "${DISK}" fi done }; @@ -611,12 +606,17 @@ stop_gjournal() } ; -# Function to wipe the potential backup gpt table from a disk -clear_backup_gpt_table() +# Function to wipe the potential metadata from a disk +wipe_metadata() { - echo_log "Clearing gpt backup table location on disk" - rc_nohalt "dd if=/dev/zero of=${1} bs=1m count=1" - rc_nohalt "dd if=/dev/zero of=${1} bs=1m oseek=`diskinfo ${1} | awk '{print int($3 / (1024*1024)) - 4;}'`" + echo_log "Wiping possible metadata on ${1}" + local SIZE="`diskinfo ${1} | awk '{print int($3/(1024*1024)) }'`" + if [ "$SIZE" -gt "5" ] ; then + rc_halt "dd if=/dev/zero of=${1} bs=1m count=1" + rc_nohalt "dd if=/dev/zero of=${1} bs=1m oseek=$((SIZE-4))" + else + rc_nohalt "dd if=/dev/zero of=${1} bs=128k" + fi } ; # Function which runs gpart and creates a single large APM partition scheme @@ -696,8 +696,7 @@ init_mbr_full_disk() rc_halt "gpart add -a 4k -t freebsd -i 1 ${_intDISK}" sleep 2 - echo_log "Cleaning up ${_intDISK}s1" - rc_halt "dd if=/dev/zero of=${_intDISK}s1 count=1024" + wipe_metadata "${_intDISK}s1" # Make the partition active rc_halt "gpart set -a active -i 1 ${_intDISK}" @@ -770,9 +769,7 @@ run_gpart_gpt_part() rc_halt "gpart modify -t freebsd -i ${slicenum} ${DISK}" sleep 2 - # Clean up old partition - echo_log "Cleaning up $slice" - rc_halt "dd if=/dev/zero of=${DISK}p${slicenum} count=1024" + wipe_metadata "${slice}" sleep 4 @@ -830,9 +827,7 @@ run_gpart_slice() rc_halt "gpart modify -t freebsd -i ${slicenum} ${DISK}" sleep 2 - # Clean up old partition - echo_log "Cleaning up $slice" - rc_halt "dd if=/dev/zero of=${DISK}s${slicenum} count=1024" + wipe_metadata "${slice}" sleep 1 @@ -883,9 +878,8 @@ run_gpart_free() echo_log "Running gpart on ${DISK}" rc_halt "gpart add -a 4k -t freebsd -i ${slicenum} ${DISK}" sleep 2 - - echo_log "Cleaning up $slice" - rc_halt "dd if=/dev/zero of=${slice} count=1024" + + wipe_metadata "${slice}" sleep 1