Ubuntu – Setting Device Label using e2label or tune2fs causes Bad magic number in super-block while trying to open /dev/sda5

partitioning

I am trying to set a label to my Partitions, I used the e2label and tune2fs command
with sudo but it cause the following error

e2label: Bad magic number in super-block while trying to open /dev/sda5
Couldn't find valid filesystem superblock

What is the problem?

Best Answer

I had this problem while trying to label a newly-created, freshly-formatted partition on a USB stick.

I formatted the file system and then tried to label it using tune2fs -L.

It gave the following error:

tune2fs: Bad magic number in super-block while trying to open /dev/sdb1 Couldn't find valid filesystem superblock.

I transpired that I had used tune2fs while the USB partition was mounted. This corrupted the file system. I couldn't even run fsck on it.

The solution for me was to unmount the drive, delete the partition and start all over again. This time I created the label when I created the file system, using the -L option with mke2fs:

mke2fs -t ext3 -L labelname /dev/sdb1

The drive now appears to be working and it has a label. But I've not tried tune2fs on it again. I was fortunate not to have any data on it. Running fsck, however, provided a suggestion that may have got round the problem.

Related Question