Ubuntu – Can’t mount hard drive. Ubuntu

hard drivemountUbuntu

I can no longer mount an extra internal hard drive on my Ubuntu 11.04 64-bit system. I could up until a few days ago.

I had added a line at the end of fstab for the drive to automount, but I don't think it worked. I then removed the line from fstab and the drive will no longer mount via GUI or CLI. At least I think the problem is related to this, it may not be at all.

Trying to mount:

$ sudo mount /dev/sda /media/openSpaceI

GUI:

enter image description here

That gives this error:

mount: wrong fs type, bad option, bad superblock on /dev/sda,
   missing codepage or helper program, or other error
   In some cases useful info is found in syslog - try
   dmesg | tail  or so

GUI:

enter image description here

Here is the print out from dmesg | tail:

$ dmesg | tail
[ 9344.234380] compiz[6098]: segfault at 28 ip 00007f1fa0641335 sp 00007fff0b306700 error 4 in libregex.so[7f1fa063c000+8000]
[ 9987.879043] nautilus[6899]: segfault at 1505b817b60f ip 00007ff6eeefdb8d sp 00007fff09aa6170 error 4 in libgobject-2.0.so.0.2800.6[7ff6eeeca000+4e000]
[10001.231835] compiz[7360]: segfault at 28 ip 00007f38e0cfe335 sp 00007fff3228d380 error 4 in libregex.so[7f38e0cf9000+8000]
[10113.817592] compiz[7429]: segfault at 28 ip 00007f01c11cd335 sp 00007fffac4f4250 error 4 in libregex.so[7f01c11c8000+8000]
[10116.592022] compiz[7651]: segfault at 28 ip 00007f4369548335 sp 00007fffb3b2b030 error 4 in libregex.so[7f4369543000+8000]
[10117.958485] compiz[7666]: segfault at 28 ip 00007f3861d7d335 sp 00007fff268395d0 error 4 in libregex.so[7f3861d78000+8000]
[10366.207793] EXT4-fs (sda): bad geometry: block count 156282966 exceeds size of device (156282701 blocks)
[10855.975855] EXT4-fs (sdb): mounted filesystem with ordered data mode. Opts: (null)
[10863.666747] EXT4-fs (sda): bad geometry: block count 156282966 exceeds size of device (156282701 blocks)
[11125.922998] EXT4-fs (sda): bad geometry: block count 156282966 exceeds size of device (156282701 blocks)

My fstab file now:

enter image description here

I also ran disk utility on the disk. Disk is good and healthy. Here are the screenshots from that:

enter image description here

enter image description here

Any help getting this disk mounted would be extremely appreciated.

Best Answer

I encountered this problem recently, and was able to solve it. Since there doesn’t seem to be a clear answer here, I thought I would attempt to fix that.

First off, it is important to understand that you can have put a filesystem directly on a block device. In that case, you would mount/fsck/etc the device, like:

/dev/sda

NOT /dev/sda1

To be clear, this means you can have a filesystem without a partition table. This is called a partionless filesystem, and has been around for a long time. Here is a thread on stackexchange debating the merits: https://unix.stackexchange.com/questions/14010/the-merits-of-a-partitionless-filesystem

Next, this seems to be a somewhat common problem, mostly because Ubuntu decided to include the option of installing directly to a device.

The problem arises because in some cases a partitionless install breaks the formula EXT4 uses to compute disk size. You can tell if you have this problem if the difference between the expected and actual size is 265 bytes. (and no that’s not supposed to be 256) Google just told me that 265 is the size of an EXT4 inode structure. Since putting filesystems on bare devices is supported, and in some cases even encouraged, I would assume this is a bug. I was using kernel version 2.6.39 when it happened to me.

Finally, the solution. It’s quite easy really.

First, you need to force an fsck of the filesystem:

fsck.ext4 -f /dev/(your device)

Again, for a partionless device you would use for instance /dev/sda, not /dev/sda1 or anything like that.

Next you need to resize the device to match what ext4 wants:

resize2fs /dev/(your device) ####

Where <####> is the value from the error message:

EXT4-fs (sda): bad geometry: block count exceeds size of device (#### blocks)

PLEASE NOTE: the usual disclaimers apply. Messing with filesystems is dangerous etc. Be careful! This is meant is a last-ditch attempt to fix a filesystem, when the only other alternative is to reformat. I am not a filesystem expert, and have no idea if the above fix will work on your system, or introduce problems later on down the road. YMMV.

Once you’ve rescued your data, the safest approach is probably to reformat and create a standard partition table, if you can.

Related Question