From owner-freebsd-geom@FreeBSD.ORG Sun Mar 7 19:13:23 2010 Return-Path: Delivered-To: freebsd-geom@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 294C4106566B for ; Sun, 7 Mar 2010 19:13:23 +0000 (UTC) (envelope-from xcllnt@mac.com) Received: from asmtpout030.mac.com (asmtpout030.mac.com [17.148.16.105]) by mx1.freebsd.org (Postfix) with ESMTP id 1427D8FC08 for ; Sun, 7 Mar 2010 19:13:22 +0000 (UTC) MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: text/plain; charset=us-ascii Received: from macbook-pro.lan.xcllnt.net (mail.xcllnt.net [75.101.29.67]) by asmtp030.mac.com (Sun Java(tm) System Messaging Server 6.3-8.01 (built Dec 16 2008; 32bit)) with ESMTPSA id <0KYX00MZREQ3EP30@asmtp030.mac.com> for freebsd-geom@freebsd.org; Sun, 07 Mar 2010 11:13:16 -0800 (PST) X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 ipscore=0 phishscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx engine=5.0.0-0908210000 definitions=main-1003070165 From: Marcel Moolenaar In-reply-to: <4B9389C1.9000102@icyb.net.ua> Date: Sun, 07 Mar 2010 11:13:14 -0800 Message-id: References: <4B9389C1.9000102@icyb.net.ua> To: Andriy Gapon X-Mailer: Apple Mail (2.1077) Cc: freebsd-geom@freebsd.org Subject: Re: another gpt vs mbr (sanity) check X-BeenThere: freebsd-geom@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: GEOM-specific discussions and implementations List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Mar 2010 19:13:23 -0000 On Mar 7, 2010, at 3:10 AM, Andriy Gapon wrote: > > Please consider the following scenario: > - GPT scheme is used on a disk > - the disk changes hands > - the disk is repartitioned with MBR without explicitly wiping out any of old > data and thus GPT > - GPT data survives undamaged > > So now we have the valid GPT but it points to wrong offsets and we have the > valid and correct MBR. > Currently FreeBSD would pick GPT scheme over MBR scheme when presented which > such a disk. I think that this is incorrect. Sorry. That ship has sailed. Originally GEOM_GPT at the time checked for the protective MBR before accepting the GPT. This was changed to support Apple setups. There's no turning back now. People just need to learn to wipe out old partitioning information before writing select sectors in order to create a new one. This, BTW, is exactly why gpart was designed the way it was. It makes sure that you properly clean all the meta-data of the old scheme before new meta-data is written. Legacy tools like fdisk and bsdlabel only write their meta-data without any consideration of the possible existence of meta-data corresponding to other schemes. Now that I think of it, it wouldn't necessarily be a bad feature to extend gpart with a verb, like "wipe", that calls G_PART_DESTROY() for all the schemes it knows about and then erases all the sectors in the sector map, wiping out any and all meta-data that gpart could ever interpret (with the caveat that this is limited to the schemes the kernel knows about at the time). -- Marcel Moolenaar xcllnt@mac.com