I have been running a dual-boot of Windows 10 and Ubuntu 20.04 on my pc. Ubuntu is installed on a 250gb m.2 ssd and Windows is installed on a 1tb hdd.

I was booted into Ubuntu and I was using the stock disks and partition tool to erase and reformat some flash drives. I was somewhat distracted by a telephone call and I accidentally erased a partition on my Ubuntu drive. Terrible mistake.

On the drive, there was a ~250gb partition that my files and the OS were installed on as well as another <1gb partition. I erased the smaller partition.

After realizing my mistake, I formatted the small partition to ext4. I then backed up some important files and rebooted the PC.

I am no longer able to boot into Ubuntu. I'm pretty sure that I'm going to have to reinstall Ubuntu, but I need to recover the files from the main partition.

I booted into Windows and mounted the drive but I am unable to access it due to security/permissions. I would say that I have intermediate computing skills but this issue is simply beyond my level of expertise.

I'm pretty sure that I could probably boot into Linux from a flash drive, mount the broken drive, access the files and back them up. Then I could reinstall the OS and that should fix the problem.

I wanted to post this to first help me understand the problem better. I want to know what exactly was on that partition and what was its function.

Secondly, I'd like a recommendation for a best course of action. I am self employed and I run my business from this PC. I was right about to set up a backup solution to prevent issues like this, but I guess I wasn't quick enough.

So what did I break? How do I fix it? Any and all responses are much appreciated. Thank you for reading and thank you for any assistance you may be able to provide.


Solution 1:

All you did wrong was to overwrite the 1GB boot partition, so all your Ubuntu files did not get overwritten and you can make both Ubuntu and Windows able to boot by using GParted and the Boot-Repair-Disk live USB.

  1. Run an Ubuntu live session from the same USB/DVD that you used to install Ubuntu. Check that none of the files on the 250GB hard drive partition that have Ubuntu installed on it were overwritten. Optionally you can backup the files that you want to save from the 250GB to another storage device such as an external hard drive at this time, or boot to another Ubuntu live USB session and back them up later.

  2. Reformat the 1GB partition that you mistakenly formatted to ext4 to FAT32 using the built-in GParted partition editor. You don't have to worry about the boot partition's flags because this will be done automatically in the following steps.

  3. Insert another USB flash drive and make a Boot-Repair live USB. The instructions on that website recommend using UNetbootin which the Ubuntu repositories doesn't have, but you can use the built-in Startup Disk Creator application instead. I've used Startup Disk Creator to make five different updated live USBs that were originally made with UNetbootin and all five of the live USBs that were made with Startup Disk Creator were able to boot successfully.

  4. Shutdown the computer, remove the Ubuntu live USB, boot the computer from the Boot-Repair USB and click the Recommended repair button.

  5. After the Boot-Repair recommended repair is finished, test if both Ubuntu and Windows are able to boot successfully and you are done.

  6. If Ubuntu still can't boot after running the Boot-Repair live USB, your computer at least has a boot partition that the Ubuntu installer is able to recognize and install grub in it, and you should be able to reinstall Ubuntu without losing data in the existing home directory. Before you reinstall Ubuntu you should backup any files that you want to backup by following the instructions in Step 1.

Solution 2:

Since it is ssd, if you have TRIM enabled, then it may be difficult to recover the data if it has been deleted. Then going to a professional would be the best option. If you had multiple partitions in the ssd with os and data in separate partitions or formatted just the small <1gb partition, then you can just "boot into Linux from a flash drive, mount the broken drive, access the files and back them up" as you mentioned in your post.