How to give UUID to a swap partition?

Dear Folks

Is there anyway to give a UUID to a swap partition? mkswap on CentOS 5 (util-linux-2.13-0.45.el5_1.1) appears to override this option ;-(

# swapoff -a
# mkswap -L swap1 /dev/sda3
Setting up swapspace version 1, size = 4293591 kB
LABEL=swap1, no uuid

And there's no UUID for swap partition:

# ls -l /dev/disk/by-uuid/
total 0
lrwxrwxrwx 1 root root 10 Dec 31 11:01 617b4b90-112e-497a-bc6b-dda2a3e7565e -> ../../sda2
lrwxrwxrwx 1 root root 10 Dec 31 11:01 6ede6345-3ef5-4cb1-9cce-b8583cf263cf -> ../../sda4
lrwxrwxrwx 1 root root 10 Dec 31 11:01 ae703248-438e-46ca-9935-8800fb3c9536 -> ../../sda1

# /lib/udev/vol_id /dev/sda3
ID_FS_USAGE=other
ID_FS_TYPE=swap
ID_FS_VERSION=2
ID_FS_UUID=
ID_FS_LABEL=swap1
ID_FS_LABEL_SAFE=swap1

In previus versions of mkswap, in CentOS 4, I solved this problem re-formating the partition with "mkswap"...

Regards,

Any ideas? Thanks!!

The swap partiotion has no uuid. Check this:

[root@sirim ~]# cat /etc/fstab | grep -i swap
LABEL=SWAP-sda3 swap swap defaults 0 0

[root@sirim ~]# findfs LABEL=SWAP-sda3
/dev/sda3

[root@sirim ~]# hal-device | grep sda3 -A 9
9: udi = '/org/freedesktop/Hal/devices/volume_label_SWAP_sda3'
volume.ignore = true (bool)
info.udi = '/org/freedesktop/Hal/devices/volume_label_SWAP_sda3' (string)
volume.partition.flags = { } (string list)
volume.partition.uuid = '' (string)
volume.partition.label = '' (string)
volume.partition.type = '0x82' (string)
volume.partition.scheme = 'mbr' (string)
info.product = 'SWAP-sda3' (string)
volume.partition.media_size = 60011642880 (0xdf8f90000) (uint64)
volume.partition.start = 58934131200 (0xdb8bf7a00) (uint64)
volume.size = 1077511680 (0x40398600) (uint64)
volume.num_blocks = 2104515 (0x201cc3) (int)
volume.block_size = 512 (0x200) (int)
volume.partition.number = 3 (0x3) (int)
info.capabilities = { 'volume', 'block' } (string list)
info.category = 'volume' (string)
volume.is_partition = true (bool)

Dear lechuga,

Thanks for your reply :wink:

Regards,