Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have installed ubuntu in my computer, later, I format a partition as linux swap and want to replace it with existing tmp directory under mount point /. I followed procedure given in this link: http://ubuntuforums.org/showthread.php?t=1670222 . The question is that the swap is still not enabled. Here is some command output.

shijiex@shijie-ThinkPad-T410:~$ df 
Filesystem     1K-blocks     Used Available Use% Mounted on
/dev/sda1       28703740  5324096  21914916  20% /
tmpfs            1180916      924   1179992   1% /run
.........
/dev/sda7       28706812 17150036  10091896  63% /home
shijiex@shijie-ThinkPad-T410:~$ sudo blkid -c /dev/null -o list 
device         fs_type  label     mount point        UUID
-----------------------------------------------------------------------
/dev/sda1      ext4               /                  47d9205b-00a8-40e5-88d6-e8b9571799a7
...
/dev/sda7      ext4               /home              e2ae897d-62b1-45d3-a17a-49e7a1b8fbe7
/dev/sda9      swap               <swap>             81ce2033-4ff2-4e05-9500-aacfd1019855

shijiex@shijie-ThinkPad-T410:~$ sudo mount
/dev/sda1 on / type ext4 (rw,errors=remount-ro)
udev on /dev type devtmpfs (rw,mode=0755)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
tmpfs on /run type tmpfs (rw,noexec,nosuid,size=10%,mode=0755)
 ......
/dev/sda8 on /opt type ext4 (rw)
/dev/sda5 on /backup type ext4 (rw)
/dev/sda6 on /other type ext4 (rw)
/dev/sda7 on /home type ext4 (rw)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noexec,nosuid,nodev)
gvfs-fuse-daemon on /home/shijiex/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,user=shijiex)

At the end of /etc/fstab, it is:

# swap was on /dev/sda9 during installation
UUID=81ce2033-4ff2-4e05-9500-aacfd1019855  none            swap    sw              0       0

shijiex@shijie-ThinkPad-T410:~$ df 
Filesystem     1K-blocks     Used Available Use% Mounted on
/dev/sda1       28703740  5324100  21914912  20% /
udev             2942940        4   2942936   1% /dev
tmpfs            1180916      924   1179992   1% /run
none                5120        0      5120   0% /run/lock
none             2952280      156   2952124   1% /run/shm

/dev/sda8 14286320 11978284 1575672 89% /opt /dev/sda5 38317716 36097448 267144 100% /backup /dev/sda6 85532500 35151740 46029084 44% /other /dev/sda7 28706812 17150392 10091540 63% /home

The swap partition is sda9.I am not sure whether swap is enabled, because:

  1. /dev/sda9 is not in list of df result. While previously it always should be like:

    /dev/sda9       28706812 17150392  10091540  63% /tmp
    
  2. Gpart shows that /dev/sda9 as linux-swap with 14.85G,

    used     unused 
    --        --
    
  3. I was unable to access swap area. Previously, swap was always mount as /tmp and I can access this directory. Now the /tmp is only a directory under /..

  4. The OS is ubuntu 12.04 lts..

[UPDATE]:

The swap should have been enabled, cat /proc/swaps:

/dev/sda9                               partition   15575036    0   -1

though the used size is 0.

Now the scenario is:

I already have tmp directory under /, how can I mount swap this partition as mount point is /tmp. I modified last line of fstab as:

UUID=81ce2033-4ff2-4e05-9500-aacfd1019855  /tmp            swap    sw              0       0

Then mount -a and reboot does not report any error. But used in swap is 0 though I dumped many file content to /tmp.

So how can I fully utilized swap area, which is almost 15G? It is waste of disk if it always 0 used..

Or how can I just change /tmp to the swap partition?

I want this because this directory is widely used in my program and it is also as exchange area between my Ubuntu and hosted WindowXP. Both requires large disk space..

share|improve this question

2 Answers 2

None of those commands will show you if the swap is activated or not. To know whenever is the swap activated just run swapon -s:

swapon -s
Filename                Type        Size    Used    Priority
/dev/sda2                               partition   1052220 0   -1
/dev/sdb3                               partition   1047548 0   -2
/dev/sdb6                               partition   498684  0   -3

Another way is using free:

free
             total       used       free     shared    buffers     cached
Mem:       1552616    1394436     158180          0     116080     676940
-/+ buffers/cache:     601416     951200
Swap:      2598452          0    2598452

almost any process/system watcher has the swap values, htop in this example:

enter image description here

The swap is used only when the physical memory is not enough. Some people never gets the opportunity to use the swap while other just don't create it since they have heaps of RAM memory. I don't know why you want the swap into /tmp but there is not legit reasons why you would like to do this.

share|improve this answer
    
Now I mount it as /tmp, which already exists under sda1(mount point /). I dumped files to this directory but used swap is still 0. Is there any way to full utilized this directory, which is more than 15G? –  Xu Shijie Sep 19 '13 at 7:09
    
You should not do that! /tmp is used for saving files and is cleared once in a while. Could you please tell us why you want to do this? –  Braiam Sep 19 '13 at 12:30

To check the status of swqp partition you should read this link

Confirm that the swap partition exists.

cat /proc/swaps 

https://help.ubuntu.com/community/SwapFaq#How_do_I_add_more_swap.3F

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.