I wanted to repartition my hard disk using KDE Partition Manager running from a USB. Unfortunately, something went wrong, as most of the partitions I wanted to delete are still present and the one I wanted to keep (but with larger size) has lost its filesystem information and, hence, it is unaccessible.

This is how it looks now sda5:

enter image description here

And that is fdisk -l output:

Disk /dev/sda: 596,2 GiB, 640135028736 bytes, 1250263728 sectors
Units: sectors of 1 * 512 = 512 bytes
Disklabel type: dos
Disk identifier: 0x1549f232

Dispositiu Arrencada      Start      Final   Sectors   Size Id Tipus
/dev/sda1  *                 63  540619379 540619317 257,8G  7 HPFS/NTFS/exFAT
/dev/sda2            1224201195 1250258624  26057430  12,4G  7 HPFS/NTFS/exFAT
/dev/sda3             540619441 1224200012 683580572   326G  5 Estesa
/dev/sda5             540620863 1126558362 585937500 279,4G 83 Linux

If I want to change sda5 to its ext4 original filesystem, I get a warning stating that all changes will be lost.

Is there any way to recover original data or is it already lost for good?

Edit: as per @damadam request, this is the lsblk output:

sda      8:0    0 596,2G  0 disk 
├─sda1   8:1    0 257,8G  0 part 
├─sda2   8:2    0  12,4G  0 part 
├─sda3   8:3    0     1K  0 part 
└─sda5   8:5    0 279,4G  0 part 
sdb      8:16   0 232,9G  0 disk 
├─sdb1   8:17   0   450M  0 part 
├─sdb2   8:18   0    99M  0 part 
├─sdb3   8:19   0    16M  0 part 
├─sdb4   8:20   0 111,8G  0 part 
├─sdb5   8:21   0  27,5G  0 part /
└─sdb6   8:22   0  93,1G  0 part /home
sr0     11:0    1  1024M  0 rom  
loop0    7:0    0  86,9M  1 loop /snap/core/4917
loop1    7:1    0  86,6M  1 loop /snap/core/4650
loop2    7:2    0  86,9M  1 loop /snap/core/4830
  • the is a software "recuva" or something like that on windows that does that. so I believe surely that you can recover your old data. though it would be not as good as original. On ubuntu I have no idea but will search around – MaNyYaCk Jul 16 '18 at 6:26
  • itsfoss.com/recover-deleted-files-linux , Take a look at this article – MaNyYaCk Jul 16 '18 at 6:29
  • Your picture is about /dev/sda, but the fdisk output is only about /dev/sdb. Does it say nothing on /dev/sda? – muclux Jul 16 '18 at 6:33
  • @muclux you're right: I copied the wrong output. I have fixed it on the question. – ccamara Jul 16 '18 at 6:37
  • @ccamara you can try to access on your partition by mounting it with sudo mount /dev/sda5 /opt and accessing it with sudo chroot /opt; if these 2 commands works, ping me because I can't ensure that you can restore your data like that – damadam Jul 16 '18 at 7:38

For further reference: Following @MaNyYaCk's advice, I have managed to recover the partition using Testdisk

  1. Download from https://www.cgsecurity.org/wiki/TestDisk_Download and uncompress
  2. Locate the folder download on #1 and run command sudo ./testdisk_static
  3. Click on create enter image description here
  4. Navigate through the hard drive(s) and select the desired one and then the command Proceed.
  5. Select the type of partitions, which in my case was Intel (usually makes a reasonable guess and selects it accordingly) enter image description here
  6. Select the partitions you want to work with and then select Analyse command.
  7. Select Quick Search command. After a while (it can take some time) it will find the partitions on that drive and you will see new options available.
  8. Click on the new write option that appeared after #7 (if it is not available you may want to make a Deep search instead of a quick one). You will be asked to confirm that you want to write partition table. enter image description here
  9. If everything goes as expected your partitions will be recovered and available again (it may require to reboot)

Your Answer

