Solved Partition table corrupt

First the good,
Code:
zpool list -v
NAME                     SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT
KEEP2                    104G  4.92G  99.1G        -         -     0%     4%  1.00x    ONLINE  -
  mirror-0              72.5G  4.39G  68.1G        -         -     0%  6.05%      -    ONLINE
    ufs/NEWUFSp8          73G      -      -        -         -      -      -      -    ONLINE
    gpt/KEEP_B            73G      -      -        -         -      -      -      -    ONLINE
special                     -      -      -        -         -      -      -      -         -
  mirror-1              31.5G   546M  31.0G        -         -     1%  1.69%      -    ONLINE
    ufs/NEWUFSp6          32G      -      -        -         -      -      -      -    ONLINE
    gpt/KEEP_B_SPECIAL    32G      -      -        -         -      -      -      -    ONLINE
logs                        -      -      -        -         -      -      -      -         -
  ufs/NEWUFSp7            32G    20K  31.5G        -         -     0%  0.00%      -    ONLINE
cache                       -      -      -        -         -      -      -      -         -
  ada2p6                  64G  4.79G  59.2G        -         -     0%  7.48%      -    ONLINE
SSD                      530G   211G   319G        -         -    10%    39%  1.00x    ONLINE  -
  indirect-0                -      -      -        -         -      -      -      -    ONLINE
  indirect-1                -      -      -        -         -      -      -      -    ONLINE
  mirror-2               498G   207G   291G        -         -    10%  41.5%      -    ONLINE
    ufs/NEWUFSp3         500G      -      -        -         -      -      -      -    ONLINE
    gpt/SSD_B            501G      -      -        -         -      -      -      -    ONLINE
  indirect-3                -      -      -        -         -      -      -      -    ONLINE
  indirect-4                -      -      -        -         -      -      -      -    ONLINE
  indirect-7                -      -      -        -         -      -      -      -    ONLINE
special                     -      -      -        -         -      -      -      -         -
  mirror-6              31.5G  4.25G  27.2G        -        1G    56%  13.5%      -    ONLINE
    ufs/NEWUFSp4          33G      -      -        -         -      -      -      -    ONLINE
    gpt/SSD_B_SPECIAL     34G      -      -        -         -      -      -      -    ONLINE
root@myfreebsd:~ #

Everything seems healty.
Now the bad, the ufs you see are actual gpt.
But all these gpt , names "SSD_A_..." are are gone.

Code:
 ls /dev/ada3
/dev/ada3

No partitions to be seen, there where many of them including , linux , maybe freebsd log and cache device.

somehow , i do not why there is still,
Code:
ls -l /dev/ufs/
total 0
crw-r-----  1 root operator 0xa6 26 mrt. 07:07 NEWUFS
crw-r-----  1 root operator 0xd4 26 mrt. 07:07 NEWUFSp1
crw-r-----  1 root operator 0xd6 26 mrt. 07:07 NEWUFSp2
crw-r-----  1 root operator 0xd8 26 mrt. 07:07 NEWUFSp3
crw-r-----  1 root operator 0xda 26 mrt. 07:07 NEWUFSp4
crw-r-----  1 root operator 0xdc 26 mrt. 07:07 NEWUFSp5
crw-r-----  1 root operator 0xde 26 mrt. 07:07 NEWUFSp6
crw-r-----  1 root operator 0xe0 26 mrt. 07:07 NEWUFSp7
crw-r-----  1 root operator 0xe2 26 mrt. 07:07 NEWUFSp8

These I think are the partitions. But i can no longer boot the linux as system does no longer knows it is a linux partition.

Should I reboot in Artix linux , try tools to "recover" the first record of drive.
I don't want to hurt system more than it has.
And because mirror zfs says everything online all data should be still intact.
First analysis, seem partition table problem.
Please advice. Thanks and have a nice day.
 
installed "testdisk" package , output,
Code:
TestDisk 7.2, Data Recovery Utility, February 2024
Christophe GRENIER <grenier@cgsecurity.org>
https://www.cgsecurity.org

Disk /dev/ada3 - 1000 GB / 931 GiB - 1953525168 sectors
Current partition structure:
     Partition                  Start        End    Size in sectors

Bad GPT partition, invalid signature.
Trying alternate GPT
 1 P FreeBSD Swap           272631808  406849535  134217728 [FREEBSWAPADA3]
 2 P Linux filesys. data         2048  272631807  272629760 [NEWREDCORE]
 3 P Unknown                406849536 1455425535 1048576000 [SSD_A]
 4 P Unknown               1455425536 1524631551   69206016 [SSD_A_SPECIAL]
 5 P Unknown               1524631552 1658849279  134217728 [SSD_CACHE]
 6 P Unknown               1658849280 1725958143   67108864 [KEEP_A_SPECIAL]
 7 P Unknown               1725958144 1793067007   67108864 [KEEP_LOG]
 8 P Unknown               1793067008 1946159103  153092096 [KEEP_A]



                P=Primary  D=Deleted
 
