Recovering a failed GPT disk: Difference between revisions

From Notes to self
Jump to navigation Jump to search
No edit summary
m Verbovet moved page Recovering a failed GPT drive to Recovering a failed GPT disk without leaving a redirect
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
* before hot replacing a disk, say <code>ada5</code>, run
* before hot replacing a disk (say <code>ada5</code>) run
:<code># zpool offline zroot ada5</code>
:<code># zpool offline zroot ada5</code>
:and check
:and check
Line 5: Line 5:
* Insert a new physical disk
* Insert a new physical disk
* Copy the partition table to the new disk from a healthy one
* Copy the partition table to the new disk from a healthy one
:<code># gpart backup ada0 | gpart restore -F ada5</code>
* Label all partitions with the commands:
* Label all partitions with the commands:
:<code># gpart modify -l LABEL -i1 ada5</code>
:<code># gpart modify -l LABEL -i1 ada5</code>
* Fill the EFI partition:
* Fill the EFI partition:
:<code>#newfs_msdos -F 32 -c 1 /dev/ada5p1</code>
:<code># newfs_msdos -F 32 -c 1 /dev/ada5p1</code>
:<code># mount -t msdosfs /dev/ada5p1 /mnt</code>
:<code># mount -t msdosfs /dev/ada5p1 /mnt</code>
:<code># mkdir -p /mnt/EFI/BOOT /mnt/EFI/FREEBSD</code>
:<code># mkdir -p /mnt/EFI/BOOT /mnt/EFI/FREEBSD</code>
Line 15: Line 16:
:<code># umount /mnt</code>
:<code># umount /mnt</code>
* Fill the freebsd-boot partition:
* Fill the freebsd-boot partition:
:<code>#gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 2 ada5</code>
:<code># gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 2 ada5</code>
* Check:
* Check:
:<code>#loaders-update  show-me</code>
:<code># loaders-update  show-me</code>
* Return ada5p3 to the ZFS pool:
* Return ada5p3 to the ZFS pool:
:<code>#zpool replace zroot ada5p3</code>
:<code># zpool replace zroot ada5p3</code>


[[Category: FreeBSD]]
[[Category: FreeBSD]]
[[Category: Hardware]]
[[Category: Hardware]]

Latest revision as of 22:17, 13 December 2025

  • 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