Tuesday, June 21, 2005

Questions regarding swap and /tmp

==============================================================================
TOPIC: Questions regarding swap and /tmp
==============================================================================

== 1 of 4 ==
Date: Fri 17 Jun 2005 06:15
From: suzanne.dorman

As you read this, please keep in mind that I am not a sys admin. I'm a
lowly developer who is the only one in this small shop who knows
anything about Unix (and that was a few years ago).

I am configuring our stand-alone Sun to accomodate Oracle 9i. One of
the requirements is that the swap size be the same or greater than the
RAM (1 GB). The other requirement is that /tmp have at least 400MB of
space available and that /tmp does not use a device of swap.
After running the swap -l command, I can see that my swap is not large
enough (it's about 500 MB).

swap -l

swapfile dev swaplo blocks free
/dev/dsk/c0t0d0s1 32,1 16 1058288 682528

By doing a df -k, I can see that my /tmp does indeed use a device of
swap.

df -k

Filesystem kbytes used avail capacity Mounted on
/dev/dsk/c0t0d0s0 2327951 2241035 40357 99% /
/proc 0 0 0 0% /proc
mnttab 0 0 0 0% /etc/mnttab
fd 0 0 0 0% /dev/fd
swap 363208 168 363040 1% /var/run
swap 363368 328 363040 1% /tmp
/dev/dsk/c0t0d0s7 67731034 11322365 55731359 17% /export/home
/export/home/dlataille 67731034 11322365 55731359 17%
/home/dlataille
/export/home/oracle 67731034 11322365 55731359 17% /home/oracle

My /etc/vfstab file looks like this:

#device device mount FS fsck mount mount
#to mount to fsck point type pass at boot options
#
fd - /dev/fd fd - no -
/proc - /proc proc - no -
/dev/dsk/c0t0d0s1 - - swap - no -
/dev/dsk/c0t0d0s0 /dev/rdsk/c0t0d0s0 / ufs 1
no -
/dev/dsk/c0t0d0s7 /dev/rdsk/c0t0d0s7 /export/home ufs
2 yes -
swap - /tmp tmpfs - yes -

For reference, uname -a produced the following:

SunOS HARTFORD 5.9 Generic_117171-01 sun4u sparc SUNW,Sun-Fire-V250

My questions are:

1. Does /tmp being on a swap device mean that the swap file and /tmp
share the same space?
2. How do I make /tmp no longer be on a swap device?
3. I believe I have to change the /etc/vfstab file to make any changes
exist after reboot. If I do that, how can I specify a swap size?
4. /var/run is also on a swap device (see df -k results) and the size
is very close to /tmp. Is the similar size a coincidence or is there a
reason for it?

Thanks in advance!

== 2 of 4 ==
Date: Fri 17 Jun 2005 15:46
From: Thomas Maier-Komor

wrote:
[ snip ]

first of all I would like to recommend reading the man page of tmpfs.

>
> 1. Does /tmp being on a swap device mean that the swap file and /tmp
> share the same space?

tmpfs is a filesystem which allocates its space in the virtual memory.
So the answert to your question is yes and no, as it will just allocate
pages of virtual memory, which might eventually get pushed into swap
space.

> 2. How do I make /tmp no longer be on a swap device?

remove the entry in vfstab. I would further recommend creating a
new filesystem on an unused slice and mounting that instead, because
unmount /tmp means that tmp will reside on /. Before doing any
such change make sure you know what you are doing, because putting
/tmp on a regular filesystem can reduce performance dramatically.
Furthermore you should make sure that /tmp will be clean upon
boot, because it is when mounted with tmpfs on swap.

> 3. I believe I have to change the /etc/vfstab file to make any changes
> exist after reboot. If I do that, how can I specify a swap size?

you can add swap by either specifying swap slices or creating swap
files. see man page for swap

> 4. /var/run is also on a swap device (see df -k results) and the size
> is very close to /tmp. Is the similar size a coincidence or is there a
> reason for it?

AFAIK swap is automatically mounted on /var/run and you should leave it
like this...

>
> Thanks in advance!
>

Cheers,

Tom

== 3 of 4 ==
Date: Fri 17 Jun 2005 15:57
From: c(
Andreas F. Borchert)

On 2005-06-17, suzanne.dorman> wrote:
> 1. Does /tmp being on a swap device mean that the swap file and /tmp
> share the same space?

Yes.

> 2. How do I make /tmp no longer be on a swap device?

Create a free disk partition, newfs it, fix the /tmp line in /etc/vfstab,
and reboot or umount/mount /tmp. (In this case, you should create a
procedure that cleans up /tmp at boot time).

> 3. I believe I have to change the /etc/vfstab file to make any changes
> exist after reboot. If I do that, how can I specify a swap size?

The swap size depends on the size of the swap partitions.

> 4. /var/run is also on a swap device (see df -k results) and the size
> is very close to /tmp. Is the similar size a coincidence or is there a
> reason for it?

This is done in /etc/init.d/buildmnttab (up to Solaris 9, somewhere
else in Solaris 10). The swap file system has the big advantage that
firstly it does not require a separate partition and secondly it does
not need to be cleaned up. (Besides the advantage of speed, of course).

Andreas.

== 4 of 4 ==
Date: Fri 17 Jun 2005 14:50
From: Rich Teer

On Fri, 17 Jun 2005 suzanne.dorman wrote:

> I am configuring our stand-alone Sun to accomodate Oracle 9i. One of
> the requirements is that the swap size be the same or greater than the
> RAM (1 GB). The other requirement is that /tmp have at least 400MB of
> space available and that /tmp does not use a device of swap.

I'm no Oracle expert, but that last piece of advice sounds a bit bogus
to me. Be very generous with your swap space allocation, sure, and limit
the size of /tmp using the appropriate mount option. But having /tmp
on a ufs file system seems a bit daft to me.

> /dev/dsk/c0t0d0s0 /dev/rdsk/c0t0d0s0 / ufs 1 no -
> /dev/dsk/c0t0d0s7 /dev/rdsk/c0t0d0s7 /export/home ufs 2 yes -

For those UFS file systems, you should specify the "logging" option,
unless you're using the latest version of S9 (or S10) which does this
by default.

> SunOS HARTFORD 5.9 Generic_117171-01 sun4u sparc SUNW,Sun-Fire-V250

Uppercase hostnames are a bad idea, or at the very least, go against
convention. I'd rename it to hardford if I were you (and that doesn't
cause too much disruption).

> 1. Does /tmp being on a swap device mean that the swap file and /tmp
> share the same space?

Sort of. The bit of your swap space that isn't being used for virtual
memory is available to tmpfs, and vice versa.

> 2. How do I make /tmp no longer be on a swap device?

Mount /tmp on a different device. But I'd advise against that for
performance reasons.

> 3. I believe I have to change the /etc/vfstab file to make any changes
> exist after reboot. If I do that, how can I specify a swap size?

Man swap.

> 4. /var/run is also on a swap device (see df -k results) and the size
> is very close to /tmp. Is the similar size a coincidence or is there a
> reason for it?

Yes, they share the same "space".

--
Rich Teer, SCNA, SCSA, OpenSolaris CAB member

0 Comments:

Post a Comment

<< Home