Hongwei Li wrote:
Hi,
I just found that my fc3 system's swap partition is "gone". When I installed the system, I set it to 1Gb. The kernel is 2.6.10-1.766_FC3. I don't know when it started, but here are some information:
# free total used free shared buffers cached Mem: 1035748 658792 376956 0 145380 272540 -/+ buffers/cache: 240872 794876 Swap: 0 0 0
# cat /etc/fstab
# This file is edited by fstab-sync - see 'man fstab-sync' for details LABEL=/1 / ext3 defaults 1 1 none /dev/pts devpts gid=5,mode=620 0 0 none /dev/shm tmpfs defaults 0 0 LABEL=/home1 /home ext3 defaults,usrquota 1 2 LABEL=/opt /opt ext3 defaults 1 2 none /proc proc defaults 0 0 none /sys sysfs defaults 0 0 LABEL=/tmp1 /tmp ext3 defaults 1 2 LABEL=/usr1 /usr ext3 defaults 1 2 LABEL=/var1 /var ext3 defaults,usrquota 1 2 LABEL=SWAP-hda7 swap swap defaults 0 0 ...
I tried this:
# swapon -a swapon: cannot find the device for LABEL=SWAP-hda7
The system log does not show anything related to this problem. Can somebody tell me what may cause this problem? how to check it further and fix it?
Have you booted one of the LiveCD style distributions on this machine? I have heard that one of them may remove the label from swap partitions.
You might try changing the fstab entry: LABEL=SWAP-hda7 swap swap defaults 0 0 to: /dev/hda7 swap swap defaults 0 0
and see if that works. If it does, you might want to relabel the partition (when it's not being used), using (I think - the -L option is undocumented):
# mkswap -L SWAP-hda7 /dev/hda7
Paul.
Yes, it works. Thank you very much! Now, I have questions:
1. What's the use of mkswap -L SWAP-hda7 /dev/hda7? I don't see any effect?
It *should* be setting the "filesystem label" of the partition to "SWAP-hda7" so that mkswap can find it by name rather than being needed to be told where exactly the swap partition is.
2. When I put the original entry back to /etc/fstab as: LABEL=SWAP-hda7 swap swap defaults 0 0
it does not work again. I have to put /dev/hda7 in it. How to let the original entry work -- the above mkswap ... does not have effect?
Was your system swapping to that partition at the time you did the mkswap?
> Why do we need those LABEL=... in fstab?
The idea is that labels should be less of a moving target than device names. For example, lots of people found that their SATA drives moved from being /dev/hdX to /dev/sdX fairly recently. Labelling filesystems means that the OS can find them no matter what the device name is. This isn't without its problems (e.g. when moving disks between machines, resulting in multiple partitions with the same labels), but that's why they're there.
Labels for swap partitions are discussed at: https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=127892
Paul.