12 July 2010

Restore lost partition with fdisk

Unfortunately, there is various situations where partition can "vanish" (bad manipulation, unwanted application behaviour, issue while using a partition manager ...).
Some years ago, I've started using a very simple rule:
Save the result of fdisk -l into a text file after each disk/partition management

It is very simple, it takes very few time and it can save many hours avoiding awful situations and some times data loss.

If ever you lost a partition:
 - start with a GNU/Linux LiveCD (e.g. Fedora)
 - retrieve your fdisk output (in particular first and last cylinders, indicated under "start" and "end" columns)
 - launch fdisk in interactive mode on the regarded device (e.g. /dev/sda)
fdisk /dev/sda
 - restore missing partition using first and last cylinder (typing 'n' for new partition)
 - if needed, update the type of partition (typing 't' for changing partition' system ID; then 'L' to get the list of available codes)
 - save changes (typing 'w')

If nothing has been written on the corresponding disk space, you will get back lost partition without data loss.

No comments:

Post a Comment

Thank you for your visit, let's share your point of view: