I accidentally deleted the root partition using the default partition editor, the partitions just disappeared. When I open GParted, I receive the following error message :

Partition(s) 6, 7, 8, 9 on /dev/sda have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use.  As a result, the old partition(s) will remain in use.  You should reboot now before making further changes.

I want to restore the partitions because it seems that the kernel is still keeping a cached image. How can I restore the partitions (before rebooting)?

  • What "default partitions editor" exactly did you use? Was it 'fdisk' or a GUI tool, and if the latter, which? Not Gparted, apparently... – Zeiss Ikon Dec 28 '16 at 15:46
  • Its a GUI tool: Its called Disks simply.I have a bad feeling that if I restart the system, I'll lose the partition – SoWhat Dec 28 '16 at 15:54
  • MBR or gpt? Either way back up partition table before rebooting. And make sure you have working repair/live Ubuntu disk. If MBR sudo sfdisk -d /dev/sda > parts_sda.txt & save file to repair disk or other device. If gpt: sudo sgdisk --backup=table /dev/sda If not rebooted recover partition: ubuntuforums.org/showpost.php?p=10364557&postcount=34 – oldfred Dec 28 '16 at 15:57
  • Write the old partition start and end down or take a picture with another device like a phone. It'll be no fun trying to find your list in a file in a filessytem which is not in a partition any longer. – ubfan1 Dec 28 '16 at 16:59
  • Yes, that's what I did. Took a dump from fdisk and restored it. Then booted using grub command line use(hd0,msdos8) and finally restored grub. Everything works, except I can't change the partitions anymore – SoWhat Dec 29 '16 at 12:16

If you have done all that from within the running operating system and did not click the Apply button in GParted, you may be VERY lucky, because normally deleting the root partition is not possible this way - this has to be done from a Live media with unmounted partitions. So, when you reboot everything should be as it was before. In case not, you unfortunately are lost - you only can restore the system from a backup image, which hopefully you have created before.

|improve this answer|||||
  • I didnt' do it in Gparted. It happened in the system partition editor (Disks) . I opened GParted to check what's going on. Everything works hunky dory, except thepartitions don't show up on system editor. They show up on GParted with an exclamation mark before them . and the error message as shown . – SoWhat Dec 28 '16 at 15:45
  • By everything being okay, I mean the partitions are mounted fine. All the files are there and everything. It doesn't show up in the partition list – SoWhat Dec 28 '16 at 15:46
  • @SomeshMukherjee : Boot from an Ubuntu installation media, select Try Ubuntu without installing - open GParted and check whether the error messages are gone - additionally open Disks and check for the same. If everything looks okay, reboot into the Ubuntu operating system and re-check everything again. :) – cl-netbox Dec 28 '16 at 15:52
  • You sure the partitions won't disappear when I do that. I checked somewhere and it said the kernel maintains a permanent cache of the table when the partitions are in use and refreshes on restart. When I open Disks, the partitions are gone, but in Gparted,they're still there. – SoWhat Dec 28 '16 at 15:55
  • @SomeshMukherjee : You have done something you shouldn't have done, but as I say in my answer, you most probably are lucky that "nothing" happened ... so rebooting is definitely necessary ... you have no other chance ! Good chances are that after checking and rebooting everything will show up correctly. :) – cl-netbox Dec 28 '16 at 16:08

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.