Partition table — repair / reinstall / copy for future

Puneet Singh
techpsl
Published in
2 min readMar 15, 2011

Part 1: Backup your partition table: Either you are Windows or Linux user it does not matter, for backing up there are very simple steps but before that start for computer with Linux live cd if you do not have that you can download it from http://www.ubuntu.com or get.fedoraproject.org burn it to a CD and boot the CD to run the live Linux system.
Once you have running system then insert any pendrive or mount any of your partitions. Using terminal change your directory to pendrive or the mounted drive.
For example:

puneet@puneet-laptop:/media$ cd /media/funnsongs/
puneet@puneet-laptop:/media/funnsongs$


Now we can start the process of backing up your partition table.
As said prevention is better than cure this is strongly recommended that one should take a copy of his/her partition table before hand.
In terminal write =>

mkdir backupcd backupsudo dd if=/dev/sda of=backup-sda.mbr count=1 bs=512sudo sfdisk -d /dev/sda > backup-sda.sf

Remove Pendrive and reboot your system. Now these two files are your life Saviour. Keep them at safe place. (Remember do the same procedure whenever you do any changes to your partitions)


Part 2: Reinstall your backup of Partition table: Do the same procedure as above to reach to any directory where your backup files are stored.
Now in terminal write:

sudo dd if=backup-sda.mbr of=/dev/sdasudo sfdisk /dev/sda < backup-sda.sf

reboot your computer and ta-da your partition table is recovered.

Part 3: Repair any damaged partition table: This can be a complicated task because it all depends on how your partition table got corrupted.
But there are solution for many problems by using these simple steps.Boot from Linux live CD.
Go to Terminal and write:

sudo fdisk /dev/sdaCommand (m for help):p {press enter}

see the result
for example:

Device Boot Start End Blocks Id System
/dev/sda1 1 2580 20723818+ 83 Linux
/dev/sda2 ? 2581 6954 35134155 7 HPFS/NTFS
/dev/sda3 6955 30402 188338284+ 5 Extended
/dev/sda5 6955 13328 51199092 7 HPFS/NTFS
/dev/sda6 13329 18427 40957686 7 HPFS/NTFS
/dev/sda7 18428 20977 20481024 7 HPFS/NTFS
/dev/sda8 20978 27351 51199123+ 7 HPFS/NTFS
/dev/sda9 27352 27482 1052226 82 Linux swap / Solaris
/dev/sda10 27483 30074 20820208+ 7 HPFS/NTFS
/dev/sda11 30075 30402 2626560 83 Linux

If you see question mark in your Boot list there is the error.
now

Command (m for help):a {press enter}Partition number (1-11):2

Now if you will see partition table again using ‘p’ then you will not see that ‘?’ in boot list.

and some of the other problems can be solved using

Command (m for help):vCommand (m for help):xCommand (m for help):fCommand (m for help):wCommand (m for help):q

Thats it, now try to reboot and if still it does not help Google your specific problem.
If you have any problem you can post your queries in comments below.
Note: sda wherever is used can sometimes also considered as hda by some systems so if using sda is showing error then use hda instead of sda.

--

--

Puneet Singh
techpsl

Machine Learning @ Factset, ex-blogger, wannabe-writer, Science-lover, student for life. Other interests: Entrepreneurship, Photography, Politics, SelfHelp