[COLUG] How to read label of a swap partition

jep200404 jep200404 at columbus.rr.com
Fri Aug 24 20:00:18 EDT 2007


Rob Funk wrote:

> jep200404 wrote:
> > How can one read the label of a swap partition?

> I don't label my partitions, 

Me too. I was in the middle of disabling the labels that 
the OS had set up in /boot/grub/grub.conf and /etc/fstab, 
when I noticed this the following line from /etc/fstab: 

   LABEL=SWAP-hda2         swap                    swap    defaults        0 0

I have been familiar with e2label, but this swap label stuff 
stumped me. The man pages did not reveal an answer. 

> but the swapon man page's description of -L 
> seems to imply that "cat /proc/partitions" may help.

I had already tried that before asking: 

   [jep at localhost ~]$ cat /proc/partitions
   major minor  #blocks  name
   
      3     0   40146624 hda
      3     1     200781 hda1
      3     2    2096482 hda2
      3     3   37849140 hda3
   [jep at localhost ~]$ 

All three of those partitions are labeled. 
hda1 and hda3 have e2labels. 
hda2 is a swap partition and has a swap label. 

   [root at localhost ~]# e2label /dev/hda1
   /boot
   [root at localhost ~]# e2label /dev/hda2
   e2label: Bad magic number in super-block while trying to open /dev/hda2
   Couldn't find valid filesystem superblock.
   [root at localhost ~]# e2label /dev/hda3
   /
   [root at localhost ~]# fdisk -l /dev/hda
   
   Disk /dev/hda: 41.1 GB, 41110142976 bytes
   255 heads, 63 sectors/track, 4998 cylinders
   Units = cylinders of 16065 * 512 = 8225280 bytes
   
      Device Boot      Start         End      Blocks   Id  System
   /dev/hda1   *           1          25      200781   83  Linux
   /dev/hda2              26         286     2096482+  82  Linux swap / Solaris
   /dev/hda3             287        4998    37849140   83  Linux
   [root at localhost ~]# 

Jim



More information about the colug432 mailing list