Solved

Swap-file

Posted on 1996-12-10
2
426 Views
Last Modified: 2014-01-27
Is it possible to have a swap-file in Linux
and not a full swap-partition.
0
Comment
Question by:LarsC
2 Comments
 

Accepted Solution

by:
dspencer earned 50 total points
ID: 1631511
Not that I know of.  (I would just say "no, it is not", except for the possibility that since it's the Linux community and all, *anything* is remotely possible. =])

The utilities dealing with swap interaction, specifically mkswap and swapon/off, and the way it is accessed to the system through /etc/fstab, seem to be irrevocably tied to swap space being on one or more separate partitions.

See the Installation-HOWTO and (if you're interested in possibly sharing swapfile space with a Windows 3.x installation) the Swap-Space mini-HOWTO for supporting details.

Sorry!

(And just as long as we're on the subject of separate partitions:  my favorite schema is /, /usr, /usr/local, /home, /var, /tmp, and swap, with sharing as appropriate for your installation. Post another question if you want better explanation :) )
0
 
LVL 1

Expert Comment

by:stgreenwalt
ID: 39811926
The accepted solution is wrong.  You can create a swap file in Linux that is not a part of a separate partition as follows.  This creates a 1GB swap file:

All from a root prompt (or preceed each line with sudo):
     $ sudo dd if=/dev/zero of=/mnt/swapfile bs=1024 count=1048576
     $ sudo chmod 600 /mnt/swapfile
     $ sudo mkswap /mnt/swapfile
     $ sudo swapon /mnt/swapfile
     $ sudo echo '/mnt/swapfile none swap sw 0 0' >> /etc/fstab
     $ sudo sysctl vm.swappiness=10

Open in new window

Check if your new swap is working;
    $ sudo swapon -s

Open in new window

   If '/mnt/swapfile' appears in the results, then it is working.

Other notes:

If swappiness=0, swapping will occur only if RAM is exhausted.  Increasing the number increases the likelihood that swap will be used even when RAM not exhausted.  You have to experiment with this.  A value of 60 would be reasonable, but a lot depends on your system configuration.
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Determine Who is Runnig my Bash Shell Script 4 61
Why isn't object file created? 6 41
networking details on centos 6.6 4 50
wipe a usb using python 5 26
If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now