From owner-freebsd-questions@freebsd.org Sun Oct 8 16:22:08 2017 Return-Path: Delivered-To: freebsd-questions@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 BC942E3981A for ; Sun, 8 Oct 2017 16:22:08 +0000 (UTC) (envelope-from wblock@wonkity.com) Received: from wonkity.com (wonkity.com [67.158.26.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "wonkity.com", Issuer "wonkity.com" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 49BDE6D76B for ; Sun, 8 Oct 2017 16:22:07 +0000 (UTC) (envelope-from wblock@wonkity.com) Received: from wonkity.com (localhost [127.0.0.1]) by wonkity.com (8.15.2/8.15.2) with ESMTPS id v98GM3pi067399 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 8 Oct 2017 10:22:03 -0600 (MDT) (envelope-from wblock@wonkity.com) Received: from localhost (wblock@localhost) by wonkity.com (8.15.2/8.15.2/Submit) with ESMTP id v98GM2nT067396; Sun, 8 Oct 2017 10:22:03 -0600 (MDT) (envelope-from wblock@wonkity.com) Date: Sun, 8 Oct 2017 10:22:02 -0600 (MDT) From: Warren Block To: Fabian Keil cc: Jonathan Bond-Caron , "freebsd-questions@freebsd.org" Subject: Re: GELI disk and glabel label In-Reply-To: <20171007133532.0c647a07@fabiankeil.de> Message-ID: References: <20171007133532.0c647a07@fabiankeil.de> User-Agent: Alpine 2.21 (BSF 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (wonkity.com [127.0.0.1]); Sun, 08 Oct 2017 10:22:03 -0600 (MDT) X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Oct 2017 16:22:08 -0000 On Sat, 7 Oct 2017, Fabian Keil wrote: > Jonathan Bond-Caron wrote: > >> I was trying to organize hard disk using labels and labelled two geli >> disks: https://marc.info/?l=freebsd-questions&m=147526341300616&w=2 > > Note that this post seems to be about gpt labels, > not about glabel labels. > > They are not the same kind of label (and there are various other > types of labels in FreeBSD). As you have just discovered, sometimes > the difference matters. > >> glabel secure /dev/da1 >> galbel backups /dev/da2 >> >> The problem is now I can't mount them :/ >> geli attach -k /root/geli.key >> geli: Cannot read metadata from /dev/da1 > > As Bernt already explained, that's the expected behaviour. > > While it's possible to relocate the geli metadata, before adding a > "glabel label", the process is a bit tedious and I wouldn't recommend > trying it unless you already know that your backups work. It should not need to be relocated. The problem is using the wrong device. Both geli and glabel create a new device in /dev. That device is one block smaller than the source device. If you continue to refer to the root device, new metadata will overwrite the old. Instead, use the newly-created device. For example: Create a glabel device on /dev/da1 called foo: glabel label foo /dev/da1 There is now a device called /dev/label/foo. It is one block smaller than /dev/da1 to prevent writing to the metadata at the end. Use this new device for further work, like creating a geli device (which will be called .eli). If you mistakenly create another GEOM device on the raw /dev/da1, it will overwrite the metadata that is already at the end, as happened here.