From owner-freebsd-hackers@freebsd.org Sat Feb 4 21:30:10 2017 Return-Path: Delivered-To: freebsd-hackers@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 C3B2FCD00F4 for ; Sat, 4 Feb 2017 21:30:10 +0000 (UTC) (envelope-from bu7cher@yandex.ru) Received: from forward1p.cmail.yandex.net (forward1p.cmail.yandex.net [IPv6:2a02:6b8:0:1465::11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "forwards.mail.yandex.net", Issuer "Yandex CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4A17B1E0D for ; Sat, 4 Feb 2017 21:30:10 +0000 (UTC) (envelope-from bu7cher@yandex.ru) Received: from smtp3m.mail.yandex.net (smtp3m.mail.yandex.net [IPv6:2a02:6b8:0:2519::125]) by forward1p.cmail.yandex.net (Yandex) with ESMTP id 3E82520739; Sun, 5 Feb 2017 00:29:58 +0300 (MSK) Received: from smtp3m.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp3m.mail.yandex.net (Yandex) with ESMTP id 8516D2840C3C; Sun, 5 Feb 2017 00:29:56 +0300 (MSK) Received: by smtp3m.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id Ymd0qNbxp2-Tteqc1sS; Sun, 05 Feb 2017 00:29:55 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client certificate not present) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1486243795; bh=CV5Z67ipK0CO9a3qshJ2TV7MukQYhCwsmaYVvGic3vQ=; h=Subject:To:References:Cc:From:Message-ID:Date:In-Reply-To; b=brs7c9noU3s8FbjaVzu9HFIcsUxR8lxu7XOz3kk0njBLly8yYv+oMoD3xck71z8Qc UG4KOeEmIhxSbojyBV6lomADSW5pJAW/rcQUPAXxVi0A57KS49MFdawc/AXawBcEDE E42guZx/qCny/TGBoFaaCGT1DbNJ4W6Q967NI8nY= Authentication-Results: smtp3m.mail.yandex.net; dkim=pass header.i=@yandex.ru X-Yandex-Suid-Status: 1 0,1 0,1 0,1 0 Subject: Re: How to safely remove rest of GTP? To: Warren Block References: <201701311543.v0VFh0Bl044986@pdx.rh.CN85.dnsmgr.net> <515e709a-5c34-0bc1-bc3b-7cff99f6dd97@yandex.ru> Cc: "Rodney W. Grimes" , freebsd-hackers@freebsd.org, Slawa Olhovchenkov From: "Andrey V. Elsukov" Message-ID: Date: Sun, 5 Feb 2017 00:28:46 +0300 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 04 Feb 2017 21:30:10 -0000 On 04.02.2017 21:57, Warren Block wrote: >> Please, give me some working example, when or where you have a >> problem, and not some theoretical, based on previous negative >> experience or memories. > > I just encountered something similar with a Windows 7 install on a disk > that previously had a FreeBSD GPT layout. > > Clonezilla reported a conflicting GPT/MBR layout on the disk. In gpart, > it showed a valid GPT (not corrupt) with no partitions. After all the > cursing, I ran 'sudo sgdisk -z /dev/sda' as instructed by Clonezilla. > > It was only after that I realized I should have saved at least the > partition tables. Hi, so, what is wrong here from your point of view? I can imagine a way how to reproduce it. Create two partition tables MBR and GPT. # truncate -s 100m disk0 # truncate -s 100m disk1 # mdconfig -f disk0 md0 # mdconfig -f disk1 md1 # gpart create -s gpt md0 md0 created # gpart create -s mbr md1 md1 created # gpart add -t fat32 -s 25m md1 md1s1 added # gpart add -t ntfs -s 25m md1 md1s2 added # gpart add -t \!238 md1 md1s3 added # gpart show md0 md1 => 40 204720 md0 GPT (100M) 40 204720 - free - (100M) => 9 204791 md1 MBR (100M) 9 51200 1 fat32 (25M) 51209 51200 2 ntfs (25M) 102409 102391 3 !238 (50M) Copy MBR from md1 to md0: # dd if=/dev/md1 of=/dev/md0 count=1 1+0 records in 1+0 records out 512 bytes transferred in 0.285149 secs (1796 bytes/sec) # gpart show md0 md1 => 40 204720 md0 GPT (100M) 40 204720 - free - (100M) => 9 204791 md1 MBR (100M) 9 51200 1 fat32 (25M) 51209 51200 2 ntfs (25M) 102409 102391 3 !238 (50M) Now md0 has correct MBR and GPT (not corrupt). GPT has higher priority, due to MBR has partition with type 0xee (PMBR). https://svnweb.freebsd.org/base?view=revision&revision=258448 Remove "PMBR" partition and overwrite MBR on md0 again: # gpart delete -i 3 md1 md1s3 deleted # dd if=/dev/md1 of=/dev/md0 count=1 1+0 records in 1+0 records out 512 bytes transferred in 0.289039 secs (1771 bytes/sec) # gpart show md0 md1 => 9 204791 md0 MBR (100M) 9 51200 1 fat32 (25M) 51209 51200 2 ntfs (25M) 102409 102391 - free - (50M) => 9 204791 md1 MBR (100M) 9 51200 1 fat32 (25M) 51209 51200 2 ntfs (25M) 102409 102391 - free - (50M) md0 still has both GPT and MBR, but GPT has lower priority, because there is no PMBR partition. Destroy MBR on the md0: # gpart destroy -F md0 md0 destroyed # gpart show md0 md1 gpart: No such geom: md0. And force retaste: # true > /dev/md0 # gpart show md0 md1 => 40 204720 md0 GPT (100M) 40 204720 - free - (100M) => 9 204791 md1 MBR (100M) 9 51200 1 fat32 (25M) 51209 51200 2 ntfs (25M) 102409 102391 - free - (50M) -- WBR, Andrey V. Elsukov