From owner-freebsd-current@FreeBSD.ORG Fri Feb 27 12:53:11 2004 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D897616A4CE; Fri, 27 Feb 2004 12:53:11 -0800 (PST) Received: from mail004.syd.optusnet.com.au (mail004.syd.optusnet.com.au [211.29.132.145]) by mx1.FreeBSD.org (Postfix) with ESMTP id A82CE43D2D; Fri, 27 Feb 2004 12:53:10 -0800 (PST) (envelope-from peterjeremy@optushome.com.au) Received: from server.vk2pj.dyndns.org (c211-30-75-229.belrs2.nsw.optusnet.com.au [211.30.75.229]) i1RKr8P04674; Sat, 28 Feb 2004 07:53:09 +1100 Received: from server.vk2pj.dyndns.org (localhost.vk2pj.dyndns.org [127.0.0.1])i1RKr8i6082703; Sat, 28 Feb 2004 07:53:08 +1100 (EST) (envelope-from peter@server.vk2pj.dyndns.org) Received: (from peter@localhost) by server.vk2pj.dyndns.org (8.12.10/8.12.10/Submit) id i1RKr8Om082702; Sat, 28 Feb 2004 07:53:08 +1100 (EST) (envelope-from peter) Date: Sat, 28 Feb 2004 07:53:08 +1100 From: Peter Jeremy To: Andre Oppermann Message-ID: <20040227205308.GA75246@server.vk2pj.dyndns.org> References: <403E53C6.40100@freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <403E53C6.40100@freebsd.org> User-Agent: Mutt/1.4.2.1i cc: FreeBSD current users Subject: Re: would this be a useful utility? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Feb 2004 20:53:12 -0000 On Thu, Feb 26, 2004 at 09:15:02PM +0100, Andre Oppermann wrote: >Oh yes. I just got a 1GB compact flash on which appearently one >sector is defect. I know the file it is in but can't figure out >how to avoid it. If you know which block in the file is defective, you can use truncate(1) to delete blocks after the defective one. You should be able to use fsdb(8) to locate the physical block number. If it's a small file, just rename it to something like '.bad_blocks', mark it nodump (amd maybe schg) and remember not to read or delete it. Unfortunately, there's no simple way to free the blocks between the beginning of the file and the bad block. The easiest way would be to create a single dummy file that occupied all the remaining free space, delete the file with the defective block and then create N 1-block files (1 for every block in the file). One of these files will contain the defective block and can be renamed as above, then the remaining files can be deleted. You probably want to do this with softupdates turned off (so you don't have to wait for the delayed free space release). Note that this includes a fair bit of FS churn so it may be undesirable on a flash device with limited write cycles. Peter