I was running Windows under dual-boot with Ubuntu 14.04.

I accidentally opened Windows native disk manager and set the C: drive as active. It turned my Ubuntu extended partition into free space (unallocated space). Now my computer does not boot, showing grub rescue prompt.

I booted using an Ubuntu live CD, and ran Gparted. Gparted also shows the space unallocated.

So, have I completely lost my Ubuntu installation and files? Is there a way to recover my Ubuntu installation and files?


I solved the problem using GNU Parted. Other methods of recovering are mentioned in the Ubuntu Documentation.
Advantage of choosing GNU Parted:
No need to download it, it is included in Ubuntu base.

How to use GNU Parted

Run Parted from the command line to recover your partition.

When changing the partition table on your hard drive, you must ensure that no partition on the disk is mounted. This includes swap space. The easiest way to accomplish this is to run the live cd. Parted is installed on the base Ubuntu system. Once at the desktop, open a terminal and run_:

sudo swapoff -a or you can use Gparted partition editor to achieve the same. Next run parted and tell it to use the device in question.

For example, if your /dev/sda drive is the drive from which you want to recover, run:

sudo parted /dev/sda

Enter the following command to ensure the unit used is 's':

unit s

Now you can use the print and rescue command to recover your partition as explained in the user manual as follows:

Enter the following command to get details of all partitions and their start and end locations:


Now we can enter the final rescue command:

rescue START END

Use the values for start and end from the output of the print command.

If you have more than one partition to recover, repeat you rescue command.

You won't need to restore GRUB.


I would go about it in these steps:

  • Boot the Ubuntu Live CD
  • sudo apt-get install testdisk
  • Run testdisk, and try to recover the partition from there.

Probably Windows just removed the partition definition from the partition table, which will take just a few seconds for testdisk to fix. Then grub should also work automagically. If the problem's worse, testdisk may only be able to recover some of your files; in that case I'd deem it unfeasible to fix the installation itself; I'd just back up the files worth backing up and reinstall Ubuntu.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.