I'm running ubuntu 16.04 on a Lenovo P50.

I have 2 SDDs on my laptop as follows:

  • /dev/sda - 256GB, has both a linux and windows partition
  • /dev/sdb - 512GB, single fat32 partition, use to store large data files (all of which are either unimportant or backed up elsewhere)

I wanted to move windows to /dev/sdb so that my linux partition could take up all 256GB of /dev/sda. To do that, I first wanted to shrink my /dev/sdb "data storage" partition.

To shrink my /dev/sdb partition, I opened gparted and used the "resize partition" operation to shrink my /dev/sdb partition to 128GB. GParted reported that it completed the operation successfully.

I closed gparted and re-opened it. When I reopened it, it reported that the size of my /dev/sdb partition was unchanged and it was still taking up the entire 512GB of the drive. I did the "resize" operation again. After doing the resize operation a second time, the partition table became corrupted. GParted was no longer able to detect the file system.

Testdisk was not able to detect my fat32 filesystem either. fdisk reported 4 partitions of random sizes, suggesting that the partition table was corrupted.

I plan to shuffle around some important data in the future, and I want to know

  • What I did wrong
  • Why this happened
  • How can I recover my data (I'm willing to open a hex editor and pick through it by hand)
  • How do I prevent this in the future?

What I did wrong

First mistake was using FAT32 and assuming you could save larger files. FAT32 does not have a journal, to make recovery/repair easier and cannot save files over 4GB. It may say you saved it but only first 4GB saved.

When gparted said it worked but did not show it, you should have immediately stopped an investigated why. May have needed chkdsk which is really slow on FAT32 as no journal.

Why this happened

Not sure, usually gparted works, but often better to use Windows tools for Windows & Linux tools for Linux. Then you do not blame Linux for corrupting a Windows file system.

How can I recover my data (I'm willing to open a hex editor and pick through it by hand)

You probably should use ddrescue or similar tools to image drive. Then you can use photorec which is part of testdisk to scan drive for anything that looks like a file. Since only one partition, you then could just try resetting partition table and see if chkdsk or dosfsck works.

How do I prevent this in the future?

I now like gpt as it has backup partition table over MBR(msdos), but Windows only boots in UEFI mode from gpt. Ubuntu can be UEFI or BIOS boot from gpt. I would suggest reinstalling Ubuntu rather than moving Windows. You then could move /home & data into new install easily before deleting old install. If you want a data partition for sharing data use NTFS.

  • Thank you very much for the suggestion of using photorec. I'm surprised that I didn't come across it as I was researching linux file recovery tools. It does a very good job. – johnny_boy Jan 14 '17 at 18:35

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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