Recover Partition Table After Remove Partition (parted)

6,390

Solution 1

I figured out how to recover my system. Just in case anyone else has the same problem, I'll outline what I did.

First I ran testdisk, which (mostly) recovered my partition table. Now it shows:

1      32.3kB  99.1GB  99.1GB  primary   ntfs            boot
2      208GB   238GB   30.2GB  primary   ext4
3      238GB   240GB   2012MB  extended                  lba
5      238GB   240GB   2009MB  logical   linux-swap(v1)
4      240GB   250GB   9977MB  primary   ntfs

Than, I rebooted as testdisk asked me to do. However, upon trying to boot GRUB failed and went into rescue mode. I then booted from a Ubuntu Live CD, ran boot-repair which fixed GRUB and restarted a final time.

It is now running and I cannot see any problems with it, although I still have not figured out how to extend my partition.

Solution 2

The total data storage space of a PC HDD can be divided into at most four primary partitions, or alternatively three primary partitions and an extended partition. These partitions are described by 16-byte entries that constitute the Partition Table, located in the master boot record.

A primary partition contains one file system.

An HDD may contain only one extended partition; the extended partition can be subdivided into multiple logical partitions.

You deleted :

3 208GB 240GB 32.2GB extended

which contained:

5 208GB 238GB 30.2GB logical ext4 6 238GB 240GB 2009MB logical linux-swap(v1)

I don't believe that you would be able to extend this ext 4 partition to more than 2Gb (the size of swap if you had deleted it)

As soon as you restore your data from ext4 you will need to delete 3 extended partition again, and if you want to make the new partition bigger, you will need to resize 1 or 2(make one of them or both less). The extra space you can take is only, in your case, from 1 or 2 partitions (both are ntfs in your case). iif you are able to run Windows still, it would be probably easier for you to involve windows software to operate., so I would advise Partition Wizard Mini Tool

As for restoring your partition, if it is from Windows again, try for example Partition Recovery , it promises:

Recover data from deleted partitions (accidentally deleted or using programs)

Restore files from lost partition caused by repartitioning, boot manager, hard drive crash, virus attack, system installation, etc.

Gat data back from quick or full formatted partition

Recover files from corrupted partition with "Disk is not formatted" error

Recover data from inaccessible partition, hard drive, USB drive, floppy disk, etc.

Recover data from FAT/NTFS/EXT2/EXT3 partition

Restrive data from reformatted volumes or devices

Recover data from RAW partition or when no files can be read from RAW disk, RAW USB drive, RAW SD card, etc.

Recover data after an MBR corruption

Recover data from improper or other partition errors

UPDATE: Okay, now, if you came to the new partition structure, as can be viewed from your answer below, you can extend your ext4. Now it is easier, because it became a primary partition, not logical as it was before. It is assuming that you have enough free space at 1 partition and you are ready to sacrifice it to another one. So just run Gparted if you don't have it then install it sudo apt-get install gparted or from here enter image description here

and resize 1 ntfs, make it less, make your 2 ext4 partition bigger by pulling its left border to the left side, where the 1 ntfs partition ends. Press Apply every time you want to write changes to the disk.

Share:
6,390

Related videos on Youtube

Ethan H
Author by

Ethan H

Updated on September 18, 2022

Comments

  • Ethan H
    Ethan H over 1 year

    I deleted a partition using (parted) rm 3, so I could extend my ext4 partition. Here was my partition table before I removed it:

    Disk /dev/sda: 250GB
    Sector size (logical/physical): 512B/512B
    Partition Table: msdos
    
    Number  Start   End     Size    Type      File system     Flags
    1      32.3kB  99.1GB  99.1GB  primary   ntfs            boot
    3      208GB   240GB   32.2GB  extended                  lba
    5      208GB   238GB   30.2GB  logical   ext4
    6      238GB   240GB   2009MB  logical   linux-swap(v1)
    2      240GB   250GB   9977MB  primary   ntfs
    

    After I ran (parted) rm 3 it shows up like this:

    Disk /dev/sda: 250GB
    Sector size (logical/physical): 512B/512B
    Partition Table: msdos
    
    Number  Start   End     Size    Type     File system  Flags
    1      32.3kB  99.1GB  99.1GB  primary  ntfs         boot
    2      240GB   250GB   9977MB  primary  ntfs
    

    Since I only removed number 3, I don't understand where my ext4 partition and my linux-swap(v1) partition went. I am attempting to restore my partition table using sudo gpart /dev/sda, however I read online that it doesn't support ext4 partitions.

    Anyone have any suggestions? I would like my ext4 and linux-swap(v1) partitions back, and ideally to extend the ext4 partition to use the empty space before it.


    EDIT:

    gpart failed to find my correct partition. I am now trying to use testdisk which will hopefully correctly identify my partition table.

  • Ethan H
    Ethan H almost 10 years
    I realize what I did wrong now. I just shrunk partition 1 and, completely not thinking, assumed that when I shrunk it, it auto-created partition 3, which I was then going to delete and extend my ext4 partition (number 5) to the free space. Looking at the partition table I posted below, I am going to extend partition 2 (ext4) to the free space before it.
  • Ruslan Gerasimov
    Ruslan Gerasimov almost 10 years
    Okay, now, if you came to the new partition structure, as can be viewed from this answer, you can extend your ext4, Now it is easier, because it became a primary partition, not logical as it was before. It is assuming that you have enough gree space at 1 partition and you are ready to sacrifice it to another one. So just run Gparted and resize 1 ntfs, make it less, make your 2 ext4 partition bigger by pulling its left border to the left side, where the 1 ntfs partition ends. I will add this to my answer.