so i have
1. freebsd wap partition
2. ext4 probably
3. zfs data part of mirror
4. zfs special part of mirror
5. zfs cache part of mirror
6. zfs special part of mirror
7. zfs log (mirrored ?)
8. zfs data (mirrored ?)

Now i must reconstruct somehow table ?
 
did,
Code:
# 1. Initialize the GPT scheme
gpart create -s gpt ada3
# 2. Re-add the partitions using TestDisk's sector math
gpart add -t freebsd-swap -l FREEBSWAPADA3 -b 272631808 -s 134217728 ada3
gpart add -t linux-data   -l NEWREDCORE     -b 2048      -s 272629760 ada3
gpart add -t freebsd-zfs  -l SSD_A          -b 406849536 -s 1048576000 ada3
gpart add -t freebsd-zfs  -l SSD_A_SPECIAL  -b 1455425536 -s 69206016 ada3
gpart add -t freebsd-zfs  -l SSD_CACHE      -b 1524631552 -s 134217728 ada3
gpart add -t freebsd-zfs  -l KEEP_A_SPECIAL -b 1658849280 -s 67108864 ada3
gpart add -t freebsd-zfs  -l KEEP_LOG       -b 1725958144 -s 67108864 ada3
gpart add -t freebsd-zfs  -l KEEP_A         -b 1793067008 -s 153092096 ada3
 
Code:
# 1. Initialize the GPT scheme
gpart create -s gpt ada3

# 2. Re-add the partitions using TestDisk's sector math
gpart add -t freebsd-swap -l FREEBSWAPADA3 -b 272631808 -s 134217728 ada3
gpart add -t linux-data   -l NEWREDCORE     -b 2048      -s 272629760 ada3
gpart add -t freebsd-zfs  -l SSD_A          -b 406849536 -s 1048576000 ada3
gpart add -t freebsd-zfs  -l SSD_A_SPECIAL  -b 1455425536 -s 69206016 ada3
gpart add -t freebsd-zfs  -l SSD_CACHE      -b 1524631552 -s 134217728 ada3
gpart add -t freebsd-zfs  -l KEEP_A_SPECIAL -b 1658849280 -s 67108864 ada3
gpart add -t freebsd-zfs  -l KEEP_LOG       -b 1725958144 -s 67108864 ada3
gpart add -t freebsd-zfs  -l KEEP_A         -b 1793067008 -s 153092096 ada3

    8 sysctl kern.geom.debugflags=16
    9 ./doitx
   10 zpool list -v
   11 zpool import -f KEEP
   12 zpool import -f KEEP2
   13 zpool list -v
   14 zpool replace SSD ufs/NEWUFSp3 gpt/SSD_A
   15 zpool replace -f SSD ufs/NEWUFSp3 gpt/SSD_A
   16 zpool detach SSD ufs/NEWUFSp3
   17 zpool detach SSD ufs/NEWUFSp4
   18 zpool labelclear -f /dev/gpt/SSD_A
   19 zpool labelclear -f /dev/gpt/SSD_A_SPECIAL
   20 zpool replace SSD ufs/NEWUFSp3 gpt/SSD_A
   21 zpool replace SSD ufs/NEWUFSp4 gpt/SSD_A_SPECIAL
   22 # Attach the new gpt/SSD_A to the healthy gpt/SSD_B
   23 zpool attach SSD gpt/SSD_B gpt/SSD_A
   24 # Attach the new gpt/SSD_A_SPECIAL to the healthy gpt/SSD_B_SPECIAL
   25 zpool attach SSD gpt/SSD_B_SPECIAL gpt/SSD_A_SPECIAL
   28 zpool status SSD
   29 mkdir /mnt/redcore
   30 mount -t ext2fs /dev/gpt/NEWREDCORE /mnt/redcore
   31 mount -t ext2fs -o ro /dev/gpt/NEWREDCORE /mnt/redcore
   32 kldload ext2fs
   33 mount -t ext2fs -o ro /dev/gpt/NEWREDCORE /mnt/redcore
   34 pkg install e2fsprogs
   35 tune2fs -l /dev/gpt/NEWREDCORE | grep features
   36 pkg install fusefs-ext2
   37 kldload fusefs
   38 fuse-ext2 -o ro /dev/gpt/NEWREDCORE /mnt/redcore
   39 ls /mnt/redcore/
 
