LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   swap (https://www.linuxquestions.org/questions/linux-newbie-8/swap-933558/)

sam845 03-09-2012 03:10 AM

swap
 
hi,

I'm new to linux. I noticed the swap isn't being used: the system monitor shows 0 bytes of swap and /proc/swaps is empty. Yet I have a linux swap partition (as shown in fdisk -l). I even tried mkswap /dev/my_swap_partition but it didn't work either.

Please help.
Thanks.

druuna 03-09-2012 03:23 AM

Hi,

It might be that a swap partition is present, but not mounted.

Can you post the output of the following commands:
Code:

cat /etc/fstab
free
fdisk -l

BTW: If swap isn't needed by the system it will not be used (but it should show up when using the appropriate commands).

Hope this helps.

sam845 03-09-2012 03:26 AM

Thank you very much, that was the issue.
Swapon worked.
How is it possible that it is not mounted by default, and how can I make it so that it is automatically mounted when the computer starts ?
Thanks.

druuna 03-09-2012 03:29 AM

Hi,

There should be an entry in your /etc/fstab file that mounts swap during the boot process. Something like this:
Code:

/dev/sdaX      swap                    swap      pri=1            0    0
X being the appropriate partition.

Hope this helps.

sam845 03-09-2012 03:32 AM

I have an entry in my /etc/fstab file that says something like this:
UUID=some_uuid none swap sw 0 0
I don't have a pri=1 though.
and I checked that this uuid is indeed the one where the swap is. So how can it be that the swap wasn't mounted during the boot process ?

druuna 03-09-2012 03:46 AM

Hi,
Quote:

Originally Posted by sam845 (Post 4622546)
I have an entry in my /etc/fstab file that says something like this:
UUID=some_uuid none swap sw 0 0
I don't have a pri=1 though.
and I checked that this uuid is indeed the one where the swap is. So how can it be that the swap wasn't mounted during the boot process ?

Although my example differs from yours, it is also correct and should work.

Have a look at your boot log file(s) to see if anything strange pops up (probably /var/log/dmesg or /var/log/boot). You can also use the dmesg command.

BTW: Is this a one time thing or consistent after every (re)boot?

sam845 03-09-2012 04:05 AM

hi,

This was consistent so far, but I haven't rebooted yet since I typed that swapon command.

/var/log/dmesg | grep swap and /var/log/boot | grep swap return no result.
dmesg | grep swap shows:
[14435.771470] 0 pages in swap cache
[14435.771478] Free swap = 0kB
[14435.771480] Total swap = 0kB

ps: what do the numbers in [] refer to ?

druuna 03-09-2012 04:40 AM

Hi,
Quote:

Originally Posted by sam845 (Post 4622562)
This was consistent so far, but I haven't rebooted yet since I typed that swapon command.

If at all possible, reboot the machine to make sure.

Quote:

/var/log/dmesg | grep swap and /var/log/boot | grep swap return no result.
dmesg | grep swap shows:
[14435.771470] 0 pages in swap cache
[14435.771478] Free swap = 0kB
[14435.771480] Total swap = 0kB
I would have expected a line telling you that swap was added, something like this:
Code:

$ dmesg | grep -i swap
Adding 4008208k swap on /dev/sdb2.  Priority:1 extents:1 across:4008208k

You might want to go through the boot files and the output of dmesg by hand, maybe an error is thrown that doesn't contain the swap keyword you are searching for with grep.

Quote:

ps: what do the numbers in [] refer to ?
The numbers shown between the square brackets show the number of seconds that have passed since your last boot.

Hope this helps.

sam845 03-09-2012 06:39 AM

hi,

so I did reboot.
I still had to manually use the swapon command.
I went through all the dmesg output and didn't find anything peculiar (though I don't understand half of it). In particular, the words 'error' and 'warn' are not present.
Any idea as to what could cause my system not to automatically add the swap partition ?
I only have one drive by the way.

Thanks

druuna 03-09-2012 07:42 AM

Hi,

Can you post the output I asked for in post #2?

michaelk 03-09-2012 08:12 AM

Is swap the last line in the fstab file?
It could be something as simple as no end of line character.

sam845 03-09-2012 09:12 AM

No it's not the last line.

/etc/fstab:

# /etc/fstab: static file system information.
#
# Use 'blkid -o value -s UUID' to print the universally unique identifier
# for a device; this may be used with UUID= as a more robust way to name
# devices that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc nodev,noexec,nosuid 0 0
# / was on /dev/sda1 during installation
UUID=2b772b05-301a-4705-9b8b-52b52c4ec756 / ext4 errors=remount-ro 0 1
# /home was on /dev/sda7 during installation
UUID=32d3f953-711a-4514-8e5b-17b7d3b34104 /home ext4 defaults 0 2
# swap was on /dev/sda6 during installation
UUID=41e7d85c-9bdb-4434-a055-1e7e1124a419 none swap sw 0 0
# sd card for pandaboard
UUID=42e278b3-3255-4a7f-8b1d-441d62b68515 none ext3 noauto 0 0
UUID=84F7-4051 none vfat noauto 0 0




free -m (after using swapon):

total used free shared buffers cached
Mem: 1982 1865 117 0 11 93
-/+ buffers/cache: 760 222
Swap: 3759 203 3555


fdisk -l:

Disk /dev/sda: 150.0 GB, 150041884686 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00030db2

Device Boot Start End Blocks Id System
/dev/sda1 * 1 2431 19530252 83 Linux
/dev/sda2 2431 19451 136757149 5 Extended
/dev/sda5 2432 12040 77095135 83 Linux
/dev/sda6 12040 12512 3951858+ 82 Linux swap / Solaris
/dev/sda7 12512 19451 55702128 83 Linux

sam845 03-12-2012 03:40 AM

Can someone help me please ?

michaelk 03-12-2012 07:42 AM

Have you checked the logs to see if there are any errors?

sam845 03-12-2012 09:12 AM

Well I'm not sure about which logs you're talking about, I haven't checked all the logs on my system, but I have checked /var/log/dmesg and /var/log/boot, and there was nothing unusual that I could find. In particular, the words 'warning' or 'error' aren't present.


All times are GMT -5. The time now is 09:44 AM.