abril 12, 2012

Corrupción de tablas GPT

Últimamente los Ubuntu suelen instalar por defecto el tipo de tabla de particiones GPT, un estándar basado en EFI que reemplaza el viejo MBR. Hemos tenido un problema con la corrupción (aparente) de una de estas tablas, grub dejó de tener acceso a su partición y por tanto de arrancar el sistema, tras muchas vueltas una de las soluciones ha sido reescribir la tabla de particiones, para ello arrancando desde un livecd:
livecd ~ # parted /dev/sda
(parted) p
Warning: /dev/sda contains GPT signatures, indicating that it has a GPT table.  However, it does not have a valid fake msdos partition table, as
it should.  Perhaps it was corrupted -- possibly by a program that doesn't understand GPT partition tables.  Or perhaps you deleted the GPT
table, and are now using an msdos partition table.  Is this a GPT partition table?
Yes/No? yes
Model: ATA ST2000DL003-9VT1 (scsi)
Disk /dev/sda: 2000GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start   End     Size    File system  Name  Flags
 1      17.4kB  1018kB  1000kB                     bios_grub
 2      1018kB  257MB   256MB   ext2
 3      257MB   2000GB  2000GB                     lvm
Como vemos nos avisa de que a pesar de que hay firmas GPT algo raro ha pasado, posiblemente esté leyendo la tabla de backup. Como aun tenemos toda la información con realizar un pequeño cambio para que se sobreescriba será suficiente:
(parted) set
Warning: /dev/sda contains GPT signatures, indicating that it has a GPT table.  However, it does not have a valid fake msdos partition table, as
it should.  Perhaps it was corrupted -- possibly by a program that doesn't understand GPT partition tables.  Or perhaps you deleted the GPT
table, and are now using an msdos partition table.  Is this a GPT partition table?
Yes/No? yes
Partition number? 1
Flag to Invert? bios_grub
New state?  on/[off]? on
Volviendo a rearrancar el parted:
livecd ~ # parted /dev/sda
GNU Parted 3.0
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p
Model: ATA ST2000DL003-9VT1 (scsi)
Disk /dev/sda: 2000GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start   End     Size    File system  Name  Flags
 1      17.4kB  1018kB  1000kB                     bios_grub
 2      1018kB  257MB   256MB   ext2
 3      257MB   2000GB  2000GB                     lvm

(parted) q
livecd ~ # vgscan
  Reading all physical volumes.  This may take a while...
  Found volume group "XXX" using metadata type lvm2
Ahora ya tenemos acceso a la partición donde teníamos el lvm, igualmente grub ya puede localizar de nuevo su referencia y arrancar el sistema correctamente.

comentarios: