SWAP File 

Newsgroups: comp.os.linux.misc
Date: 2002-09-05 16:35:24 PST
> written out to the console talking about SWAP and some kernel messages. Is
> there some kind of diagnostics i can run on 1) the hard disks in the machine
> and 2) how do I evaluate my swap space?
  1. Post the messages. ALWAYS post the messages.

  2. If you want to check your hard disk for errors (no way of determining that this is what you mean) then #man fsck

  3. To see what your Linux swap-space (NOT a file) is doing, type: #free This will show you how much memory (real & swap) the system is using.

  4. check the system load with #uptime (5, 10 & 15 min. averages) or #top (continuous)

On an IDE system it is usual for samba to consume anything up to 50-60% of the CPU load when transferring large files - my Celeron 533 on a (badly designed) VIA motherboard uses about half the CPU time to reach its top IDE transfer speed of 5 MB/sec… which, frankly, sucks.

And read (and learn to understand) the samba log files - if you increase the log level for the smbd process to 3 or 4 you'll get more debug info than you can read in a YEAR…

Jeroen Geilman @adaptr.nl

SWAP File 

>How's this swap?
>
>#free
>             total       used       free     shared    buffers     cached
>Mem:         30792      17584      13208      11836       3044       8824
>-/+ buffers/cache:       5716      25076
>Swap:        66996          0      66996

That actually doesn't tell much. You have, roughly, 32 Mb of RAM and 64Mb of swap, which gives you about 96Mb of Virtual Memory. Not much. I would recomment adding another 100Mb, at least, of swap space.

It is also obvious that you have recently booted your box. No swap at all is used, and there is more "free" memory than is being used by buffers and cache put together!

What are the chances your problem was simply that you ran out of Virtual Memory space? If you were running Emacs and had any kind of an image editing or even image veiwing program running… that would make it very possible to just eat all of your swap space. Heck, netscape has a memory leak that can do that in nothing flat!

If you have X running you might try using xsysinfo to allow you to graphically watch what your box is doing.

Floyd Davidson @ptialaska.net

mount swap in /tmp 

*Tags*: dev:swap

Newsgroups: comp.os.linux.misc
>How can I mount swap in /tmp?
>I used to have a linuxswap partition for the swap, but now since I
>noticed that my swap utilization is extremly low, I want to change it for
>/tmp volume. Please also provide some comments or tips on this.

