Question: SOLUTION: For all of the things that were right, making the volume with fsck and making the filesystem with mkfs are two separate operations. Thanks for giving me nice, descriptive, helpful error messages, Linux. 😀
fsck.ext2: Bad magic number in super-block while trying to open /dev/sdaThe superblock could not be read or does not describe a correct ext2filesystem. ?If the device is valid and it really contains an ext2filesystem (and not swap or ufs or something else), then the superblockis corrupt, and you might try running e2fsck with an alternate superblock: ?e2fsck -b 8193
That error occurred when running sudo fsck /dev/sda on a brand new drive. I ran sudo fdisk /dev/sda and added a new partition (just accepted the defaults here) but I got a corresponding magic number error when trying to mount it. I tried alternate blocks (using superblocks listed by sudo mkfs -n /dev/sda) but none worked, they were all listed as being corrupt.
I’m looking for a way to solve this, especially considering it’s a brand new drive, never partitioned.
Addendum 1: After this failed, I dd’d the entire disk with zeroes, then used fdisk and noted it had no partitions. I added a partition in fdisk (accepting the defaults). In fdisk, partitions are listed as follows:
Command (m for help): pDisk /dev/sda: 2000.4 GB, 2000398934016 bytes, 3907029168 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk label type: dosDisk identifier: 0x639543e8 ?Device Boot ?Start ?End ?Blocks ?Id ?System/dev/sda1 ?2048 ?3907029167 ?1953513560 ?83 ?Linux
I then used sudo mount /dev/sda1 drivefolder/ and it gave the following error:
[user@localhost ~]$ sudo mount /dev/sda1 drivefolder/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.
The dmesg output shows this:
[17467275.127319] ata9.00: configured for UDMA/133[17467275.127325] ata9.00: device reported invalid CHS sector 0[17467275.127332] ata9: EH complete[17594695.132437] ?sda: sda1
And fsck says:
fsck from util-linux 2.23.1e2fsck 1.42.7 (21-Jan-2013)ext2fs_open2: Bad magic number in super-blockfsck.ext2: Superblock invalid, trying backup blocks…fsck.ext2: Bad magic number in super-block while trying to open /dev/sdaThe superblock could not be read or does not describe a correct ext2filesystem. ?If the device is valid and it really contains an ext2filesystem (and not swap or ufs or something else), then the superblockis corrupt, and you might try running e2fsck with an alternate superblock: ?e2fsck -b 8193
Since this was a new drive, and I also dd’d the entire drive to zeroes, I’m at a loss to fix it. It’s reproducible and so far the solutions I’ve seen involve using the fsck -b option, but I’ve tried it with all of the backup superblocks given by mkfs and none of them have worked.
Answer: If you did a mkfs /dev/sda1, when you mount it, you have to use mount /dev/sda1 /wherever, not mount /dev/sda /wherever.
To add a volume to fstab so it automatically mounts on boot, first find its UUID using blkid:
# blkid /dev/sda1UUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX /media/whatever ?ext2 ?noatime
and conveniently you can just add that entire line to your fstab – with the exception that you probably want to change the 2nd parameter that tells it where to mount it. ?Don’t mount things to /media with fstab – make a directory in /mnt or similar.
On Debian and Debian derived distros such as Ubuntu, symlinks to each attached physical drive’s /dev/sdX1, etc. are in /dev/disk/by-id – these symlinks will have recognizable names based on the bus and manufacturer of the drive. ?Use the UUID for fstab because it will always work.