2

So I have three disks. I had thought to label the volumes themselves:

$ e2label /dev/sda
d80-JD-75MS

$ e2label /dev/sdb
e2label: Bad magic number in super-block while trying to open /dev/sdb
Found a dos partition table in /dev/sdb

$ e2label /dev/sdc
e2label: Bad magic number in super-block while trying to open /dev/sdc
Found a dos partition table in /dev/sdc

... All three disks are bootable. fdisk reports no errors on any of them. But the usual ext4 utilities all report the same thing or very close:

"Couldn't find a valid filesystem superblock
Found a dos partition table in ..."

/dev/sdb is a band new install of Debian 11 all kosher but somehow e2label isn't happy with it. Apart from that, I can detect no kind of trouble but what's going on with the 'superblock' issue? Is that fixable?

BTW one thing that seemed promising was:

mkfs.ext4 -L "wipeout" /dev/sda

... which added a label alright, but also wiped out everything on the disk :(

... so this is naughty?"

$ e2label /dev/sda "bad bad bad"

$ lsblk /dev/sda -o name,label,fstype,mountpoint,size,model
NAME    LABEL          FSTYPE MOUNTPOINT     SIZE MODEL
sda     bad bad bad    ext4                 74.5G WDC_WD800JD-75MSA3
├─sda1  d1--5-swap     swap                    5G 
├─sda2  d2--0-boot     ext4   /media/sda/2   200M 
├─sda3  d3--6-root     ext4   /media/sda/3     6G 
├─sda4      

... the command is happy to execute, the command is about LABELING a FS, not creating one. Nothing seems to have broken. I'm happy. What I want to know is why I get those 'bad magic number' messages on the other two disks.

8
  • Because I want to and it is supposed to be possible. Labeling the partitions has not been a problem. Oct 1, 2022 at 14:13
  • 2
    Where do you get the idea that it is possible to label the disk as well as the partitions? I think you may have misread. e2label is an extX tool.
    – Bib
    Oct 1, 2022 at 14:24
  • As shown above I had no trouble labeling one of my disks. In any case the "Bad magic number" message is troubling. I'd prefer my magic numbers were good ones. One never knows when a bad magic number might not come back to bite one in the arse. Oct 1, 2022 at 14:27
  • 1
    No, you did not label one of the disks, you appeared to creat an ext4 file system on the whole of the disk without partitioning it and assigned a label to the file system.
    – Bib
    Oct 1, 2022 at 14:29
  • Label to the filesystem you say? Fine, I call that the 'volume' but your language might be better. In any case I can perform the operation on one disk but not the other two and I'd like to know why. Oct 1, 2022 at 14:31

1 Answer 1

3

A label is a property of a filesystem, not of a disk.

You can use e2label to label an extN filesystem (for N={ 2, 3, 4 }). For an FAT filesystem you would need to use fatlabel, mlabel, or another FAT-aware tool.

You seem to have created an extN filesystem on the first disk /dev/sda directly rather than through a partition table. This is a generally a really bad idea: you should (almost) always have a partition table for a disk.

The problem with a filesystem directly on the disk (/dev/sda) rather than a partition (such as /dev/sda1) is that you cannot use the disk for anything other than that one filesystem.

Worryingly, from your later edit showing lsblk output, you had other partitions on the disk. At best you've corrupted the first partition table and the disk is using its backup near the end of the disk. At worst you've also overwritten data on one or more of the partitions.

Right now, I would be inclined to recommend that you backup all your data on this disk and rebuild it. Once you've backed it up and tested that the backup was successful, if you're feeling adventurous you could try rebuilding the primary GPT. It seems that gdisk with the r and then c options should do this but I have not tried it. I think I'd be happier wiping the disk and restoring my data.

3
  • Ah! I had earlier done: "mkfs.ext4 -L "wipeout" /dev/sda" ... so I DID 'create a filesystem' there! 'e2label' will happily label a PARTITION on the other disks. So the question now becomes: what sort of animal is this 'filesystem' on /dev/sda NOT on one of the partitions? What 'is it?' where does it live? how does it exist apart from the partition table? Can it hurt me? I can see that it's rather irregular tho so I'm beginning to understand what you guys are saying. Oct 1, 2022 at 15:05
  • @RayAndrews I've tried to address this concern in an edit to my answer Oct 1, 2022 at 15:19
  • Ok thanks. Mind, you could make that even better. 'fdisk' shows no trouble on the disk -- all partitions show up. But 'gparted' shows nothing but the 'phony' fs. So it's clearly bogus. No data there yet, this is all exploratory. Bottom line is that I CAN'T 'label the disk' or 'label the device' itself. So basically the 'mkfs.ext4 -L "disaster" /dev/sda' command is a Very Bad Idea. If you want, incorporate the above into your answer and it might save the ass of the next guy :) Oct 1, 2022 at 15:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .