From nobody Fri Sep 2 00:51:59 2022 X-Original-To: freebsd-questions@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4MJfWp35RHz4bFYM for ; Fri, 2 Sep 2022 00:52:22 +0000 (UTC) (envelope-from freebsd@gushi.org) Received: from prime.gushi.org (prime.gushi.org [149.20.68.142]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "prime.gushi.org", Issuer "RapidSSL TLS DV RSA Mixed SHA256 2020 CA-1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4MJfWn4tMMz4Kv4 for ; Fri, 2 Sep 2022 00:52:21 +0000 (UTC) (envelope-from freebsd@gushi.org) Received: from smtpclient.apple ([IPv6:2601:602:87f:b05d:a8aa:e32b:2b06:f9e3]) (authenticated bits=0) by prime.gushi.org (8.16.1/8.16.1) with ESMTPSA id 2820q5d2001497 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 1 Sep 2022 17:52:06 -0700 (PDT) (envelope-from freebsd@gushi.org) DKIM-Filter: OpenDKIM Filter v2.10.3 prime.gushi.org 2820q5d2001497 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gushi.org; s=prime2014; t=1662079926; bh=w8a5sauILmfhk4i5xVSkXUeh+sF+1akShklaxNbTx+g=; h=From:Subject:Date:In-Reply-To:Cc:To:References; z=From:=20Dan=20Mahoney=20|Subject:=20Re:=20maki ng=20a=20disk/slice=20bootable|Date:=20Thu,=201=20Sep=202022=2017: 51:59=20-0700|In-Reply-To:=20|Cc:=20FreeBSD-questions=20|To:=20paul=20beard=20|References:=20=0D=0A=20<07BE254D-7701-47F2-94E3-09ED7 229FB2B@gushi.org>=0D=0A=20=0D=0A=20; b=TAvsrWH1LDeieqqsiuxzfTGrFkYxU3A7gaO8f+GOBe4UB2CVG3sf0zphkJGxlAkpV 1slGyXd6RxADn2hpewHFBPHYBE/P1hivKsa7YYocEPysOd3idI7CCj1A2Lgw3VygWC MoEj+k4dSJnVW9PlSOiTr1rVapZfDJCDRdzi5FCNUKDw2VhCvGcj/C9UacqCPtpa/q +czSeCys8/2mvsrn3RsZ9+tA3njiuCr8NNHNU2bxu1PvPRmq/fWdaVoUlENJ74riO9 niIpPoSm3B/Gwc9Fiftkwm0EwVjed6B2BQVnm1FG1sL1gPdG7+pvhxJ+1cTnt9umf1 lZaaPlSHJoGvw== X-Authentication-Warning: prime.gushi.org: Host [IPv6:2601:602:87f:b05d:a8aa:e32b:2b06:f9e3] claimed to be smtpclient.apple From: Dan Mahoney Message-Id: <03F3F917-CCF5-44BB-85F0-00AD3ADF9818@gushi.org> Content-Type: multipart/alternative; boundary="Apple-Mail=_BD5E5957-31BB-487E-9ED5-3230E0CA0007" List-Id: User questions List-Archive: https://lists.freebsd.org/archives/freebsd-questions List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-questions@freebsd.org X-BeenThere: freebsd-questions@freebsd.org Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Subject: Re: making a disk/slice bootable Date: Thu, 1 Sep 2022 17:51:59 -0700 In-Reply-To: Cc: FreeBSD-questions To: paul beard References: <07BE254D-7701-47F2-94E3-09ED7229FB2B@gushi.org> X-Mailer: Apple Mail (2.3696.120.41.1.1) X-Rspamd-Queue-Id: 4MJfWn4tMMz4Kv4 X-Spamd-Bar: ----- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gushi.org header.s=prime2014 header.b=TAvsrWH1; dmarc=pass (policy=none) header.from=gushi.org; spf=pass (mx1.freebsd.org: domain of freebsd@gushi.org designates 149.20.68.142 as permitted sender) smtp.mailfrom=freebsd@gushi.org X-Spamd-Result: default: False [-5.20 / 15.00]; DWL_DNSWL_MED(-2.00)[gushi.org:dkim]; URI_COUNT_ODD(1.00)[5]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; DMARC_POLICY_ALLOW(-0.50)[gushi.org,none]; MV_CASE(0.50)[]; RCVD_DKIM_ARC_DNSWL_MED(-0.50)[]; R_SPF_ALLOW(-0.20)[+mx]; RCVD_IN_DNSWL_MED(-0.20)[149.20.68.142:from]; R_DKIM_ALLOW(-0.20)[gushi.org:s=prime2014]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; FROM_HAS_DN(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; MLMMJ_DEST(0.00)[freebsd-questions@freebsd.org]; TO_MATCH_ENVRCPT_SOME(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; ASN(0.00)[asn:393507, ipnet:149.20.68.0/24, country:US]; RCPT_COUNT_TWO(0.00)[2]; TO_DN_ALL(0.00)[]; HAS_XAW(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; DKIM_TRACE(0.00)[gushi.org:+]; FROM_EQ_ENVFROM(0.00)[]; FREEMAIL_TO(0.00)[gmail.com]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[] X-ThisMailContainsUnwantedMimeParts: N --Apple-Mail=_BD5E5957-31BB-487E-9ED5-3230E0CA0007 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 I haven't used recoverdisk. If you're going to mirror, use one of the = other things I mentioned. gmirror is low-impact and easy enough to use = and supported by the various boot loaders. If you're just cloning disk to similar disk with rsync, you should not = need to do this more than once, unless maybe if you upgrade your system. = Normal freebsd-update upgrades do not generally touch the boot blocks. = The best advice I can give is "test this BEFORE you need it". Rip your = primary drive out and see if you still boot. For a lightweight system, even zfs mirroring is okay, but it does use = some ram for caching and the like, so I wouldn't try it with a tiny = embedded box. -Dan > On Sep 1, 2022, at 17:47, paul beard wrote: >=20 > yeah, I was pretty sure I was using the wrong tool=E2=80=A6thanks for = this.=20 >=20 > So a further Q=E2=80=A6if I continue to use recoverdisk from ports to = mirror my boot disk to a copy, is it best practice to do this on the = mirror after the mirroring is completed? For all I know there is a far = better way to do that but this is a FreeBSD 11 system (!) that has just = been doing its thing for some years. So it worked (more or less) when it = was set up. A backup you can't use isn't much use, as I have learned = (again, I expect).=20 >=20 > On Thu, Sep 1, 2022 at 5:20 PM Dan Mahoney > wrote: > > > > Fdisk is for old-school partitions (where disks had only 1-4 primary = partitions, and then subdivided those partitions into "slices" = (bsdlabel). > > > > I'm pretty sure the command you're looking for is: > > > > gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 ada1 > > > > In english, this says: > > > > * Stick the "protective master boot record" on the root of the disk = (/boot/pmbr) > > * Write a partition boot label from the file specified... > > * to this indexed partition (-i 1) > > * ...on ada1 > > > > =46rom there, you may need to tell the stage 0 loader where to find = your next bootable partition on the next boot() prompt. > > > > -Dan > > > > > > > On Sep 1, 2022, at 16:44, Dan Mahoney > wrote: > > > > > > > > > > > >> On Sep 1, 2022, at 16:41, paul beard > wrote: > > >> > > >> I have been mirroring the virtual disk in a FreeBSD vm for a = couple of years and the main disk got corrupted. The mirrored disk = doesn't boot, says it can't find a kernel, so I think I missed out on an = additional step, writing an MBR or boot sector, perhaps. > > >> > > >> The files are all there if I mount them from a VM with FreeBSD.I = assume there is a way to make a mountable disk bootable. fdisk and = gpart are available but it's been a long time since I messed around with = those. > > > > > > Let's start with the obvious: Can you post your disk layout? = Mirrored how? Gmirror/ZFS/Hardware raid/etc? MBR or Gpart? > > > > > > What commands have you tried thusfar? > > > > > > What does the boot so far look like (i.e. are you hitting the = stage 0 boot loader, and getting the loader prompt?) > > > > > > More info required, please, but this sounds very fixable. > > > > > > -Dan > > >=20 >=20 > -- > Paul Beard / www.paulbeard.org/ --Apple-Mail=_BD5E5957-31BB-487E-9ED5-3230E0CA0007 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 I = haven't used recoverdisk.  If you're going to mirror, use one of = the other things I mentioned.  gmirror is low-impact and easy = enough to use and supported by the various boot loaders.

If you're just cloning = disk to similar disk with rsync, you should not need to do this more = than once, unless maybe if you upgrade your system.  Normal = freebsd-update upgrades do not generally touch the boot blocks. =  The best advice I can give is "test this BEFORE you need it". =  Rip your primary drive out and see if you still boot.

For a = lightweight system, even zfs mirroring is okay, but it does use some ram = for caching and the like, so I wouldn't try it with a tiny embedded = box.

-Dan

On Sep = 1, 2022, at 17:47, paul beard <paulbeard@gmail.com> wrote:

yeah, I was pretty sure I was using the wrong tool=E2=80=A6than= ks for this.

So a further Q=E2=80=A6if I = continue to use recoverdisk from ports to mirror my boot disk to a copy, = is it best practice to do this on the mirror after the mirroring is = completed? For all I know there is a far better way to do that but this = is a FreeBSD 11 system (!) that has just been doing its thing for some = years. So it worked (more or less) when it was set up. A backup you = can't use isn't much use, as I have learned (again, I expect).

On Thu, Sep 1, 2022 at 5:20 PM Dan Mahoney = <freebsd@gushi.org> wrote:
>
> Fdisk is for old-school partitions (where disks had only = 1-4 primary partitions, and then subdivided those partitions into = "slices" (bsdlabel).
>
> I'm pretty = sure the command you're looking for is:
>
> gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 = ada1
>
> In english, this says:
>
> * Stick the "protective master boot = record" on the root of the disk (/boot/pmbr)
> * Write = a partition boot label from the file specified...
> * = to this indexed partition (-i 1)
> * ...on ada1
>
> =46rom there, you may need to tell = the stage 0 loader where to find your next bootable partition on the = next boot() prompt.
>
> -Dan
>
>
> > On Sep 1, = 2022, at 16:44, Dan Mahoney <freebsd@gushi.org> wrote:
> >
> >
> >
> >> = On Sep 1, 2022, at 16:41, paul beard <paulbeard@gmail.com>= wrote:
> >>
> >> I have = been mirroring the virtual disk in a FreeBSD vm for a couple of years = and the main disk got corrupted. The mirrored disk doesn't boot, says it = can't find a kernel, so I think I missed out on an additional step, = writing an MBR or boot sector, perhaps.
> >>
> >> The files are all there if I mount them from a = VM with FreeBSD.I assume there is a way to make a mountable disk = bootable.  fdisk and gpart are available but it's been a long time = since I messed around with those.
> >
> > Let's start with the obvious: Can you post your = disk layout?  Mirrored how?  Gmirror/ZFS/Hardware = raid/etc?  MBR or Gpart?
> >
> = > What commands have you tried thusfar?
> >
> > What does the boot so far look like (i.e. are you = hitting the stage 0 boot loader, and getting the loader prompt?)
> >
> > More info required, please, = but this sounds very fixable.
> >
> = > -Dan
>


--
Paul Beard / www.paulbeard.org/
=

= --Apple-Mail=_BD5E5957-31BB-487E-9ED5-3230E0CA0007--