volume label for swap space - Redhat

This is a discussion on volume label for swap space - Redhat ; Dear all, I am wondering how I can set or edit volume labels for swap space. Recently I set up a CentOS 4.1 server. During the setup I partitioned /dev/hda3 as swap space. After setup I found, with surprise, that ...

+ Reply to Thread
Results 1 to 16 of 16

Thread: volume label for swap space

  1. volume label for swap space

    Dear all,

    I am wondering how I can set or edit volume labels for swap space.

    Recently I set up a CentOS 4.1 server. During the setup I partitioned
    /dev/hda3 as swap space. After setup I found, with surprise, that in
    /etc/fstab the swap partition was refered as "LABEL=SWAP-hda3", it
    behaved the same as for example an ext3 root partition (i.e., refered as
    LABEL=/). However I don't know how to edit the label, nor do I know how
    I can create it. Googled around to no avail.

    Anyone please kindly explain? Thanks.

    --
    Let's play Kill Bill at http://www.xbill.org/

  2. Re: volume label for swap space

    Kill Bill wrote:
    > Dear all,
    >
    > I am wondering how I can set or edit volume labels for swap space.
    >
    > Recently I set up a CentOS 4.1 server. During the setup I partitioned
    > /dev/hda3 as swap space. After setup I found, with surprise, that in
    > /etc/fstab the swap partition was refered as "LABEL=SWAP-hda3", it
    > behaved the same as for example an ext3 root partition (i.e., refered as
    > LABEL=/). However I don't know how to edit the label, nor do I know how
    > I can create it. Googled around to no avail.
    >
    > Anyone please kindly explain? Thanks.
    >
    > --
    > Let's play Kill Bill at http://www.xbill.org/


    Additionally, I played with fdisk and mkswap but no success. Also I knew
    e2label can set/edit labels for ext2/ext3 partitions but they are not
    for swap partitions.

    Thanks for any hint.

  3. Re: volume label for swap space

    On Tue, 06 Sep 2005 19:06:58 +0000, Kill Bill wrote:

    > Dear all,
    >
    > I am wondering how I can set or edit volume labels for swap space.
    >
    > Recently I set up a CentOS 4.1 server. During the setup I partitioned
    > /dev/hda3 as swap space. After setup I found, with surprise, that in
    > /etc/fstab the swap partition was refered as "LABEL=SWAP-hda3", it
    > behaved the same as for example an ext3 root partition (i.e., refered as
    > LABEL=/). However I don't know how to edit the label, nor do I know how
    > I can create it. Googled around to no avail.


    In the past I used Partition Magic to create partitions and attach labels
    to them. By the way, /etc/fstab allows to mount partitions to specific
    mount points based solely on the name of the label, irrespective of the
    device where they are located. So labelling a swap partition as SWAP-hda3
    is completely useless in my opinion. "LABEL=SWAP1" (and SWAP2, SWAP3
    etc. if more needed) OTOH seems more appropriate to me.

    shakiro

    > Anyone please kindly explain? Thanks.



  4. Re: volume label for swap space

    Kill Bill wrote:
    > Dear all,
    >
    > I am wondering how I can set or edit volume labels for swap space.
    >

    My guess is that there is no point doing it. It is my understanding that
    swap space uses the entire partition, so if you were to write a label on it
    (probably somewhere in the first block, perhaps?), as soon as the swap space
    gets initialized, the label will be gone).

    Actually, maybe it will work. Here is the first little bit of my swap
    partitions. It appears that the first 2000bytes (octal) are unused. Trouble
    is, I do not know if that is guaranteed.



    0000000 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
    *
    0002000 001 \0 \0 \0 F 320 \a \0 \0 \0 \0 \0 \0 \0 \0 \0
    0002020 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
    *
    0007760 \0 \0 \0 \0 \0 \0 S W A P S P A C E 2



    0000000 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
    *
    0002000 001 \0 \0 \0 F 320 \a \0 \0 \0 \0 \0 \0 \0 \0 \0
    0002020 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
    *
    0007760 \0 \0 \0 \0 \0 \0 S W A P S P A C E 2


    0000000 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
    *
    0002000 001 \0 \0 \0 F 320 \a \0 \0 \0 \0 \0 \0 \0 \0 \0
    0002020 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
    *
    0007760 \0 \0 \0 \0 \0 \0 S W A P S P A C E 2



    0000000 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
    *
    0002000 001 \0 \0 \0 ? 320 \a \0 \0 \0 \0 \0 \0 \0 \0 \0
    0002020 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
    *
    0007760 \0 \0 \0 \0 \0 \0 S W A P S P A C E 2


    --
    .~. Jean-David Beyer Registered Linux User 85642.
    /V\ PGP-Key: 9A2FC99A Registered Machine 241939.
    /( )\ Shrewsbury, New Jersey http://counter.li.org
    ^^-^^ 20:25:00 up 83 days, 14:21, 3 users, load average: 4.27, 4.19, 4.07

  5. Re: volume label for swap space

    On Wed, 07 Sep 2005 01:20:20 +0200, shakiro wrote:

    > On Tue, 06 Sep 2005 19:06:58 +0000, Kill Bill wrote:
    >
    >> Dear all,
    >>
    >> I am wondering how I can set or edit volume labels for swap space.
    >>
    >> Recently I set up a CentOS 4.1 server. During the setup I partitioned
    >> /dev/hda3 as swap space. After setup I found, with surprise, that in
    >> /etc/fstab the swap partition was refered as "LABEL=SWAP-hda3", it
    >> behaved the same as for example an ext3 root partition (i.e., refered as
    >> LABEL=/). However I don't know how to edit the label, nor do I know how
    >> I can create it. Googled around to no avail.

    >
    > In the past I used Partition Magic to create partitions and attach labels
    > to them. By the way, /etc/fstab allows to mount partitions to specific
    > mount points based solely on the name of the label, irrespective of the
    > device where they are located. So labelling a swap partition as SWAP-hda3
    > is completely useless in my opinion. "LABEL=SWAP1" (and SWAP2, SWAP3
    > etc. if more needed) OTOH seems more appropriate to me.


    Oops, I have to retract that (for the time being) as I myself am not using
    that property for swap space. Part of my /etc/fstab:

    LABEL=/var /var ext3 defaults 1 2
    /dev/hda12 swap swap defaults 0 0

    I'm too lazy to try it with 'LABEL=' right now, maybe later some time.

    shakiro

    > shakiro
    >
    >> Anyone please kindly explain? Thanks.



  6. Re: volume label for swap space

    shakiro wrote:
    > On Tue, 06 Sep 2005 19:06:58 +0000, Kill Bill wrote:
    >
    >
    >>Dear all,
    >>
    >>I am wondering how I can set or edit volume labels for swap space.
    >>
    >>Recently I set up a CentOS 4.1 server. During the setup I partitioned
    >>/dev/hda3 as swap space. After setup I found, with surprise, that in
    >>/etc/fstab the swap partition was refered as "LABEL=SWAP-hda3", it
    >>behaved the same as for example an ext3 root partition (i.e., refered as
    >>LABEL=/). However I don't know how to edit the label, nor do I know how
    >>I can create it. Googled around to no avail.

    >
    >
    > In the past I used Partition Magic to create partitions and attach labels
    > to them. By the way, /etc/fstab allows to mount partitions to specific
    > mount points based solely on the name of the label, irrespective of the
    > device where they are located. So labelling a swap partition as SWAP-hda3
    > is completely useless in my opinion. "LABEL=SWAP1" (and SWAP2, SWAP3
    > etc. if more needed) OTOH seems more appropriate to me.


    Your are totally right about this and it is exactly why I would like to
    edit the label.

    Just don't know how CentOS 4 installer created the label.

    Cheers,

    KB

  7. Re: volume label for swap space

    Jean-David Beyer wrote:
    > Kill Bill wrote:
    >
    >>Dear all,
    >>
    >>I am wondering how I can set or edit volume labels for swap space.
    >>

    >
    > My guess is that there is no point doing it. It is my understanding that
    > swap space uses the entire partition, so if you were to write a label on it
    > (probably somewhere in the first block, perhaps?), as soon as the swap space
    > gets initialized, the label will be gone).


    For my experience, the label sticks to the partition, at least survives
    after reboot.

    There are advantages to use disk label instead of device names because
    device names may vary if you change the partition schemes, or you move
    your hard driver around. So it is handy to use "LABEL=" in /etc/fstab
    and for mount command.

    > Actually, maybe it will work. Here is the first little bit of my swap
    > partitions. It appears that the first 2000bytes (octal) are unused. Trouble
    > is, I do not know if that is guaranteed.
    >
    >
    >
    > 0000000 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
    > *
    > 0002000 001 \0 \0 \0 F 320 \a \0 \0 \0 \0 \0 \0 \0 \0 \0
    > 0002020 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
    > *
    > 0007760 \0 \0 \0 \0 \0 \0 S W A P S P A C E 2


    The mkswap man page says "SWAPSPACE2" here indicates this is a new style
    swap partition.

    Hey what command did you use to display these bits so cleanly? I may
    check my swap partition to see where the label stores.

    Thanks,

    KB

  8. Re: volume label for swap space

    Kill Bill wrote:
    > Dear all,
    >
    > I am wondering how I can set or edit volume labels for swap space.
    >
    > Recently I set up a CentOS 4.1 server. During the setup I partitioned
    > /dev/hda3 as swap space. After setup I found, with surprise, that in
    > /etc/fstab the swap partition was refered as "LABEL=SWAP-hda3", it
    > behaved the same as for example an ext3 root partition (i.e., refered as
    > LABEL=/). However I don't know how to edit the label, nor do I know how
    > I can create it. Googled around to no avail.
    >
    > Anyone please kindly explain? Thanks.
    >
    > --
    > Let's play Kill Bill at http://www.xbill.org/


    More findings:

    The mkswap and mount (both provided by util-linux rpm) in fedora core 3
    and centos 4 understand volume labels for swap partitions, but the ones
    in fedora core 2 and lower version do not understand swap labels.

    So with FC3/CentOS4/RHEL4, I can use mkswap to create/edit the labels.

    Interesting.

    Anybody knows if the latest version of util-linux understand disk labels
    for ReiserFS/JFS? I know the ext2/3 and XFS labels are well recognised
    by mount and mkfs.ext2/mkfs.xfs.

    Thanks,

    KB

  9. Re: volume label for swap space

    Kill Bill wrote:

    > The mkswap man page says "SWAPSPACE2" here indicates this is a new style
    > swap partition.
    >
    > Hey what command did you use to display these bits so cleanly? I may
    > check my swap partition to see where the label stores.
    >

    od -c /dev/sda2 | less

    or something like that. Do not forget to pipe it through less (or more)
    because otherwise, it will show you the whole thing, and that can be pretty big.


    --
    .~. Jean-David Beyer Registered Linux User 85642.
    /V\ PGP-Key: 9A2FC99A Registered Machine 241939.
    /( )\ Shrewsbury, New Jersey http://counter.li.org
    ^^-^^ 06:45:00 up 84 days, 41 min, 4 users, load average: 4.26, 4.29, 4.18

  10. Re: volume label for swap space

    Jean-David Beyer wrote:
    > Kill Bill wrote:
    >
    >
    >>The mkswap man page says "SWAPSPACE2" here indicates this is a new style
    >>swap partition.
    >>
    >>Hey what command did you use to display these bits so cleanly? I may
    >>check my swap partition to see where the label stores.
    >>

    >
    > od -c /dev/sda2 | less
    >
    > or something like that. Do not forget to pipe it through less (or more)
    > because otherwise, it will show you the whole thing, and that can be pretty big.


    Thanks, Jean-David.

    And this is the first page of my swap space (Fedora Core 3):

    0000000 P 312 364 240 377 264 K 311 212 347 @ 314 275 256 227 1
    0000020 S W A P \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
    0000040 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
    *
    0002000 001 \0 \0 \0 _ 330 003 \0 \0 \0 \0 \0 \0 \0 \0 \0
    0002020 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
    *
    0007760 \0 \0 \0 \0 \0 \0 S W A P S P A C E 2
    0010000 B B B B B B B B B B B B B B B B


    There "SWAP" is the volume label I created with mkswap. Probably I could
    edit the bits manually as well.

    Cheers,

    KB

  11. Re: volume label for swap space

    Kill Bill wrote:
    > Jean-David Beyer wrote:
    >
    >> Kill Bill wrote:
    >>
    >>
    >>> The mkswap man page says "SWAPSPACE2" here indicates this is a new
    >>> style swap partition.
    >>>
    >>> Hey what command did you use to display these bits so cleanly? I may
    >>> check my swap partition to see where the label stores.
    >>>

    >>
    >> od -c /dev/sda2 | less
    >>
    >> or something like that. Do not forget to pipe it through less (or more)
    >> because otherwise, it will show you the whole thing, and that can be
    >> pretty big.

    >
    >
    > Thanks, Jean-David.
    >
    > And this is the first page of my swap space (Fedora Core 3):
    >
    > 0000000 P 312 364 240 377 264 K 311 212 347 @ 314 275 256 227 1
    > 0000020 S W A P \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
    > 0000040 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
    > *
    > 0002000 001 \0 \0 \0 _ 330 003 \0 \0 \0 \0 \0 \0 \0 \0 \0
    > 0002020 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
    > *
    > 0007760 \0 \0 \0 \0 \0 \0 S W A P S P A C E 2
    > 0010000 B B B B B B B B B B B B B B B B
    >
    >
    > There "SWAP" is the volume label I created with mkswap. Probably I could
    > edit the bits manually as well.
    >
    > Cheers,
    >
    > KB

    What are the first 16 bytes? Partition table? Or "magic number"?

    --
    .~. Jean-David Beyer Registered Linux User 85642.
    /V\ PGP-Key: 9A2FC99A Registered Machine 241939.
    /( )\ Shrewsbury, New Jersey http://counter.li.org
    ^^-^^ 08:35:00 up 84 days, 2:31, 3 users, load average: 4.23, 4.16, 4.10

  12. Re: volume label for swap space

    Jean-David Beyer wrote:
    >>And this is the first page of my swap space (Fedora Core 3):
    >>
    >>0000000 P 312 364 240 377 264 K 311 212 347 @ 314 275 256 227 1
    >>0000020 S W A P \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
    >>0000040 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
    >>*
    >>0002000 001 \0 \0 \0 _ 330 003 \0 \0 \0 \0 \0 \0 \0 \0 \0
    >>0002020 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
    >>*
    >>0007760 \0 \0 \0 \0 \0 \0 S W A P S P A C E 2
    >>0010000 B B B B B B B B B B B B B B B B
    >>
    >>
    >>There "SWAP" is the volume label I created with mkswap. Probably I could
    >>edit the bits manually as well.

    >
    > What are the first 16 bytes? Partition table? Or "magic number"?


    I am not sure, everytime I recreate the swap partition, the first 16
    bits get changed. So it must not be partition table. It seems not
    related to time either.

    Cheers,

    KB

  13. Re: volume label for swap space

    shakiro writes:
    >On Tue, 06 Sep 2005 19:06:58 +0000, Kill Bill wrote:
    >
    >> Dear all,
    >>
    >> I am wondering how I can set or edit volume labels for swap space.
    >>
    >> Recently I set up a CentOS 4.1 server. During the setup I partitioned
    >> /dev/hda3 as swap space. After setup I found, with surprise, that in
    >> /etc/fstab the swap partition was refered as "LABEL=SWAP-hda3", it
    >> behaved the same as for example an ext3 root partition (i.e., refered as
    >> LABEL=/). However I don't know how to edit the label, nor do I know how
    >> I can create it. Googled around to no avail.

    >
    >In the past I used Partition Magic to create partitions and attach labels
    >to them. By the way, /etc/fstab allows to mount partitions to specific
    >mount points based solely on the name of the label, irrespective of the
    >device where they are located. So labelling a swap partition as SWAP-hda3
    >is completely useless in my opinion. "LABEL=SWAP1" (and SWAP2, SWAP3
    >etc. if more needed) OTOH seems more appropriate to me.


    First off, labels are kept in file-system specific data structures. Only
    ext2 and ext3 are supported for labels in RH/CentOS. There is no
    corresponding on-disk structure for a swap device, so it cannot be
    labeled.

    Second off, the default labeling scheme used by Redhat is screwed up. They
    use the mount point directory name as the label (e. g. / for the root
    disk), which causes mucho problemo if you happen to hot plug another
    disk with the same label into the machine. The label should be a UUID.

    scott

    >
    >shakiro
    >
    >> Anyone please kindly explain? Thanks.

    >


  14. Re: volume label for swap space

    Jean-David Beyer writes:
    >Kill Bill wrote:
    >
    >> The mkswap man page says "SWAPSPACE2" here indicates this is a new style
    >> swap partition.
    >>
    >> Hey what command did you use to display these bits so cleanly? I may
    >> check my swap partition to see where the label stores.
    >>

    >od -c /dev/sda2 | less
    >
    >or something like that. Do not forget to pipe it through less (or more)
    >because otherwise, it will show you the whole thing, and that can be pretty big.


    xxd /dev/sda2 |less is much better.

    scott


  15. Re: volume label for swap space

    On Tue, 06 Sep 2005 19:10:04 +0000, Kill Bill wrote:

    > Kill Bill wrote:
    >> Dear all,
    >>
    >> I am wondering how I can set or edit volume labels for swap space.
    >>
    >> Recently I set up a CentOS 4.1 server. During the setup I partitioned
    >> /dev/hda3 as swap space. After setup I found, with surprise, that in
    >> /etc/fstab the swap partition was refered as "LABEL=SWAP-hda3", it
    >> behaved the same as for example an ext3 root partition (i.e., refered as
    >> LABEL=/). However I don't know how to edit the label, nor do I know how
    >> I can create it. Googled around to no avail.
    >>
    >> Anyone please kindly explain? Thanks.
    >>
    >> --
    >> Let's play Kill Bill at http://www.xbill.org/

    >
    > Additionally, I played with fdisk and mkswap but no success. Also I knew
    > e2label can set/edit labels for ext2/ext3 partitions but they are not
    > for swap partitions.
    >
    > Thanks for any hint.


    mkswap -L Swap1 /dev/hdb2




  16. Re: volume label for swap space

    Kill Bill wrote:
    > Anybody knows if the latest version of util-linux understand disk labels
    > for ReiserFS/JFS? I know the ext2/3 and XFS labels are well recognised
    > by mount and mkfs.ext2/mkfs.xfs.


    Reply to myself:

    version of 2.12p of util-linux can pick up labels for ext2/3, xfs, jfs,
    reiserfs3 as well as swap partitions. It probably comes with fedora core
    5 (or fc4?). Anyway I create an rpm on my FC3 box and I now can use
    labels for my partition in fstab and grub.conf.

    HTH,

    KB
    --
    Let's play my favorite game at http://www.xbill.org/

+ Reply to Thread