Now i must reconstruct somehow table ?
Slow down!
As I said, you have a lots of pools, drives, and partitions - it's not that easy to get a complete picture.
The only clue obviously jumps to eyes so far is:
Bad GPT partition, invalid signature.
And as far as I got it, it seems to be a problem with your ada3.
Better give a gpart show ada3
and maybe a smartctl -a /dev/ada3 can also help.
 
I think i now recovered most, restored partition table totally manually, now doing some zfs housekeeping,
Code:
41 cat doitx
   42 cd
   43 zpool list -v
   44 cd
   45 zpool import
   46 mkdir -p /mnt/usb_recovery_TWOTERRA
   47 mkdir -p /mnt/usb_recovery_TREETERRA
   48 zpool import -R /mnt/usb_recovery_TWOTERRA -N TWOTERRA
   49 zpool import -R /mnt/usb_recovery_TREETERRA -N TREETERRA
   50 zfs get mountpoint TWOTERRA
   51 zfs get mountpoint TREETERRA
   52 zpool import -N -f TWOTERRA
   53 zpool import -N -f TREETERRA
   54 zpool export TWOTERRA
   55 zpool export TREETERRA
   56 zpool import -N -f TWOTERRA
   57 zpool import -N -f TREETERRA
   58 zfs list -o name,mountpoint,canmount -r TWOTERRA
   59 zfs list -o name,mountpoint,canmount -r TREETERRA
   60 # Fix the TREETERRA /var overmounts
   61 zfs set canmount=noauto TREETERRA/SSD/var
   62 zfs set canmount=noauto TREETERRA/SSD/var/db
   63 zfs set canmount=noauto TREETERRA/SSD/var/db/influxdb
   64 zfs set canmount=noauto TREETERRA/SSD/var/db/pkg
   65 zfs set canmount=noauto TREETERRA/SSD/var/db/postgres
   66 zfs set mountpoint=/mnt/TREETERRA/var TREETERRA/SSD/var
   67 # (Repeat for the sub-datasets if you need them mounted)
   68 zfs list -o name,mountpoint,canmount -r TWOTERRA
   69 zfs list -o name,mountpoint,canmount -r TREETERRA
   70 zpool export TWOTERRA
   71 zpool export TREETERRA
   72 zpool import -f -R /mnt/TWOTERRAX TWOTERRA
   73 zpool import -f -R /mnt/TREETERRAX TREETERRA
   74 zfs mount
   75 zpool import
   76 mkdir /mnt/FOURTERRAX
   77 zpool import -N -f -R /mnt/FOURTERRAX FOURTERRA
   78 zfs list -o name,mount,canmount -r FOURTERRA
   79 zfs list -o name,mountpoint,canmount -r FOURTERRA
   80 zfs set canmount=on FOURTERRA
   81 zfs mount FOURTERRA
   82 ls /mnt/FOURTERRAX/mnt/FOURTERRA/
   83 zfs set canmount=on FOURTERRA
   84 ls /mnt/FOURTERRAX/mnt/FOURTERRA/
   85 zfs mount FOURTERRA
   86 zfs mount FOURTERRA/data
   87 mount | grep FOURTERRA
   88 ls -F /mnt/FOURTERRAX/mnt/FOURTERRA/data
   90 zpool status

seems ok,
 
Its resilvering,
Code:
  pool: SSD
 state: ONLINE
status: One or more devices is currently being resilvered.  The pool will
    continue to function, possibly in a degraded state.
action: Wait for the resilver to complete.
  scan: resilver in progress since Thu Mar 26 08:40:56 2026
    213G / 211G scanned, 89.2G / 211G issued at 46.3M/s
    93.9G resilvered, 42.26% done, 00:44:55 to go
remove: Removal of vdev 7 copied 64.2G in 0h7m, completed on Wed Mar 25 04:13:17 2026
    4.19M memory used for removed device mappings
config:

    NAME                   STATE     READ WRITE CKSUM
    SSD                    ONLINE       0     0     0
      mirror-2             ONLINE       0     0     0
        gpt/SSD_B          ONLINE       0     0     0
        gpt/SSD_A          ONLINE       0     0     0  (resilvering)
    special    
      mirror-6             ONLINE       0     0     0
        gpt/SSD_B_SPECIAL  ONLINE       0     0     0
        gpt/SSD_A_SPECIAL  ONLINE       0     0     0  (resilvering)

errors: No known data errors
 
Finishing,
Code:
   96 zpool add SSD log gpt/SSD_LOG
  100 zpool add SSD cache gpt/SSD_CACHE
  106 zpool remove KEEP2 ada2p6
  107 zpool add KEEP2 cache gpt/KEEP_CACHE
  116 zpool remove TREETERRA ada2p9
  118 zpool add TREETERRA cache gpt/TREETERRA_cache
 
Back
Top