From owner-freebsd-stable@FreeBSD.ORG Mon May 13 03:17:44 2013 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id B8DC6A43 for ; Mon, 13 May 2013 03:17:44 +0000 (UTC) (envelope-from jdc@koitsu.org) Received: from qmta05.emeryville.ca.mail.comcast.net (qmta05.emeryville.ca.mail.comcast.net [IPv6:2001:558:fe2d:43:76:96:30:48]) by mx1.freebsd.org (Postfix) with ESMTP id 86AD8123 for ; Mon, 13 May 2013 03:17:44 +0000 (UTC) Received: from omta21.emeryville.ca.mail.comcast.net ([76.96.30.88]) by qmta05.emeryville.ca.mail.comcast.net with comcast id bERW1l0011u4NiLA5FHjaA; Mon, 13 May 2013 03:17:43 +0000 Received: from koitsu.strangled.net ([67.180.84.87]) by omta21.emeryville.ca.mail.comcast.net with comcast id bFHi1l00X1t3BNj8hFHiMF; Mon, 13 May 2013 03:17:43 +0000 Received: by icarus.home.lan (Postfix, from userid 1000) id 83C5473A33; Sun, 12 May 2013 20:17:42 -0700 (PDT) Date: Sun, 12 May 2013 20:17:42 -0700 From: Jeremy Chadwick To: Chris Ross Subject: Re: Reinstalling boot blocks on a ZFS-only system Message-ID: <20130513031742.GA75801@icarus.home.lan> References: <20130512205837.GA69605@icarus.home.lan> <28B5181C-E185-40E5-90EC-9600297BE590@distal.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <28B5181C-E185-40E5-90EC-9600297BE590@distal.com> User-Agent: Mutt/1.5.21 (2010-09-15) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20121106; t=1368415063; bh=X2UlqapqFdUYjqprqRv9C9dNtg/T15TG1x9oqpKsuCU=; h=Received:Received:Received:Date:From:To:Subject:Message-ID: MIME-Version:Content-Type; b=BBkZXbdGF3HwLGrGsXzP8Uy0M6/0rdFs9fYoK9meq3M+fL47xTVfEBhaiMwLkwVZ3 li1MQKqkq/Vnw/xA/yZkA/E+SzoPZNJSUwfQQhyjvX9JNAxACtDsCn8I5mZCzgOMIS NJ7NbHBm2PSvPUZEJF+n6SA9V+PJ4Vro+xiKh61qwzT0Ai+PIdUtu9KYTjZOpfJ4aX xHf/rAaYs4U/kqNeb3vroJOmqyH+/pLlqlKdRiODu03FzSveKlaEO4/1t9KWa3W0HG +EjNpaZ0Uxqu7S4AA72eNVjNeSWNmncPfXsTBli9GJwh5iC8PB2luTRolz6HpYjCkM YvMUT/kX1EHRg== Cc: "freebsd-stable@freebsd.org" X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 May 2013 03:17:44 -0000 On Sun, May 12, 2013 at 10:20:26PM -0400, Chris Ross wrote: > > On May 12, 2013, at 16:58 , Jeremy Chadwick wrote: > > The command is "gpart bootcode", however I cannot be bothered to > > remember the syntax; I imagine it greatly depends on if you're using GPT > > vs. MBR, in addition to what your partition layout look like. Meaning: > > there is no "universal standard", it depends entirely on how you set > > your stuff up. But the command is definitely "gpart bootcode". > > > > Next, AFAIK there is no need to boot alternate media (CD etc.) to > > accomplish this. > > > > You may also need to set kern.geom.debugflags=0x10 to inhibit GEOM's > > "safety measure" / to permit writing to LBA 0; see GEOM(4) and search > > for the word "foot". > > In the past, I've found I've been unable to install all of the bootblocks if I > boot from the ZFS root. When booting from a cd, the basic: > > gpart bootcode -p ${bootdir}/zfsboot ${disk} > dd if=${bootdir}zfsloader of=/dev/${disk}a bs=512 oseek=1024 conv=notrunc,sync > > works. But, if I boot from ZFS, then I can't dd anything into the front of the > drives. Right now, the problem after booting from the CD, is trying to mount > a read/write filesystem (mfs, or the like) so that I can scp the bootblocks onto the > system and install them. BUt, I eventually found the command I'd lost. so I > think I'm alright. Thanks... What does "unable to install" mean? What output/error do you get? I am going to assume you get EPERM (Operation not permitted), which would be caused by GEOM's "preventive foot-shooting" (keep reading). Is there some reason you're sticking with the MBR scheme instead of GPT? Taken from GEOM(4): Both types of bootstrap code are used to boot from the GUID Partition Ta- ble. First, a protective MBR is embedded into the first disk sector from the /boot/pmbr image. It searches the GPT freebsd-boot partition (see the PARTITION TYPES section) in the GPT and runs the next bootstrap stage from it. The freebsd-boot partition should be smaller than 545 KB. There are two variants of bootstrap code to write to this partition: /boot/gptboot and /boot/gptzfsboot. /boot/gptboot is used to boot from UFS. It searches freebsd-ufs GPT partitions and starts /boot/loader (the third bootstrap stage) if found. The /boot/gptzfsboot is used to boot from ZFS. It searches freebsd-zfs GPT partitions and starts /boot/zfsloader if found. So by moving to GPT you would relieve yourself of a lot of pain, particularly that dd nonsense (which looks like it could seriously hurt you, especially if you're doing it by hand by booting some CD). An added bonus to using the GPT scheme is that you can align your partitions easier for 4096-byte sector drives. With GPT, I believe you'd use this, and only this: sysctl kern.geom.debugflags=16 gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ${disk} sysctl kern.geom.debugflags=0 (That also assumes the GPT freebsd-boot partition is what's comes first on $disk (i.e. index 1), as it should be) If you're using mirrors, you would need to do the gpart command for each disk that is part of your mirror vdev; i.e. if ada0 and ada1 are a mirror, issue the gpart command against ada0 and ada1, otherwise you may find that if one of your disks dies you might not be able to boot from the system. All this comes from: https://wiki.freebsd.org/RootOnZFS/GPTZFSBoot/Mirror (You'll find the EPERM situation mentioned there too) I should also note that if you do go with GPT, please use a larger freebsd-boot partition size (512KBytes is ideal, not 64KBytes), because the bootstraps are often >64KBytes these days. http://www.wonkity.com/~wblock/docs/html/ssd.html Good luck. -- | Jeremy Chadwick jdc@koitsu.org | | UNIX Systems Administrator http://jdc.koitsu.org/ | | Mountain View, CA, US | | Making life hard for others since 1977. PGP 4BD6C0CB |