Recovering a failed GPT disk
- before hot replacing a disk (say
ada5) run
# zpool offline zroot ada5- and check
# zpool status
- Insert a new physical disk
- Copy the partition table to the new disk from a healthy one
# gpart backup ada0 | gpart restore -F ada5
- Label all partitions with the commands:
# gpart modify -l LABEL -i1 ada5
- Fill the EFI partition:
# newfs_msdos -F 32 -c 1 /dev/ada5p1# mount -t msdosfs /dev/ada5p1 /mnt# mkdir -p /mnt/EFI/BOOT /mnt/EFI/FREEBSD# cp /boot/loader.efi /mnt/EFI/BOOT/BOOTX64.efi# cp /boot/loader.efi /mnt/EFI/FREEBSD/# umount /mnt
- Fill the freebsd-boot partition:
# gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 2 ada5
- Check:
# loaders-update show-me
- Return ada5p3 to the ZFS pool:
# zpool replace zroot ada5p3