Data rescue after partition moving failed

On my home PC, I’ve had the following partitions on a 1 TB SSD:

  • EFI
  • 64 GB swap
  • 32 GB Manjaro /
  • 64 GB Manjaro /home
  • empty space
  • 500 GB /data

Since my 32 GB / was full, I booted to another Linux Desktop using a boot stick. There I used the KDE Partition Manager to:

  1. move /home by 32 GB
  2. increment / by 32 GB

But the program failed, and it resulted that both, / and /home were lost (displayed as empty partitions). I’ve tried to boot, but unsuccessfully. I ran the gparted data rescue from the boot stick for more than 12h, but no data was found.

Most of the data saved on /data, but there is still some important data left on those partitions. Is there another possibility to get back these data?
Since I know where the old partitions sectors were, can I manually set a partition without losing the data on it?


Thankfully, I have my work laptop I can use as a workaround, but it would be nice to use my PC again. I hope some can help me quick.

testdisk from Manjaro extra repository might recover some of the data, but that will probably take a long time and it can create a lot of partially recovered fragments
If you do not have much free space on /data partition I would suggest recovering data from /home partition to an external USB drive if possible

1 Like

You DID take a backup of your data BEFORE you went playing with partitions ? If yes (I’m sure, you did eh), simply restore your data from the backup and be done…
Cheers,
Eddy

1 Like

I used Testdisk in the past to recover data from a partition.

Be aware though, that anything you do will damage data on the disk - by the time I recovered some 600 photos I’d stored (in 2007) about 20% of them were damaged files.

Best plan - boot Manjaro from USB, then plug in a HDD, and use Testdisk to recover what you can.

After today, with a 1TB SSD in the machine, you need to work out how to backup before doing any partition work. I think I would have been inclined to do a ‘Timeshift’ rsync backup to a HDD, and then copied any personal data to a backup folder, before just installing to the whole 1TB space with no partitions… then restoring the snapshot and copying back folders.

This is not the first time this has happened to someone!

  1. Make backups before changing partitions!
  2. Use gparted afterwards (which has been proven to work very well)

This is not a help for this case, but an important tip for anyone passing by.
:footprints:

1 Like

Thanks for your replies!

I will try testdisk this evening and hope I get some data back.

And no I didn’t made a backup of the data in /home, since I store almost all important files on /data, which is the partition I back up frequently.
When I did some bigger partition edits some time ago, I backed up the partitions just in case. But I thought for just some small changes nothing should break and ignored that. But now I’ve learned my lesson.

I will reply again with an update in about 12h when I’m back home and tried testdisk. Thanks again!

1 Like

If you know the exact partition layout - e.g. you dumped the partition table to file - you can restore that layout.

Moving a partition involves an exorbitant amount of free space - it is not just move.

Resizing a partition to the right - extending - is usually safe - but moving a partition is almost never safe - especially if it contains a lot of data.

Your best option is to

  1. use dd to create an image of the disk and place it on a secondary disk for safe keeping.
  2. cut your losses
    • that is
      • remove the home partition
      • extend your root partition
        • set it’s partition type guid to 8304 Linux x86-64 root (/)
      • create a new home partition using cgdisk
        • set it’s partition type guid to 8302 Linux /home
      • comment reference in fstab to root and home (don’t worry - system will find and moun anyway)
  3. Restore your home data from your backup

When your desktop is back up - you can decide on further action.

You can mount the img file using loop device and do forensic recovery on the mounted image.

That sounds interesting. I will do it this evening.
Since I know that I configured exactly 32 GiB and 64 GiB for / and /home, I think I can export the current table to a file, edit it to match the previous sectors and import it again should work, right?

Thanks for the explanation, I’ll try to remember it.

Wow I did it.

  1. I’ve dumped the current, corrupted partition table to file
  2. calculated the missing partition start & size sectors by what I knew
  3. imported the file again
  4. booted again and it worked
sudo sfdisk -d /dev/sda > sda.partition.table.txt
nano sda.partition.table.txt
sudo sfdisk /dev/sda < sda.partition.table.txt --force
reboot

Source: https://www.cyberciti.biz/faq/linux-backup-restore-a-partition-table-with-sfdisk-command/

4 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.