Date: Sun, 12 May 2013 20:17:42 -0700 From: Jeremy Chadwick <jdc@koitsu.org> To: Chris Ross <cross+freebsd@distal.com> Cc: "freebsd-stable@freebsd.org" <freebsd-stable@freebsd.org> Subject: Re: Reinstalling boot blocks on a ZFS-only system Message-ID: <20130513031742.GA75801@icarus.home.lan> In-Reply-To: <28B5181C-E185-40E5-90EC-9600297BE590@distal.com> References: <A6940C2F-17B4-4ECF-85B6-BA8CB335486E@distal.com> <20130512205837.GA69605@icarus.home.lan> <28B5181C-E185-40E5-90EC-9600297BE590@distal.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, May 12, 2013 at 10:20:26PM -0400, Chris Ross wrote: > > On May 12, 2013, at 16:58 , Jeremy Chadwick <jdc@koitsu.org> 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 |
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130513031742.GA75801>