From owner-freebsd-questions@FreeBSD.ORG Thu Nov 11 20:09:05 2010 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5A5E31065672 for ; Thu, 11 Nov 2010 20:09:05 +0000 (UTC) (envelope-from dan@dan.emsphone.com) Received: from email2.allantgroup.com (email2.emsphone.com [199.67.51.116]) by mx1.freebsd.org (Postfix) with ESMTP id 209378FC18 for ; Thu, 11 Nov 2010 20:09:04 +0000 (UTC) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by email2.allantgroup.com (8.14.4/8.14.4) with ESMTP id oABK933g054062 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 11 Nov 2010 14:09:04 -0600 (CST) (envelope-from dan@dan.emsphone.com) Received: from dan.emsphone.com (smmsp@localhost [127.0.0.1]) by dan.emsphone.com (8.14.4/8.14.4) with ESMTP id oABK93e8092315 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 11 Nov 2010 14:09:03 -0600 (CST) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.14.4/8.14.4/Submit) id oABK93gW092314; Thu, 11 Nov 2010 14:09:03 -0600 (CST) (envelope-from dan) Date: Thu, 11 Nov 2010 14:09:03 -0600 From: Dan Nelson To: Matthias Apitz Message-ID: <20101111200903.GA57869@dan.emsphone.com> References: <20101111200252.GA1350@tiny.Sisis.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20101111200252.GA1350@tiny.Sisis.de> X-OS: FreeBSD 8.1-STABLE User-Agent: Mutt/1.5.21 (2010-09-15) X-Virus-Scanned: clamav-milter 0.96.4 at email2.allantgroup.com X-Virus-Status: Clean X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.2.6 (email2.allantgroup.com [199.67.51.78]); Thu, 11 Nov 2010 14:09:04 -0600 (CST) X-Scanned-By: MIMEDefang 2.68 on 199.67.51.78 Cc: freebsd-questions@freebsd.org Subject: Re: how to overwrite the content of a file X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Nov 2010 20:09:05 -0000 In the last episode (Nov 11), Matthias Apitz said: > What is the best method to overwrite the blocks of a given file with bytes > of 0x00, i.e. not to O_TRUNC away the blocks to the freelist of the file > system, but overwrite the old blocks? > > I've checked > > $ dd if=/dev/zero of=file count=4 > > but dd(1) opens the file with O_RDWR|O_CREAT|O_TRUNC which for sure will > give away the old blocks and adquire new blocks. Any idea? conv=notrunc (note that this will only help with ufs; zfs is always copy-on-write, so newly-written data never overwrites the old blocks) -- Dan Nelson dnelson@allantgroup.com