I broked the filesystem : Bad magic number in super-block

Hi there,
I (have) had a USB3, 4TB HDD formatted ext4 working fine connected to the router USB port.
For testing, I disconnected it from the router and connected it on my PC (Opensuse 15.1). I could browser it was working fine.
For speed testing I wrote the command line

scp file.avi /dev/sdf1

but I didn’t had the permission, so I added sudo

sudo scp file.avi /dev/sdf1

I don’t remember what was the answer.

Unfortunately, now I can’t mount the HDD any-more and get

 sudo fsck.ext4 /dev/sdf1
e2fsck 1.43.8 (1-Jan-2018)
ext2fs_open2: Bad magic number in super-block
fsck.ext4: Superblock invalid, trying backup blocks...
fsck.ext4: Bad magic number in super-block while trying to open /dev/sdf1

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>
sudo fdisk -l
....
Disk /dev/sdf: 3.7 TiB, 4000787030016 bytes, 976754646 sectors
Disk model: EFRX-68WT0N0    
Units: sectors of 1 * 4096 = 4096 bytes
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: A7D86CAD-1E80-432F-AC1F-FE612E8566A0

Device     Start       End   Sectors  Size Type
/dev/sdf1    256 976754431 976754176  3.7T Linux filesystem
sudo e2fsck -b 8193 /dev/sdf1
e2fsck 1.43.8 (1-Jan-2018)
e2fsck: Bad magic number in super-block while trying to open /dev/sdf1

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>

-b 8193 or 32768 or 98304 same error

sudo mke2fs -n /dev/sdf1
[sudo] password for root: 
mke2fs 1.43.8 (1-Jan-2018)
Creating filesystem with 976754176 4k blocks and 244195328 inodes
Filesystem UUID: f9db9f39-37ea-4462-8eac-91c4878d0a2d
Superblock backups stored on blocks: 
    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
    4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 
    102400000, 214990848, 512000000, 550731776, 644972544


Of course I had a lot of reading but all the fix on Internet are successful with e2fsck but doesn’t work for me.
Any suggestion to fix this issue?
Thank you.

You should never do that.

Mount the file system, then copy the file to the mounted file system. DO NOT copy a file to the device special file.

You destroyed that file system. The best you can probably do is reformat (with “mkfs”), and then restore from the most recent backup.

Yeah,
Writing a file to a device was not good.
If you have any really important files on that device, you can try to recover them with photorec before you reformat (and likely then destroy any chance at recovery).

TSU

If you want that disk to have an ext4 partition on it then, you’ll need to use “mkfs.ext4” which implies “mke2fs -t ext4” – see the “mkfs.ext4” Man Page.
If you do not wish to take the easy way out with YaST, you’ll have to feed “mke2fs” with some more parameters:

  • -T usage-type
  • -U UUID – where ‘UUID’ may be also one of “clear” or “random” or “time” …
  • -E extended-options
  • -C cluster-size
  • -b block-size
  • fs-size

If you wish to have more than one partition on the drive, the easiest way is to use YaST …
[HR][/HR]Attempting to write directly to a block device connected to a UNIX®/Linux system is a skill known only to a few system programmers – it’s never, ever, executed from a Terminal’s Command Prompt …

Not for removable drives. YaST is designed to add your filesystem to /etc/fstab for automatic mounting.

Thank you everyone for your answer.
I knew I have done a big mistake. Luckily, I have a backup of the files but spread in few other HDD, this will be time consuming.

BTW, could you tell me what filesystem and what options I should use for this HDD for the use-case:

  • Linux only devices (Opensuse, OpenWRT, Libreelec)
  • Only 1 partition
  • USB3 enclosure
  • 4TB size spinning HDD
  • Music files 20MB to 50MB - 1/3 of size
  • Music HD files 100MB to 1GB - 1/3 of size
  • Video files >1GB - 1/3 of size
  • Any users (and groups) (I can change the host without permission issue)
    Command line, GParted or YaST?

I think no need of journal and I read long time ago that it is possible de increase the size of a non system disk by reducing the size of an internal security area. I don’t remember the name and the command/option.

Thank you.

Just use ext4 and be happy.

Agree that EXT4 would likely be a good choice, but nearly any FS would be OK if you’re looking for a special feature (eg I/O speed, autorepair, etc)
For very large partitions, I’d recommend not specifying the cluster or block sizes so that the default 4Kb size is configured which might be a bit less efficient in space usage but means filesystem operations can happen within a reasonable amount of time.

TSU

I’ve used the YaST Partitioner to add Linux partitions to large (>999 Gb) USB drives after, reducing the default Redmond partition by means of that Redmond thing – without any fstab entries … >:)

So, I’ll keep ext4 and use GParted as usual.

I found what I wrote in my previous post: Reserved block count for Large Filesystem
The command should be

sudo tune2fs -m 1 /dev/sdxy

to keep 1% free.

sudo tune2fs -l **/**dev**/**sdxy

to check

reducing the default Redmond partition by means of that Redmond thing –

Sorry dcurtisfra what do you mean?

The town of Redmond in the Federal State of Washington is where the Headquarters of a certain Operating System, which I prefer not to use (unless absolutely needs be), is located …

Got it, thanks :wink: