From owner-freebsd-hackers@FreeBSD.ORG Thu Jan 4 18:58:24 2007 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id EDC9816A407 for ; Thu, 4 Jan 2007 18:58:24 +0000 (UTC) (envelope-from risner@matrix.stdio.com) Received: from matrix.stdio.com (matrix.stdio.com [199.89.192.20]) by mx1.freebsd.org (Postfix) with ESMTP id A41C013C441 for ; Thu, 4 Jan 2007 18:58:20 +0000 (UTC) (envelope-from risner@matrix.stdio.com) Received: from matrix.stdio.com (localhost [127.0.0.1]) by matrix.stdio.com (8.13.4/8.13.4) with ESMTP id l04IeeCv012321 for ; Thu, 4 Jan 2007 13:40:40 -0500 (EST) (envelope-from risner@matrix.stdio.com) Received: (from risner@localhost) by matrix.stdio.com (8.13.4/8.13.4/Submit) id l04Ieepw012320 for freebsd-hackers@freebsd.org; Thu, 4 Jan 2007 13:40:40 -0500 (EST) (envelope-from risner) Date: Thu, 4 Jan 2007 13:40:40 -0500 From: James Risner To: freebsd-hackers@freebsd.org Message-ID: <20070104184040.GA12048@matrix.stdio.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.2.1i Subject: /bin/dd fails with big disks containing bad sectors X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Jan 2007 18:58:25 -0000 Hello, I filed this PR (http://www.freebsd.org/cgi/query-pr.cgi?pr=kern/107443) and it was suggested I bring the issue to this list. If you have a defective disk larger than 2 gb with many bad sectors and attempt to use dd under FreeBSD to duplicate the disk, the operation will fail with sectors being out of alignment. dd bs=512 if=src of=dst conv=noerror,sync Under Linux, this operation performs as expected. There are faster methods of duplicating the disk (tools/recoverdisk is one.) But sometimes you only have /bin/dd and a fixit disk. It isn't intuitive that dd should fail in the way it is failing. The user (in this case me) doesn't expect to have a disk improperly aligned. I once resolved this issue several years ago with a patch to dd that is no long valid with current sources. I recently resolved this issue by writing my own tiny dd program (code is provided for curious people in the pr kern/107443) to properly copy the blocks. >From what I can tell there are several requirements for this issue: 1) Disk > 2Gb 2) Disk has more than a few bad sectors. 3) Use dd to copy the disk. It seems despite using "sync", dd is getting confused as to the input and output seek position. They get out of sync with each other and all future output blocks are written earlier on the disk than is required. James Risner