1

I accidentally created a new partition table in a disk full of data which removed all the partition. Using testdisk, I am able to get the partition back but the filesystem is corrupt or damaged. Please help me with this.

➜  ~ sudo fdisk -l /dev/sdc
[sudo] password for therimalaya: 
Disk /dev/sdc: 3.7 TiB, 4000787030016 bytes, 7814037168 sectors
Disk model: ST4000DX001-1CE1
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x69747429

Device     Boot      Start        End    Sectors  Size Id Type
/dev/sdc1  *          2048 4294969342 4294967295    2T 83 Linux
/dev/sdc2       4294967295 6442450942 2147483648    1T  7 HPFS/NTFS/exFAT
/dev/sdc3       4294967295 5666549758 1371582464  654G  7 HPFS/NTFS/exFAT

Partition 2 does not start on physical sector boundary.
Partition 3 does not start on physical sector boundary.

The output from gdisk is,

➜  ~ sudo gdisk -l /dev/sdc  
GPT fdisk (gdisk) version 1.0.4

Partition table scan:
  MBR: MBR only
  BSD: not present
  APM: not present
  GPT: not present


***************************************************************
Found invalid GPT and valid MBR; converting MBR to GPT format
in memory. 
***************************************************************

Disk /dev/sdc: 7814037168 sectors, 3.6 TiB
Model: ST4000DX001-1CE1
Sector size (logical/physical): 512/4096 bytes
Disk identifier (GUID): D8EB0151-7B96-419A-A938-15F0CC02FEB5
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 7814037134
Partitions will be aligned on 8-sector boundaries
Total free space is 1371588206 sectors (654.0 GiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048      4294969342   2.0 TiB     8300  Linux filesystem
   2      4294967295      6442450942   1024.0 GiB  8300  Linux filesystem
   3      4294967295      5666549758   654.0 GiB   8300  Linux filesystem
  • Your listed partitions are total nonsense -- two and three both start at the same place, and overlap one. Alignment is the least of your problems. Do you remember how many partitions you originally had on the disk? Was it really msdos partitioned and not gpt? – ubfan1 Apr 21 at 23:37
  • Yes, I know. afterwards, I managed to give some sensible start and end and managed the get the partition back but all the files are gone. I had to use PhotoRec which didn't help much since I gut all file jumbled with arbitrary names. However, I was able to recover some photos and videos. – TheRimalaya Apr 28 at 10:55
0

Sectors are the minimum unit of data that the disk hardware can read (what is actually on the disk platters or the SSD memory cells is a different question, but is not relevant at this point). When space is allocated on disk for a file, it is allocated in sectors; if your file is smaller than an (integral) multiple of the sector size, the last remaining bytes of a sector are wasted. In the old days when disks were a lot smaller, a 512-byte sector was a good compromise between the average file size and the acceptable waste (do not confuse the physical sector size with the filesystem block size). With increased density, 512-byte physical sectors have not made sense in the last 10-20 years; spinning drives have had 4KB (8 * 512 byte) sectors for a long time now. Even though you can access stuff on disk at pretty much arbitrary offsets, operations are slightly faster if you access them at sector boundaries.

You can change the partition start and end offsets to be a multiple of 8 sectors (or 4096 bytes, whichever unit gpart uses; I use parted) and remake the partitions, and everything will be happy!

0

You did not get your partitions back using TestDisk: they're a total jumble. You're better off using PhotoRec to restore individual files.

Good luck! (You'll need it, unfortunately...)

  • I had to do this. All the folder structure are gone. This is not the bad part, the filenames are gone too. Eventually, I keep some photos and videos and removed all the files. Maybe this is a way to clean up old junks :-). Anyway thanks for the reply. – TheRimalaya Apr 28 at 10:52
  • Please don't thank me! ;-) If this answer did help, just click the little grey at the left of this text right now turning it into beautiful green. If you do not like the answer, click on the little grey down-arrow below the number, and if you really like the answer, click on the little grey ☑ and the little up-arrow... If you have any further questions, just ask another one! ;-) @TheRimalaya – Fabby Apr 28 at 10:53

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.