You don't really want to go without swap. Linux without swap will run rather slowly, especially if you don't have much RAM. You don't necessarily need a partition dedicated for swap, however. You can turn your swap partition into an ext2 partition (and keep some swap around) by doing the following things. This assumes your swap partition is /dev/hda6 ; modify for your actual setup:

  1. init S (single-user mode, not essential in Linux but a good idea for the stuff we're about to do. Many Unices have a hard time when swap goes bye-bye, so we minimize the danger here….)

  2. dd if=/dev/zero of=/swapfile bs=1M count=64 && sync && sync (creates a 64M swapfile in / which you'll use later)

  3. mkswap /swapfile (initializes /swapfile)

  4. swapon /swapfile (turn on new swap)

  5. swapoff /dev/hda6 (turn off old swap)

  6. mke2fs /dev/hda6 (create new filesystem on hda6)

  7. mkdir /mnt/other ; mount /dev/hda6 /mnt/other

  8. cp -a /tmp /mnt/other

  9. rm -rf /tmp/*

  10. umount /dev/hda6 && mount /dev/hda6 /tmp

  11. chmod 1777 /tmp

  12. Edit /etc/fstab. Remove the previous entry for swap, and replace it with the following 2 lines:

    /swapfile   swap   swap    defaults    0    0
    /dev/hda6   /tmp   ext2    defaults    1    2
  13. init 3 (or whatever your normal runlevel is)

HTH, good luck.

Matt G

Add swapfile 

dd if=/dev/zero of=/tmp/.todel/swapfile bs=1M count=64 && sync && sync

creates a 64M swapfile in /tmp/.todel

mkswap /tmp/.todel/swapfile    # (initializes /swapfile)
swapon /tmp/.todel/swapfile    # (turn on new swap)

add the following to /etc/fstab:

/tmp/.todel/swapfile   swap                    swap    defaults        0 0

increase swap file space 

swapoff /tmp/.todel/swapfile
dd if=/dev/zero of=/tmp/.todel/swapfile bs=1M count=128 && sync && sync
mkswap /tmp/.todel/swapfile
swapon /tmp/.todel/swapfile

documented on: 2000.10.09 Mon 20:55:24

Mount /tmp in swap 

> >> gained some more knowledge of the swap, I now realized that maybe
> >> the best way is the other way around -- mounting  /tmp in swap,
> >> 'cause I can make swap grow in some critical circumstances when the
> >> /tmp grows too big.
> >> So, how should I mount /tmp in swap? Detailed instruction is very
> >> much appreciated. Thanks.
> > swap space doesn't have a normal filesystem.
> > It's not even in the root tree of the FS.(unless you make a swapfile, then
> > ofcourse the *file* is, the swapspace still isn't)
>Hmm, yeah, that was my first impression. And it is also the reason
>that I went the other way. But... let me show you it is doable in
>Solaris:
>
>$ mount
>/tmp on swap read/write
>See the last line "/tmp on swap"? Heeheehee, guys, got to think about
>it, 'cause Linux shouldn't be too much different from Unix. well,
>hopefully it is not, :-)

AIX is Unix, according to IBM, and you know the old joke about AIX, Unix, and space aliens, right?

Anyway, as I'm understanding it, you want to make sure that /tmp won't fill up. There are several ways to do this under Linux, in order of increasing complexity:

  1. Make the /tmp partition N times as large as you think it needs to be.

  2. Create /blarg, mke2fs /blarg, mkdir /tmp/extra, mount /blarg /tmp/extra -o loop , have things write their crud to /tmp/extra , umount /tmp/extra && rm /blarg when you're done.

  3. Use Linear Append Mode to allow /tmp to grow if it needs to.

  4. Use Logical Volume Management to do the same thing a bit more flexibly.

IIRC Solaris has a filesystem called "tmpfs" that's meant specifically for /tmp, and it implements some stuff that's not in ext2. The ability to mount /tmp on a swap device could be one of these things.

Matt G

Mount /tmp in swap 

>See the last line "/tmp on swap"? Heeheehee, guys, got to think about
>it, 'cause Linux shouldn't be too much different from Unix. well,
>hopefully it is not, :-)

There is some way to do that in FreeBSD too, but I do not recall the details. I believe you actually create a ramdisk for /tmp and that is only swapped out of RAM if the RAM is needed for something else more urgent. In practice you are not likely to notice a speed difference using a ramdisk in Linux, but it does minimize interruptions of other disk access. So it is that reason that I use a ramdisk for SETI@home processing (which typically only saves its state every 2 minutes and I backup to hard drive every 2 hrs).

David Efflandt

Mount /tmp in swap 

>See the last line "/tmp on swap"?

It is at kernel level and especially in fs type places as well ;) tmpfs is the filesystem Solaris operates by default. If you actually look at yuor /etc/vfstab (equiv of /etc/fstab under Linux) you'll see something along the lines of swap - /tmp tmpfs …

swap being the device, it's not fschk'd and /tmp being the mountpoint. The Fs-type is tmpfs which isn't available under Linux. I know there have been discussions in these newsgroups before and kernel-dev list IIRC about specialized filesystems for temporary storage, but nothing as yet has developed for Linux. There are plus's and minus's for it, you're saving space, but you can't get parallel activity on swap and /tmp, leaving you with less than adequate performances when the system is under a heavy load, compared with a system with a "real" /tmp filesystem.

Phil.

documented on: 2000.12.22 Fri

swap space problem 

>The UNIX osf system persistantly shows following error message:
>
>Unable to obtain requested swap space
>swap space below 10 percent free

You don't have enough page/swap space. You can use the swapon(8) command to add more raw disk partitions as page/swap space devices.

Or, as another reader suggested, switch to deferred page/swap reserveration mode. Ordinary, page/swap space is reserved for every page of (anon.) virtual memory created. This ensures that if the page needs to be written to the page/swap device, there will be space for it. The deferred mode doesn't do the reservation.

The advantage is that it allows the limit on virtual memory to be appoximately the sum of page/swap space and available memory. The disadvantage is that if you run out (which you're doing now), the kernel will resolve any deadlock situations by killing apparently idle processes. If you are in an environment where you can accurately estimate virtual memory and control it, this mode is fine. If you're in an environment where you can't, deferred mode can be used as the target of a denial of service attack.

Personally, I'd go with the "add more page/swap space".

Alan Rollow

swap space problem 

you should add some Swap-Space, under UW213 you create a file with dd ( dd < /dev/zero > [Filename] bs=512 count=size ) and then you call swap -a [Filename] and edit the swaptab.

Alex

swap space problem 

Swap

Create the swap file

mkfile 100M /home/swap_100meg
swap -a /home/swap_100meg
swap -l

don't forget to add it to the vfstab

"[ADM]RS"

documented on: 2000.12.18 Mon 23:57:52

Swap File Size 

Newsgroups: comp.os.linux.misc
> I am wondering if there is any swap space allocated on the box I am
> installing Oracle onto.

No, there does not seem to be. Or at least is not in use. Maybe the original installator made a swap partition but forgot to activate it. Check with fdisk if any partition is marked as Linux swap. E.g. on the machine I'm using now:

# fdisk -l
Disk /dev/hda: 255 heads, 63 sectors, 1247 cylinders
Units = cylinders of 16065 * 512 bytes
Device Boot    Start       End    Blocks   Id  System
/dev/hda1             1        13    104391   83  Linux native
/dev/hda2            14        26    104422+  82  Linux swap
/dev/hda3            27      1247   9807682+   5  Extended
/dev/hda5            27        65    313236   83  Linux native
/dev/hda6            66       196   1052226   83  Linux native
/dev/hda7           197       327   1052226   83  Linux native
/dev/hda8           328      1247   7389868+  83  Linux native

If it's there, add an appropriate line in /etc/fstab.

> If there isn't can I add some by taking
> away from other filesytems, or do I have to re-install the OS?

Without doing anything, you can create a swap FILE rather than PARTITION. See man mkswap for how to make a swap file. In the long run I think performance will be better if you have a dedicated partition. You can resize your partitions, without reinstalling, with parted (see freshmeat.net).

If you have more than one disk, performance will improve with one swap partition on each disk.

Stefano

Swap File Size 

> > If you have more than one disk, performance will improve with one swap
> > partition on each disk.
>
> I think this depends on many factors. I have two hard drives, with a
> swap partition on each. Both are activated. However, the configuration
> is the default that Red Hat 6.0 gives me, and as such, it uses the
> entire first swap partition before it starts with the second. So I do
> not see from where the performance improvement would come. I would have
> to do something about the priorities of the partitions. They are
> presently -1 and -2. I guess I would have to set them both to -1 or
> something like that, to get it to use both at once.

Yes, from the swapon(2) man page:

Swap  pages  are  allocated  from areas in priority order,
highest priority first.  For areas with different  priori-
ties,  a  higher-priority area is exhausted before using a
lower-priority area.  If two or more areas have  the  same
priority,  and it is the highest priority available, pages
are allocated on a round-robin basis between them.
> Since I have so much memory (512 Megabytes) for a desktop machine, only
> 22 Megabytes are swapped out at the moment (and, IIRC, this is something
> of a record) and I almost never see any swapping take place. Therefore,
> for me, swapping performance is of little interest.

Lucky guy!

Stefano

format the swap patition 

Newsgroups: comp.os.linux.misc
> How can I format a linux swap partition for linux to use?
>
> I found that one of my swap linux is not functioning (is it so?):
>
> $ cat /proc/swaps
> Filename                   Type            Size    Used    Priority
> /dev/hda1                       partition       514040  2344    -1
> /dev/hdb1                       partition       514040  0       -2

It _is_ formatted; otherwise it would be rejected by swapon(8), and not show up in /proc/swaps. It has a lower priority than /dev/hda1, and will not be used until /dev/hda1 is filled up.

Paul Kimoto

Windows swap file 

http://www.computerhope.com/jargon/s/swapfile.htm

A file stored on the computer hard disk drive that is used as a temporary location to store information that is not currently being used by the computer RAM. By using a swap file a computer has the ability to use more memory than what is physically installed in the computer. However, users who are low on hard disk space may notice that the computer runs slower because of the inability of the swap file to grow in size.

It is perfectly normal for the swap file or page file to grow in size, sometimes growing several hundred megs in size. Below is a listing of common Microsoft operating system swap file information; however, it is important to realize that this information may vary. Finally, by default the swap files are hidden.

Operating System Swap file name
Location
Windows 3.x 386PART.PAR C:\WINDOWS
Windows 95 / 98 / ME WIN386.SWP C:Windows NT / 2000 / XP PAGEFILE.SYS C:

documented on: 2008-03-30