I was trying to restore the grub after I reinstalled windows, so I mounted the partition where ubuntu was installed but I got:
$ sudo mount /dev/sda3 /mnt
mount: you must specify the filesystem type
So I did
$ sudo mount -t ext4 /dev/sda3 /mnt
mount: wrong fs type, bad option, bad superblock on /dev/sda3,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try
Then I tried the solution for bad superblocks:
$ sudo e2fsck -f /dev/sda3
e2fsck 1.42.9 (4-Feb-2014)
e2fsck: Attempt to read block from filesystem resulted in short read while trying
to open /dev/sda3
Could this be a zero-length partition?
$ sudo dumpe2fs /dev/sda3|grep -i superblock
dumpe2fs 1.42.9 (4-Feb-2014)
dumpe2fs: Attempt to read block from filesystem resulted in short read while
trying to open /dev/sda3
Couldn't find valid filesystem superblock.
$ sudo mke2fs -n /dev/sda3
mke2fs 1.42.9 (4-Feb-2014)
mke2fs: inode_size (128) * inodes_count (0) too big for a
filesystem with 0 blocks, specify higher inode_ratio (-i)
or lower inode count (-N).
Edit2: And as Android Dev suggested (same using 8193)
$ sudo e2fsck -f -b 32768 -y /dev/sda3
e2fsck 1.42.9 (4-Feb-2014)
e2fsck: Invalid argument while trying to open /dev/sda3
The superblock could not be read or does not describe a valid ext2/ext3/ext4
filesystem. If the device is valid and it really contains an ext2/ext3/ext4
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
e2fsck -b 8193 <device>
or
e2fsck -b 32768 <device>
So what is going on here?? My parted -l looks like this:
$ sudo parted -l
Model: ATA SAMSUNG HM321HI (scsi)
Disk /dev/sda: 320GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags
1 1049kB 106MB 105MB primary ntfs boot
2 106MB 231GB 231GB primary ntfs
3 231GB 320GB 89.4GB extended
5 256GB 258GB 1991MB logical linux-swap(v1)
6 258GB 320GB 62.4GB logical ext4
I noted (thanks to oldfred) that partition sda4 (where ubuntu was installed) is missing! between 231GB and 256GB, sda6 is my /home. I used to have 2 partitions for windows and when I reinstalled I did it in just one, so ubuntu partitions might have been from sda4 to sda7 before (but not sure). Would this be related to the problem?
My options are to recover this partition with testdisk or to reinstall ubuntu, but I wanted to ask if someone knows of a different solution for this.
I've read similar questions but none provides a solution different from testdisk and I'm not sure if that is my problem.
Edit1:
The output for 'sudo update-grub' reads
/usr/sbin/grub-probe: error: failed to get canonical path of `/cow'.
similar for sudo grub-install /dev/sda3:
$ sudo grub-install /dev/sda3
Installing for i386-pc platform.
grub-install: error: failed to get canonical path of `/cow'.
Edit3 (solution):
In case someone else stumbles with this problem, I recovered the missing partition using parted rescue, as suggested by oldfred in the comments. His solution can be found in this link (posts 21 and 22)
http://ubuntuforums.org/showthread.php?t=1775331&page=3
In order to re-install the grub, I followed these steps:
$ sudo mount /dev/sda7 /mnt
$ sudo mount --bind /dev /mnt/dev
$ sudo mount --bind /dev/pts /mnt/dev/pts
$ sudo mount --bind /proc /mnt/proc
$ sudo mount --bind /sys /mnt/sys
$ sudo chroot /mnt
# grub-install --recheck /dev/sda
Installing for i386-pc platform.
Installation finished. No error reported.
where sda7 was the recovered partition. Worked perfectly.
source (spanish): http://www.taringa.net/post/linux/18583092/Como-recuperar-Grub-despues-de-instalar-Windows.html