Recreating a partition table from an existing device-mapper table

Solution Verified - Updated -

Issue

WARNING
The following method is provided as a commercially reasonable effort only. It is not an official method, and only to use as a last resort.

A partition table has been accidentally deleted on a multipathed disk. However, the machine has not been rebooted and the kpartx mappings still exist.

It is possible to use the mapping information to recreate the partition table.

For example :

# multipath -l testings
testings (1IET     00020001) dm-5 IET,VIRTUAL-DISK
size=1.0G features='0' hwhandler='0' wp=rw
|-+- policy='round-robin 0' prio=0 status=active
| `- 2:0:0:1 sde 8:64  active undef running
`-+- policy='round-robin 0' prio=0 status=enabled
  `- 3:0:0:1 sdg 8:96  active undef running
# fdisk -l /dev/sde

Disk /dev/sde: 1073 MB, 1073741824 bytes
34 heads, 61 sectors/track, 1011 cylinders
Units = cylinders of 2074 * 512 = 1061888 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


# dmsetup table | grep testings
testingsp4: 0 860710 linear 253:5 1236104
testingsp3: 0 410652 linear 253:5 825452
testingsp2: 0 410652 linear 253:5 414800
testingsp1: 0 414739 linear 253:5 61
testings: 0 2097152 multipath 0 0 2 1 round-robin 0 1 1 8:64 1 round-robin 0 1 1 8:96 1 

In the example above, the partition table has been zeroed and partprobe has been rerun to update the partitions. However, luckily, kpartx is still remaining and the maps can still be used... until kpartx flushes the maps (example : if the machine reboots)

How to use this information to rebuild the partition table ?

Environment

  • Red Hat Enterprise Linux v.4 v.5 v.6
  • Device Mapper Multipath
  • MSDOS partition table

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.