0

The problem originated when I was trying to fix this problem. Things went horribly, horribly wrong and I ended up with a new problem altogether. The last thing I did was run

sudo apt-get install

and that caused my system to freeze. I restarted my computer and it would not boot from the harddrive. I ran a copy of Ubuntu 12.10 from a flashdrive that I had and ran gparted to see if my partitions were all there. It returned this message:

Invalid partition table on /dev/sda -- wrong signature 5208.

The drive appeared as a 2TiB unallocated drive with an error. The drive had 4 partitions before (plus random unallocated space). There was a fat32 partition, an ext4 partition which contained ubuntu 13.04/13.10 (I don't even know which one at this point), an extended partition which contained a swap partition for my ubuntu partition (I was meaning to move that ubuntu partition into the extended partition, never got around to it), and another partition (I don't remember how I formatted it). I should also mention this is a 1TB harddrive.

So in short, I have a corrupted partition table on my primary harddrive from which I boot from, how can I fix this?


I tried mounting the drive with

sudo mount /dev/sda1 /media/ubuntu

then I changed my directory to said folder and tried to list files and this monstrosity happened:

$ ls
ls: cannot access ��w�j^�.: Input/output error
ls: cannot access �?(�
                      �x?.|: Input/output error
ls: cannot access 6W_@�)?._??: Input/output error
ls: cannot access HB0v???.A}�: Input/output error
ls: cannot access ???.�X: Input/output error
ls: cannot access t)�.+�l: Input/output error
ls: cannot access ?h@   
�.@ : Input/output error
ls: cannot access >?    @�?.���: Input/output error
ls: cannot access m???.?�: Input/output error
ls: cannot access @ if�?a?: Input/output error
ls: cannot access ?M!vN$�.??n: Input/output error
ls: cannot access ?o�
�?.Bm`: Input/output error
ls: cannot access ?:I???
M.
: Input/output error
ls: cannot access W??.??: Input/output error
ls: cannot access �: Input/output error
ls: cannot access ?W�s??: Input/output error
ls: cannot access ?v?k?.???: Input/output error
ls: cannot access 5?$<N��: Input/output error
.x����.??i: Input/output error
ls: cannot access je?���.j?1: Input/output error
XjD?.���: Input/output error
ls: cannot access W??n�??.?: Input/output error
ls: cannot access �^x.$"�: Input/output error
ls: cannot access !�?*!?�j.�?: Input/output error
ls: cannot access '-�?k?^�.?��: Input/output error
ls: cannot access b�w?w?b.\??: Input/output error
ls: cannot access o�??�"z.?�B: Input/output error
ls: cannot access ��b�h.?3-: Input/output error
ls: cannot access �?.$7: Input/output error
ls: cannot access )??K.bk: Input/output error
ls: cannot access s?�z?.?(�: Input/output error
ls: cannot access �F@?0?.@�: Input/output error
.�D: Input/output error
.?�: Input/output error
ls: cannot access?�??�.
                        @: Input/output error
ls: cannot access ?/?�
                        ?.��: No such file or directory
ls: cannot access rk?p4q(�.�k: Input/output error

This looks promising. This is the output of fdisk -l

$ sudo fdisk -l /dev/sda
Warning: ignoring extra data in partition table 5
Warning: ignoring extra data in partition table 5
Warning: ignoring extra data in partition table 5
Warning: invalid flag 0x5208 of partition table 5 will be corrected by w(rite)

Disk /dev/sda: 2199.0 GB, 2199023132672 bytes
255 heads, 63 sectors/track, 267349 cylinders, total 4294967056 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x44fdfe06

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1       113305600   894715903   390705152    c  W95 FAT32 (LBA)
/dev/sda2       894715904  1489307647   297295872   83  Linux
/dev/sda3      1489309694  1497307135     3998721    5  Extended
/dev/sda4      1497309184  1953523711   228107264    7  HPFS/NTFS/exFAT
/dev/sda5   ?  3013257822  3688738171   337740175   aa  Unknown

1 Answer 1

0

Well, I'm not sure what exactly I did to fix it, so I'll just list a bunch of things I did that might have fixed it. First off, I was using a 4 gig thumbdrive to boot Ubuntu 12.10 to work with. I had limited space on the drive and could only install new utilities by uninstalling others (like Thunderbird). One utility I came accross was called fixparts. I don't believe that there is a ppa with fixparts in it, so I had to download the .deb and install it with Ubuntu software center. The online documentation/tutorial recommends using fdisk to first backup the MBR data so that if fixparts further corrupts it, it can be restored. I did so (assume the drive we want to fix is sda) with

sudo fdisk -d /dev/sda > parts.txt

and to restore the data

sudo fdisk -f /dev/sda < parts.txt

To use fixparts you just need to provide it with the drive you want to work on

sudo fixparts /dev/sda

From there you can use the interface. It will first tell you the primary partitions it found. It will not list the Extended partitions. You can then issue commands on what you want to do. If you want a list of commands, just use ? See online documention in above links for more details. Fixparts didn't exactly fix things for me, but it got me started. I restored the original Partition Table using the before mentioned command with fdisk and then used fdisk to make my Linux partition bootable. Simply launching fdisk without arguments, or with the drive after it, will allow you to use an interface similar to fixparts. So I ran

sudo fdisk /dev/sda

and set the 2nd partition to bootable. When I booted, I was able to run Ubuntu 13.04 like normal and access all my partitions.

If someone understands the technical reasons for why this fixed things, please feel free to rewrite this mess of an answer and I will select it as best answer.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .