First, we need to know what is swap memory?
Generally, this is a temporary memory storage for an OS to utilize while the OS is trying to get more busy process managing another separate threads from another running applications.
Assuming you already have an existing swap partition, which is usual by default installation, and we would like to have additional swap memory by adding swap file, say on a different partition or harddrive, here's how to do it while inside your redhat based ditro:
VIEW CURRENT SWAP :
# cat /proc/swaps
Similarly, you'll see
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Filename Type Size Used Priority
/dev/sda6 partition 2104472 3904 -1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Currently, I am using a swap partition located from /dev/sda6. Take note of this.
Alternatively, here are the other ways to get the same swap info further:
# free
# fdisk -l | grep swap
# cat /etc/fstab | grep swap
# top -b -n 1 | head -5 | tail -1
CREATE SWAP FILE ON EXISTING PARTITION:
Since we already have a swap memory using swap partition, let us try to add and create additional swap memory using swap file. But this time, we would create it in an already existing linux (after installation), and into a different partition separate from existing swap partition.
Our current swap partition was /dev/sda6. From here, and for a test, let us try to create additional swap memory using a new swap file and placed it to /home/swap .
# cd /home/swap
Here, create a 2 MB swap file named newswap like so
# dd if=/dev/zero of=newswap bs=1024 count=20000
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20000+0 records in
20000+0 records out
20480000 bytes (20 MB) copied, 0.115077 s, 178 MB/s
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ls -la newswap
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-rw-r--r-- 1 root root 20480000 2007-07-17 17:07 newswap
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Now, set it up and inform linux its a swap file
# mkswap newswap
Result:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Setting up swapspace version 1, size = 20475 kB
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Before we add the new swap file, let's note of our current swap info
# free
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Swap: 2104472 7288 2097184
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# cat /proc/swaps
shows
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Filename Type Size Used Priority
/dev/sda6 partition 2104472 7288 -1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Now, activating the new swap file under /home/swap, still as root
# swapon newswap
SWAP VERIFICATION:
# cat /proc/swaps
will now show
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Filename Type Size Used Priority
/dev/sda6 partition 2104472 7288 -1
/home/swap/newswap file 19992 0 -3
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The same with
# free
shows your newly created swap file from a different / partition
Basically, this goes the same with a new swap file from a different harddrive. Simply mount the new harddrive and prepare a new folder with it for new swap file
# mount /dev/sdb1 /mnt/newharddisk
# cd /mnt/newharddisk
# mkdir newswapfolder
# cd newswapfolder
# dd if=/dev/zero of=newotherswap bs=1024 count=20000
# mkswap newotherswap
# swapon newotherswap
# cat /proc/swaps
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Filename Type Size Used Priority
/dev/sda6 partition 2104472 7288 -1
/home/swap/newswap file 19992 0 -3
/mnt/newharddisk/newotherswap file 19992 0 -4
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Now you have 3 swap files working :) which is not adviseable, but taken and hereby shown for the sake of creating and deleting swap files.
DISABLING SWAP
Turning off is as easy as
# swapoff swapfilename
# rm -rf swapfilename
HTH
Subscription
Categories
- HowTos (612)
- Linux Devices (40)
- Linux Diggs (620)
- Linux News (1541)
- Linux Videos (24)
Recent Posts
Blog Archive
-
▼
2007
(340)
-
▼
July
(107)
- AMSN messenger install howto
- firefox browser - yum update howto
- kopete messenger install howto
- Gaim pidgin messenger install howto
- xmms - multimedia player install howto
- UltraDMA - speedup your harddisk howto
- sabayon - user profile manager howto
- 50 quick linux command tips part 3
- No negotiations with Microsoft in progress
- connect SamSung D820 mobile to linux howto
- yum from ISO image or CD install howto
- missing portmap reinstall howto
- 50 quick linux command tips part 2
- 50 quick linux command tips part 1
- desktop wiki install howto
- NASA tests Linux for spacecraft control
- warzone 2100 strategy 3d game install howto
- motd - message of the day
- more with kernel name version howto
- stop and start networking service howto
- change network proxy preference howto
- alexa firefox toolbar plugin install howto
- reboot / halt system via CLI howto
- gparted partitioning install howto
- google picasa install howto
- pine and pico install howto
- adobe/macromedia flash player test and install howto
- realplayer install howto
- Microsoft's TrueType core fonts install howto
- Why Choose Fedora? (Fedora vs. Ubuntu)
- Microsoft vs Opensource
- the df command
- linux possessed by monsterz
- change display setting howto
- NTP clock synchronization howto
- qtparted partitioning magic install howto
- host name and host aliases explained
- IP aliasing - virtual IP howto
- viruskiller on linux
- change keyboard language setting
- changing ethernet card settings howto
- TIP: WiFi with chillispot and linux
- play tennis the linux way
- sudoku game install howto
- my linux box talked to me
- CD/DVD burning software install howto
- A SYSAD BLOG - LINUX: list out active host connect...
- list out active host connection howto
- more with linux command named history
- GnuPG and enigmail thunderbird add-ons
- PDF file readers install howto
- digikam - KDE photo management install howto
- gnome floppy formatter
- f-spot Gnome photo manager install howto
- VLC media player install howto
- ping IP subnet block howto
- TIP: find and delete files recursively
- list out opened host ports howto
- TIP: linux process priority scheduling management
- TIP: spammer sending email using squid
- remount partition as read only howto
- additional swap file howto
- CrossOver install howto
- system-config-securitylevel-tui and lokkit howto
- format a windows partition from linux hadrdisk
- TIP: monitoring while mounting USB devices
- zero-sized a file without permission / ownership c...
- TIP: auto create mail spool when adding user
- md5sum checksum howto
- IP address to country lookup howto
- gnome mail notification install howto
- add new harddisk to existing linux system
- TIP: block an IP address
- disk space report
- more trace route command alternatives
- changing your hardware / software clock howto
- other interesting ping commands
- send email via CLI howto
- adding static route howto
- send message to all logged in users
- unzip zip untar tar bzip2 bunzip2 gzip gunzip file...
- format of /etc/passwd, /etc/shadow and /etc/group
- remove user's cron jobs howto
- find the user's files howto
- passphraseless + passwordless ssh howto
- passwordless ssh howto
- X11 Forwarding via ssh howto
- skype install howto
- disable IPv6
- lsusb - list all USB devices
- make yum faster
- lspci - list all PCI devices
- kill a process
- beginners CLI guide for static ip address
- the pidof command
- retrieve data from mysql using bash script
- VirtualBox install howto
- call bash script inside php web page
- alternative linux browsers
- last / currently logged in users
-
▼
July
(107)
Tuesday, July 17, 2007
additional swap file howto
Subscribe to:
Post Comments (Atom)
ILoveTux - howtos and news | About | Contact | TOS | Policy
0 comments:
Post a Comment