Linux Swapfiles

Linux Swapfiles

Post by Dragonmaster Lo » Fri, 01 Dec 1995 04:00:00



Anyone know if it's possible to configure Linux to use swapfiles on the root
filesystem in the case that the swap partition is filled.  I'd like to be able to
run Xemacs and Netscape simultaneously if possible, but apparently the 32MB of swap
I have with my 16MB of RAM isn't enough, and I'd rather not reparition.  Thanks.
--
+--------------- http://techhouse.brown.edu/~lou/index.html ---------------+

| "Dragonmaster Lou"    | Iscandar, leaving all we love behind, who knows  |
| Technology House      | what dangers we'll find..."                      |
+-------------------- ftp://yamato.techhouse.brown.edu --------------------+
 
 
 

Linux Swapfiles

Post by Charlie Kempso » Tue, 05 Dec 1995 04:00:00




>>Anyone know if it's possible to configure Linux to use swapfiles on the root
>>filesystem in the case that the swap partition is filled.  I'd like to be able to
>>run Xemacs and Netscape simultaneously if possible, but apparently the 32MB of swap
>>I have with my 16MB of RAM isn't enough, and I'd rather not reparition.  Thanks.

>Yep, sure is. It's documented in the installation guide (Linux Documentation Project),
>section 4.9, 'Using a swap file'.

[snip]

>You can also add the '/swap' into your /etc/fstab (just copy the swap line that's
>already there, changing '/dev/hda3' (for eg) to '/swap'), and the swapon and swapoff
>will be done automagically on startup and shutdown.
>matt

Under HP-UX you can tell the kernel to use spare space on a filesystem
as a swap space, with a configurable maximum size (minimum free space
left).  The operating system decides how much space is needed and
reserves it, allocating and deallocating space dynamically as
needed.  Can this be done under Linux??

Charlie

 
 
 

Linux Swapfiles

Post by Mats Andtbac » Tue, 05 Dec 1995 04:00:00



Quote:>Under HP-UX you can tell the kernel to use spare space on a filesystem
>as a swap space, with a configurable maximum size (minimum free space
>left).  The operating system decides how much space is needed and
>reserves it, allocating and deallocating space dynamically as
>needed.  Can this be done under Linux??

Not directly; possibly you could kluge up something if you wrote a
daemon to constantly check on used swap, free disk space, and so on,
and (de)allocate swapfiles created on-the-fly as needed.

That would be a godawful hack, though, and you really wouldn't want to
do it. HP-UX's way of doing much the same in the kernel is probably
not much better; that would mean bloating the kernel even worse than
it already is. Besides, swapping would get *s-l-o-w*; swapfiles are
already slow enough compared with partitions.
--
" ... got to contaminate to alleviate this loneliness
      i now know the depths i reach are limitless... "
                -- nin

 
 
 

Linux Swapfiles

Post by Matthew Tov » Tue, 05 Dec 1995 04:00:00



>Anyone know if it's possible to configure Linux to use swapfiles on the root
>filesystem in the case that the swap partition is filled.  I'd like to be able to
>run Xemacs and Netscape simultaneously if possible, but apparently the 32MB of swap
>I have with my 16MB of RAM isn't enough, and I'd rather not reparition.  Thanks.

Yep, sure is. It's documented in the installation guide (Linux Documentation Project),
section 4.9, 'Using a swap file'.

Here's a summary:

use 'dd if=/dev/zero of=/swap bs=1024 count=8192'
to create an 8 Mb file called /swap

use 'mkswap /swap 8192'
to initialise the space

and use 'sync'
then 'swapon /swap'
to activate your extra swap.

You should 'swapoff /swap' before you shutdown.

You can also add the '/swap' into your /etc/fstab (just copy the swap line that's
already there, changing '/dev/hda3' (for eg) to '/swap'), and the swapon and swapoff
will be done automagically on startup and shutdown.

Take note of drawbacks to this system:
        - swap files are not as fast as swap partitions
        - you have more chance of corrupting your root partition (has this happened to
                        anyone?)
        - be careful with the 'dd' command - mistyping anything could be v. dangerous!

matt