From nobody Thu Sep 1 12:38:44 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 4MJLFt4CZGz4bWBJ for ; Thu, 1 Sep 2022 12:39:14 +0000 (UTC) (envelope-from smithi@nimnet.asn.au) Received: from se6.syd.hostingplatform.net.au (se6.syd.hostingplatform.net.au [IPv6:2400:b800:5::52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4MJLFr0s3qz3yM1 for ; Thu, 1 Sep 2022 12:39:10 +0000 (UTC) (envelope-from smithi@nimnet.asn.au) Received: from s121.syd3.hostingplatform.net.au ([103.27.34.4]) by se6.syd.hostingplatform.net.au with esmtps (TLSv1.2:AES128-GCM-SHA256:128) (Exim 4.92) (envelope-from ) id 1oTjTC-0002Gf-06 for freebsd-questions@freebsd.org; Thu, 01 Sep 2022 22:39:02 +1000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nimnet.asn.au; s=default; h=Message-ID:From:To:Subject: Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To: Date:Sender:Reply-To:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=cHKktJ/ORmtDFWV+QPKyiDhJoEDEshH3Hdp2QyCjyUk=; b=GQILPtCyb0SgmCUGLt5ZHsQDl7 ErEbSTmiqimmigmBkKOfLLTlE9ntjDFoab1Pj7eFkA9eIX2Rqwm8F1zGBxc1zLG8pjR1rPWTrUk9D r1stBjp9FXDnzrIG4QwSOWqoV9CUnY8fnOssGPlN/IXIuAM9Hx9zbbwna/UuN4YpDdwOTvym2uzQa mMOii3PVPWB4rxLrFxH98t+aoqzd6gLG7GUoz2ZfPalmqoFsB2zShdiUfZrnUUMo4T8XWXXx6P93u 0XJ0UrDW3Nw6lEaTcqNUoKjk5AEHgsS51GoR/WoabNqKtOn7poslcVYAyr0sgTjyeWLApw/o5Eu3X 8FdvquGQ==; Received: from [1.145.94.122] (port=1284 helo=Galaxy-J5-Pro) by s121.syd3.hostingplatform.net.au with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.95) (envelope-from ) id 1oTjT9-000XLe-Kv; Thu, 01 Sep 2022 22:38:52 +1000 Date: Thu, 01 Sep 2022 22:38:44 +1000 User-Agent: K-9 Mail for Android In-Reply-To: References: 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 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: Corrupted partitions after upgrade from 12.3 to 13.0-RELEASE To: Kaya Saman ,freebsd-questions From: Ian Smith Message-ID: X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - s121.syd3.hostingplatform.net.au X-AntiAbuse: Original Domain - freebsd.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - nimnet.asn.au X-Get-Message-Sender-Via: s121.syd3.hostingplatform.net.au: authenticated_id: smithi@nimnet.asn.au X-Authenticated-Sender: s121.syd3.hostingplatform.net.au: smithi@nimnet.asn.au X-Source: X-Source-Args: X-Source-Dir: X-Originating-IP: 103.27.34.4 X-SpamExperts-Domain: out-3.hostingplatform.net.au X-SpamExperts-Username: 103.27.34.4 X-SpamExperts-Outgoing-Class: ham X-SpamExperts-Outgoing-Evidence: Combined (0.03) X-Recommended-Action: accept X-Filter-ID: P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1i8xjBKeKlHKlYMBVpNoj8tNkhBoOf8jbJHOZPDqhXzEwFJfOdokX8m+qaat4hrM sZElN4Z5o9s32nQ5Sb74wq0jW65AYT5dCBnMcAtAva/KQS4o99XmK84= X-Report-Abuse-To: spam@se.syd.hostingplatform.net.au X-Rspamd-Queue-Id: 4MJLFr0s3qz3yM1 X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=nimnet.asn.au header.s=default header.b=GQILPtCy; dmarc=none; spf=pass (mx1.freebsd.org: domain of smithi@nimnet.asn.au designates 2400:b800:5::52 as permitted sender) smtp.mailfrom=smithi@nimnet.asn.au X-Spamd-Result: default: False [-3.50 / 15.00]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_SHORT(-1.00)[-1.000]; R_SPF_ALLOW(-0.20)[+ip6:2400:b800:5:0::49/123]; R_DKIM_ALLOW(-0.20)[nimnet.asn.au:s=default]; MIME_GOOD(-0.10)[text/plain]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; DMARC_NA(0.00)[nimnet.asn.au]; HAS_X_AS(0.00)[smithi@nimnet.asn.au]; HAS_X_GMSV(0.00)[smithi@nimnet.asn.au]; TO_MATCH_ENVRCPT_SOME(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; ASN(0.00)[asn:45638, ipnet:2400:b800:5::/48, country:AU]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_THREE(0.00)[3]; HAS_X_SOURCE(0.00)[]; HAS_XOIP(0.00)[]; MLMMJ_DEST(0.00)[freebsd-questions@freebsd.org]; TO_DN_ALL(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; DKIM_TRACE(0.00)[nimnet.asn.au:+]; FROM_EQ_ENVFROM(0.00)[]; HAS_X_ANTIABUSE(0.00)[]; RCVD_TLS_ALL(0.00)[] X-ThisMailContainsUnwantedMimeParts: N On 1 September 2022 11:54:14 am AEST, Kaya Saman wrote: > Hi, >=20 > I was trying to update one of my servers earlier from 12=2E3-RELEASE to >=20 > 13=2E0 RELEASE and after issuing: >=20 > freebsd-update install >=20 > shutdown -r now >=20 > after following Chapter 24 from the Handbook:=20 > https://docs=2Efreebsd=2Eorg/en/books/handbook/ >=20 > the Bootloader came up with an error about not being able to access > the=20 > file system on the disk=2E Having read around a little, information=20 > pointed to updating the bootcode on the disk=2E When reporting errors, show precisely what was shown=2E > Following the docs here:=20 > https://www=2Efreebsd=2Eorg/cgi/man=2Ecgi?query=3Dgptboot&sektion=3D8&f= ormat=3Dhtml >=20 > I ran: gpart bootcode -b /boot/pmbr=C2=A0=C2=A0=C2=A0 -p /boot/gptboot = -i 1 ada0 >=20 >=20 > Now I get a message saying "Invalid Partitions"=2E >=20 >=20 > Currently I have a 13=2E0-RELEASE usb stick in the system which I'm=20 > booting from and am able to read the information from /dev/ada0 which > is=20 > fine=2E Specifically make and keep a copy of the first 128 512-byte sectors: # dd if=3D/dev/ada0 of=3Dsomefile bs=3D512 count=3D128 You probably need to mount another USB stick r/w for 'somefile' for transp= ort, recording sessions =2E=2E=2E > If I run: mount /dev/ada0s1 /mnt >=20 > The a=2E slice mounts and the data is there! Please show at this stage: # gpart show -p ada0 and # gpart show -p ada0s1 > However, I think the partition table has become corrupted or altered=20 > somehow after attempting to update the bootcode as the layout used to > be: >=20 > /dev/ada0s1a >=20 > /dev/ada0s1b If the above is accurate - that your partitions were called ada0s1a and ad= a0s1b - then your disk was NOT previously partitioned with the GPT scheme, = but with the MBR scheme=2E If so, running gptboot(8) will have destroyed the master boot record (MBR)= and replaced it with its 'protective' MBR instead, and perhaps clobbered t= he boot record from the first UFS partition=2E It's very old-school, but run and record accurately, to see what the pmbr = slice table contains: # fdisk ada0 > b=2E slice was for swap=2E The swap space is dispensable, if you can recover the 'a' partition=2E > The FS is UFS of course=2E=2E=2E=2E now I only get a single partition a= nd no=20 > slices at: /dev/ada0s1 You have the terminology backwards: 'slices' are the up to 4 partitions un= der the MBR scheme, and BSD 'partitions' subdivide a slice with a (/), b (s= wap), d,e,f =2E=2E=2E optionally others like /var, /usr, /home The handbook in effect just says "we're going with GPT for all these examp= les" so is no help with this unless you started with GPT, in which case the= re would be such as ada0p1 etc, not ada0s1a etc=2E See gpart(8) section PARTITIONING SCHEMES for much more detail=2E > In an attempt at recovery I mounted an NFS share on the LiveCD and > ran a=20 > dd backup of the boot drive=2E >=20 > First attempt was: dd if=3D/dev/ada0s1 > of=3D/path_to_share/freebsd_bak=2Eimg >=20 > Secondly I tried: dd if=3D/dev/ada0 of=3D/path_to_share/freebsd_bak_1= =2Eimg Good=2E The second whole-disk one is what you want=2E Using dd and hd (h= exdump) you might find the X? GiB swap partition near the very end=2E In case I'm on the the right track with this, here's a 12=2E3-RELEASE syst= em built with bsdinstall on a SSD that came already MBR-scheme with Win10pr= o taking first 2 slices, then FreeBSD on a 48G s4 - after I had W10 shrink = itself and add a FAT32 slice=2E Root@t430s:~ # gpart show -p ada0 =3D> 63 250069617 ada0 MBR (119G) 63 1985 - free - (993K) 2048 1185792 ada0s1 ntfs (579M) 1187840 80353280 ada0s2 ntfs (38G) 81541120 67108864 ada0s3 fat32lba (32G) 148649984 100663296 ada0s4 freebsd [active] (48G) 249313280 756400 - free - (369M) Root@t430s:~ # gpart show -p ada0s4 =3D> 0 100663296 ada0s4 BSD (48G) 0 8388608 ada0s4a freebsd-ufs (4=2E0G) 8388608 8388608 ada0s4b freebsd-swap (4=2E0G) 16777216 8388608 ada0s4d freebsd-ufs (4=2E0G) 25165824 16777216 ada0s4e freebsd-ufs (8=2E0G) 41943040 58720256 ada0s4f freebsd-ufs (28G) With MBR scheme it's common to see the disk shown as starting at sector 63= , so sectors 0=2E=2E62 are reserved, and include the MBR itself plus first = stage boot sectors=2E Linux puts GRUB there as I recall=2E Here, s1 (win10 NTFS) starts at 2048 (1MiB) and hd shows |=2ER=2ENTFS = =2E=2E=2E=2E=2E| as the start of the NTFS loader=2E In my case I look at 8k (16 sectors) from 148649984 and see among the bina= ry, such as =2E=2E =2ERead=2EBoot=2E error' and 'BTX' and later strings lik= e /boot/kernel/kernel and FreeBSD/x86 boot, ie it may not be too hard to fi= nd the start of your ada0s1a partition=2E Try: # dd if=3D/dev/ada0 skip=3D2048 count=3D16 | hd | less > In either case when attempting to mount the image I get a message=20 > saying: "Block device required" vnode-backed mdconfig(8) perhaps? Make sure to use '-o readonly' on your i= mage=2E How big is the disk and image? > Is it possible to recover the slices or at least read the data from > the=20 > backup image? Should be, once you figure out exactly where the partition starts, unless = the gptboot clobbered it=2E > I don't mind reinstalling as long as I can access the backup=2E Need more data first=2E > gpart show/list ada0 doesn't give any indication about the a=2E or b=2E= =20 > slices, so either they are completely gone or I'm not using the > correct=20 > tools=2E Don't tell, show=2E # gpart show -p ada0 > Would anyone be able to suggest anything to either get the system to=20 > boot again or at least read the information from the backup image? If it was GPT originally, ignore me=2E Otherwise, let's see what's there= =2E Cheers, Ian