e2label Bad magic number in super-block?

This is the output of fdisk:

[root@ns1 ~]# fdisk -l

Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14         268     2048287+  82  Linux swap / Solaris
/dev/sda3             269        2611    18818810   83  Linux

But when I'm trying to use e2label I'm receiving the following results:

[root@ns1 ~]# e2label /dev/sda
e2label: Bad magic number in super-block while trying to open /dev/sda
Couldn't find valid filesystem superblock.
[root@ns1 ~]# e2label /dev/sda1
/boot
[root@ns1 ~]# e2label /dev/sda2
e2label: Bad magic number in super-block while trying to open /dev/sda2
Couldn't find valid filesystem superblock.
[root@ns1 ~]# e2label /dev/sda3
/

What does that error mean? (in sda & sda2)


Solution 1:

/dev/sda is the entire disc, the physical device which contains the partitions /dev/sda[123], so there's no file system to have an e2label on it.

Similarly, /dev/sda2 is a swap partition, which therefore doesn't have a file system (it's formatted as swap), so it, too, cannot be read by e2label.

Solution 2:

I also encountered that while trying to label an XFS filesystem. Here's how to label an XFS filesystem

xfs_admin -L "/newlabel" /dev/sdb1 

http://docs.oracle.com/cd/E37670_01/E37355/html/ol_admin_xfs.html

Solution 3:

e2label - Change the label on an ext2 filesystem  

/dev/sda2 is listed as swap and is not an ext partition. Since e2label works on ext filesystem types, you can't label this partition.

/dev/sda is not a partition, it is the entire disk.