]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
geom_part: make it possible recovering broken GPT after some LBAs cut off
authoreugen <eugen@FreeBSD.org>
Thu, 17 Sep 2020 04:39:39 +0000 (04:39 +0000)
committereugen <eugen@FreeBSD.org>
Thu, 17 Sep 2020 04:39:39 +0000 (04:39 +0000)
commit22eefa8b942ec6f278231dd5b228a573e123aee2
tree89934090b99d06ef7dad6e13a7d103e1a2200370
parentd1c2200b76c345a5f32dbce0c8e79390ca6b0a5a
geom_part: make it possible recovering broken GPT after some LBAs cut off

This is followup to r365477.

If pre-formatted device has GPT and a partition covering
last available LBAs and the device is attached using
a bridge reducing amount of LBAs, then it could be not enough
forcing GEOM to use primary GPT. Also, we should make it possible
to recover GPT and this requires either deleting or resizing the partition.

This change enables "gpart delete" and "gpart resize" commands
on corrupted GPT with following "gpart recover".

It still does not allow modifying corrupted GPT without
preliminary setting sysctl kern.geom.part.check_integrity=0

For example:

# gpart show da0
=>        34  3906963389  da0  GPT  (1.8T) [CORRUPT]
          34      262144    1  ms-reserved  (128M)
      262178        2014       - free -  (1.0M)
      264192  3906764943    2  freebsd-swap  (1.8T)
# gpart resize -i 2 -s 3900000000 da0
# gpart recover da0

Reported by: Alex Korchmar
MFC after: 3 days
sys/geom/part/g_part.c