Re: Corrupted partitions after upgrade from 12.3 to 13.0-RELEASE

From: jin guojun <jguojun_at_gmail.com>
Date: Thu, 01 Sep 2022 05:16:17 UTC
Recovery of a corrupted partition is usually very hard to do unless you
have backed up the first 64 sectors of the disk drive.
If you do not have a back of the partition table, then probably try to
search for the second boot code location and fix the partition table to see
if the disk can be recovered. Make sure to back up the very first 64
sectors before doing it.

Corrupting the partition table seems starting at 12.x release. When I
installed the 12.x and 13.x or upgraded to a later release, I experienced
nearly 30% partition corruption issues, even though I did sync by entering
the shell before rebooting. Keep reinstalling in the same configuration,
eventually, the installation will be completed.
The lesson I learned is to save the first 128-256 sectors of the disk
before upgrading.

This issue may be related to partition calculation. In release 12 and
later, when doing partition as following:
a /
b sawp
d /tmp .etc

the partition a + b must be in some satisfaction, typically the partition
b, which needs to be 6 GB or 8Gb and greater; otherwise, the size of
partition d will be assigned to -1 no matter what value to give.

-Jin

On Wed, Aug 31, 2022 at 6:59 PM Kaya Saman <kayasaman@optiplex-networks.com>
wrote:

> Hi,
>
>
> I was trying to update one of my servers earlier from 12.3-RELEASE to
> 13.0 RELEASE and after issuing:
>
>
> freebsd-update install
>
> shutdown -r now
>
>
> after following Chapter 24 from the Handbook:
> https://docs.freebsd.org/en/books/handbook/
>
> the Bootloader came up with an error about not being able to access the
> file system on the disk. Having read around a little, information
> pointed to updating the bootcode on the disk.
>
> Following the docs here:
> https://www.freebsd.org/cgi/man.cgi?query=gptboot&sektion=8&format=html
>
> I ran: gpart bootcode -b /boot/pmbr    -p /boot/gptboot -i 1 ada0
>
>
> Now I get a message saying "Invalid Partitions".
>
>
> Currently I have a 13.0-RELEASE usb stick in the system which I'm
> booting from and am able to read the information from /dev/ada0 which is
> fine.
>
> If I run: mount /dev/ada0s1 /mnt
>
> The a. slice mounts and the data is there!
>
>
> However, I think the partition table has become corrupted or altered
> somehow after attempting to update the bootcode as the layout used to be:
>
>
> /dev/ada0s1a
>
> /dev/ada0s1b
>
>
> b. slice was for swap.
>
>
> The FS is UFS of course.... now I only get a single partition and no
> slices at: /dev/ada0s1
>
>
> In an attempt at recovery I mounted an NFS share on the LiveCD and ran a
> dd backup of the boot drive.
>
> First attempt was: dd if=/dev/ada0s1 of=/path_to_share/freebsd_bak.img
>
> Secondly I tried: dd if=/dev/ada0 of=/path_to_share/freebsd_bak_1.img
>
>
> In either case when attempting to mount the image I get a message
> saying: "Block device required"
>
>
> Is it possible to recover the slices or at least read the data from the
> backup image?
>
>
> I don't mind reinstalling as long as I can access the backup.
>
>
> gpart show/list ada0 doesn't give any indication about the a. or b.
> slices, so either they are completely gone or I'm not using the correct
> tools.
>
>
> Would anyone be able to suggest anything to either get the system to
> boot again or at least read the information from the backup image?
>
>
> Many thanks.
>
>
> Kaya
>
>
>
>