Friday, March 10, 2023

Recovery ZFS Frebsd

# zpool status
  pool: zroot
 state: DEGRADED
status: One or more devices could not be opened.  Sufficient replicas exist for
        the pool to continue functioning in a degraded state.
action: Attach the missing device and online it using 'zpool online'.
   see: https://openzfs.github.io/openzfs-docs/msg/ZFS-8000-2Q
config:

        NAME        STATE     READ WRITE CKSUM
        zroot       DEGRADED     0     0     0
          mirror-0  DEGRADED     0     0     0
            ada0p3  ONLINE       0     0     0
            ada1p3  UNAVAIL      0     0     0  cannot open

errors: No known data errors`

# zpool detach zroot ada1p3
# zpool status
  pool: zroot
 state: ONLINE
config:

        NAME        STATE     READ WRITE CKSUM
        zroot       ONLINE       0     0     0
          ada0p3    ONLINE       0     0     0

errors: No known data errors
# gpart create -s GPT ada1
ada1 created
root@:/home/rahox # gpart show
=>      40  33554352  ada0  GPT  (16G)
        40      1024     1  freebsd-boot  (512K)
      1064       984        - free -  (492K)
      2048   4194304     2  freebsd-swap  (2.0G)
   4196352  29356032     3  freebsd-zfs  (14G)
  33552384      2008        - free -  (1.0M)

=>      40  33554352  ada1  GPT  (16G)
        40  33554352        - free -  (16G)
 # gpart bootcode -b /boot/pmbr ada1
bootcode written to ada1
# gpart add -t freebsd-boot -s 512K ada1
ada1p1 added

 # gpart show
=>      40  33554352  ada0  GPT  (16G)
        40      1024     1  freebsd-boot  (512K)
      1064       984        - free -  (492K)
      2048   4194304     2  freebsd-swap  (2.0G)
   4196352  29356032     3  freebsd-zfs  (14G)
  33552384      2008        - free -  (1.0M)

=>      40  33554352  ada1  GPT  (16G)
        40      1024     1  freebsd-boot  (512K)
      1064  33553328        - free -  (16G)
root@:/home/rahox # gpart bootcode -p /boot/gptboot -i 1 ada1
partcode written to ada1p1
root@:/home/rahox # gpart add -t freebsd-swap -s 2G ada1
ada1p2 added
root@:/home/rahox # gpart show
=>      40  33554352  ada0  GPT  (16G)
        40      1024     1  freebsd-boot  (512K)
      1064       984        - free -  (492K)
      2048   4194304     2  freebsd-swap  (2.0G)
   4196352  29356032     3  freebsd-zfs  (14G)
  33552384      2008        - free -  (1.0M)

=>      40  33554352  ada1  GPT  (16G)
        40      1024     1  freebsd-boot  (512K)
      1064   4194304     2  freebsd-swap  (2.0G)
   4195368  29359024        - free -  (14G)
root@:/home/rahox # gpart add -t freebsd-zfs ada1
ada1p3 added
root@:/home/rahox # newfs -Uj /dev/ada1p3
/dev/ada1p3: 14335.5MB (29359024 sectors) block size 32768, fragment size 4096
        using 23 cylinder groups of 625.22MB, 20007 blks, 80128 inodes.
        with soft updates
super-block backups (for fsck_ffs -b #) at:
 192, 1280640, 2561088, 3841536, 5121984, 6402432, 7682880, 8963328, 10243776,
 11524224, 12804672, 14085120, 15365568, 16646016, 17926464, 19206912, 20487360,
 21767808, 23048256, 24328704, 25609152, 26889600, 28170048
Using inode 4 in cg 0 for 33554432 byte journal
newfs: soft updates journaling set
root@:/home/rahox # gpart show
=>      40  33554352  ada0  GPT  (16G)
        40      1024     1  freebsd-boot  (512K)
      1064       984        - free -  (492K)
      2048   4194304     2  freebsd-swap  (2.0G)
   4196352  29356032     3  freebsd-zfs  (14G)
  33552384      2008        - free -  (1.0M)

=>      40  33554352  ada1  GPT  (16G)
        40      1024     1  freebsd-boot  (512K)
      1064   4194304     2  freebsd-swap  (2.0G)
   4195368  29359024     3  freebsd-zfs  (14G)
root@:/home/rahox # zpool attach zroot ada0p3 ada1p3
root@:/home/rahox # zpool status
  pool: zroot
 state: ONLINE
  scan: resilvered 762M in 00:00:08 with 0 errors on Sat Mar 11 03:31:29 2023
config:

        NAME        STATE     READ WRITE CKSUM
        zroot       ONLINE       0     0     0
          mirror-0  ONLINE       0     0     0
            ada0p3  ONLINE       0     0     0
            ada1p3  ONLINE       0     0     0

errors: No known data errors

No comments:

Post a Comment