HDD no longer able to mount after editing /etc/fstab

filesystemsmount

I have an SSD which holds / and my home directory, but I also have a 1TB HDD with most of my music on. I tried to edit /etc/fstab to automatically mount the HDD to save me time. I am running Kubuntu.

I opened KDE Partition Manager to check the type of the filesystem and it read ext3

The line I added read:

/dev/sda /media/HDD ext3 defaults 0 2

On rebooting, an error appeared under 'Kubuntu' on the boot screen saying that the filesystem couldn't mount so I hit S to skip attempting to mount.

Running sudo blkid shows:

/dev/sda1: LABEL="HDD" UUID="00000000-dba3-409e-a185-345c60459125" TYPE="ext2" 
/dev/sdb1: UUID="44cdc69c-0746-4a99-9c48-ccf7fca69768" TYPE="ext4" 
/dev/sdb5: UUID="478bf04c-8bf6-46c4-86e8-e844380cf8e7" TYPE="swap" 

I can remember when I created the partition originally, I didn't set it to ext2 (even though this was ~2 years ago)

I attempted a couple more times with different options (changing defaults to other commands rw,async,auto…). The HDD will no longer mount. When opening in dolphin, the message reads:

An error occurred while accessing 'Home', the system responded: The requested operation has failed: Error mounting /dev/sda1 at /media/myname/HDD: Command-line `mount -t "ext2" -o "uhelper=udisks2,nodev,nosuid" "/dev/sda1" "/media/myname/HDD"' exited with non-zero exit status 32: mount: wrong fs type, bad option, bad superblock on /dev/sda1, missing codepage or helper program, or other error In some cases useful info is found in syslog – try dmesg | tail or so

KDE Partition Manager says the type is unknown. Clicking 'properties' shows it as unformatted

fdisk -l gives the following:

    Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
    255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x000819ae

Device Boot      Start         End      Blocks   Id  System
/dev/sda1              63  1953520064   976760001   83  Linux
Partition 1 does not start on physical sector boundary.

Disk /dev/sdb: 128.0 GB, 128035676160 bytes
255 heads, 63 sectors/track, 15566 cylinders, total 250069680 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: 0x0001a3c6                                    

Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *        2048   233330687   116664320   83  Linux
/dev/sdb2       233332734   250068991     8368129    5  Extended
/dev/sdb5       233332736   250068991     8368128   82  Linux swap / Solaris

Attempting to mount gives the error

~ $ sudo mount /dev/sda /media/HDD
[sudo] password for myname: 
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

dmesg | tail says:

[ 5632.049404] EXT2-fs (sda): error: ext2_check_descriptors: Block bitmap for group 880 not in group (block 0)!
[ 5632.049411] EXT2-fs (sda): group descriptors corrupted
[ 5669.867629] EXT2-fs (sda): error: ext2_check_descriptors: Block bitmap for group 880 not in group (block 0)!
[ 5669.867632] EXT2-fs (sda): group descriptors corrupted
[ 6894.395961] EXT2-fs (sda1): error: can't find an ext2 filesystem on dev sda1.
[ 7040.625599] EXT3-fs (sda1): error: fragsize 1024 != blocksize 4096 (unsupported)
[ 7045.462213] EXT2-fs (sda1): error: can't find an ext2 filesystem on dev sda1.
[ 7048.975278] EXT4-fs (sda1): VFS: Can't find ext4 filesystem
[ 7421.551590] EXT2-fs (sda1): error: can't find an ext2 filesystem on dev sda1.
[ 7451.874417] EXT2-fs (sda1): error: can't find an ext2 filesystem on dev sda1.

strace:

$ strace -s 2000 -o mount.log blkid

/dev/sda1: LABEL="HDD" UUID="00000000-dba3-409e-a185-345c60459125" TYPE="ext2" 
/dev/sdb1: UUID="44cdc69c-0746-4a99-9c48-ccf7fca69768" TYPE="ext4" 
/dev/sdb5: UUID="478bf04c-8bf6-46c4-86e8-e844380cf8e7" TYPE="swap" 

/proc/filesystems:

$ cat /proc/filesystems
nodev   sysfs
nodev   rootfs
nodev   bdev
nodev   proc
nodev   cgroup
nodev   cpuset
nodev   tmpfs
nodev   devtmpfs
nodev   debugfs
nodev   securityfs
nodev   sockfs
nodev   pipefs
nodev   anon_inodefs
nodev   devpts
        ext3
        ext4
nodev   ramfs
nodev   hugetlbfs
        vfat
nodev   ecryptfs
        fuseblk
nodev   fuse
nodev   fusectl
nodev   pstore
nodev   mqueue
nodev   binfmt_misc
        ext2
        udf

Best Answer

There are several ways to determine a drives filesystem type. Here's a list of the tools I'm familiar with.

1. blkid

Works whether device is mounted or not.

$ blkid
/dev/sda1: UUID="XXXX" TYPE="ext4" 
/dev/sda2: UUID="XXXX" TYPE="LVM2_member"

2. mount

This is only useful once the block device has been mounted.

$ sudo mount | grep /dev/sda1
/dev/sda1 on /boot type ext4 (rw,relatime,seclabel,data=ordered)

3. lsblk

Shows drive topologies, but not the filesystem types on the devices.

$ sudo lsblk -a
NAME                      MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda                         8:0    0 465.8G  0 disk 
├─sda1                      8:1    0   500M  0 part /boot
└─sda2                      8:2    0 465.3G  0 part 

tune2fs

$ tune2fs -l /dev/sda1 | grep magic
Filesystem magic number:  0xEF53

Shows the magic number associated with the device, you can look these up on this site, Linux Magic Numbers. It's also in a file, often here, /usr/share/magic. You can locate it using locate /magic.

dumpe2fs

$ sudo dumpe2fs /dev/sda1 | grep magic
dumpe2fs 1.42.7 (21-Jan-2013)
Filesystem magic number:  0xEF53

Same things apply as in tune2fs.

/dev/mounts

This is the "file" maintained by the kernel that's used to display devices that have been mounted. NOTE: many of the tools on this list are typically using the contents of this file.

$ sudo cat /proc/mounts | grep /dev/sda1
/dev/sda1 /boot ext4 rw,seclabel,relatime,data=ordered 0 0

file

You can also use the file command to display info about unmounted filesystems.

$ sudo file -s /dev/sda1
/dev/sda1: Linux rev 1.0 ext4 filesystem data, UUID=XXXX (needs journal recovery) (extents) (huge files)

An alternative syntax (as root):

$ file - </dev/sda1
/dev/stdin: Linux rev 1.0 ext4 filesystem data, UUID=XXXX (needs journal recovery) (extents) (huge files)

Your mounting issue

I'd suspect that the filesystem you're attempting to mount is not what you think it is. Either the entire device was formatted with a filesystem (/dev/sda), in which case you'd be mounting the entire drive. You can test this hypothesis like this:

$ sudo mount /dev/sda /mnt

Of if you need to explicitly tell what filesystem to use:

$ sudo mount -o ext2 /dev/sda /mnt

NOTE: This is generally not the case that an entire filesystem is laid down on the entire device, /dev/sda, rather they're partitioned into /dev/sda1, etc.

Or perhaps the drive has been partitioned. In this case you'd see these partitions with the above command lsblk, where they'd show up as /dev/sda1, /dev/sda2, etc. If that's the case for you then you'll need to mount the partition instead like so:

$ sudo mount /dev/sda1 /mnt

Again pay special attention to the formatting used on the filesystem of the device, you'll occasionally have to specify it literally to mount.

Since your output from fdisk shows that you have /dev/sda1 I'd be inclined to think that you have your filesystem on the 1st partition.

Device Boot      Start         End      Blocks   Id  System
/dev/sda1              63  1953520064   976760001   83  Linux

So mounting it like this should do the trick:

$ sudo mount -o ext2 /dev/sda1 /mnt

/etc/fstab

If the above mounting commands work then you can add this to your /etc/fstab file.

/dev/sda1 /media/HDD ext2 defaults 0 2
Related Question