|
|
How-to Add More Swap Without Having To Re-partiton | ||
Discussion by qwijibow with 1 Replies.
Last Update: December 16, 2007, 10:20 pm | |||
![]() |
|
|
If you dont have nough mmory, (ram + swap) there are 3 things you can do.
the first 2 are the most obviouse,
1) buy more memory.
2) use knoppix and qtparted to re-size your parttions
3) the little known easy method.
You may not know, but linux has a loop driver in the /dev/ folder that allows a file on the hard disk to act as a disk drive / disk partiton. you can use it in exactly the same way your would use /dev/hda1 or /dev/cdrom.
here is how to use it to quickly add extra virtual memory.
before we start, make sure your loop driver is loaded... have a look in the /dev/ folder for files named loopX where X is a number between 0 and 7, possably by using the ommand "ls /dev/ | grep loop"
if its not there, then as root run "modprobe loop" and look again.
all these commands need to be done as root user.
to become root user run the command "su -" and enter the root password.
when you have finished, be sure to run "exit" to giveup the root privilages.
first, create the file that will contain the virtual disk drive.
the abouve command will copy 256 * 1Megabyte from the file /dev/zero into the file /SWAP.img.
/dev/zero is a pretend file, which dontains an infinite number of "0"'s for more info, read "man dd"
replace 256 with the extra amount of memory you require.
secondly, we need to setup the loop driver, to create a /dev/ interface to the file.
their are 8 loop devices, somtimes the first one or 2 is in use, so to be save, lets use the 6th.
now /dev/loop5 will act as a disk drive, and save all its information to the /SWAP.img file automatically.
for more information about losetup, read "man losetup" (you can delete a loop device like so "losetup -d /dev/loopX" where X is the loop number.
thirdly... we need to format the disk as swap.
finally, activate the swap
if you ever need to remove the swap file, first de-activate, then delete the interface, then delete the file.
losetup -d /dev/loop5
rm /SWAP.img
to make the added swap activate automatically add the following lines to the end or your rc.local startup script. this script is in different places for different distro's but i will be somwhere in your /etc/ folder.
most likely /etc/init.d/rc.local
swapon /dev/loop5
the first 2 are the most obviouse,
1) buy more memory.
2) use knoppix and qtparted to re-size your parttions
3) the little known easy method.
You may not know, but linux has a loop driver in the /dev/ folder that allows a file on the hard disk to act as a disk drive / disk partiton. you can use it in exactly the same way your would use /dev/hda1 or /dev/cdrom.
here is how to use it to quickly add extra virtual memory.
before we start, make sure your loop driver is loaded... have a look in the /dev/ folder for files named loopX where X is a number between 0 and 7, possably by using the ommand "ls /dev/ | grep loop"
if its not there, then as root run "modprobe loop" and look again.
all these commands need to be done as root user.
to become root user run the command "su -" and enter the root password.
when you have finished, be sure to run "exit" to giveup the root privilages.
first, create the file that will contain the virtual disk drive.
CODE
dd if=/dev/zero of=/SWAP.img bs=1M count=256the abouve command will copy 256 * 1Megabyte from the file /dev/zero into the file /SWAP.img.
/dev/zero is a pretend file, which dontains an infinite number of "0"'s for more info, read "man dd"
replace 256 with the extra amount of memory you require.
secondly, we need to setup the loop driver, to create a /dev/ interface to the file.
their are 8 loop devices, somtimes the first one or 2 is in use, so to be save, lets use the 6th.
CODE
losetup /dev/loop5 /SWAP.imgnow /dev/loop5 will act as a disk drive, and save all its information to the /SWAP.img file automatically.
for more information about losetup, read "man losetup" (you can delete a loop device like so "losetup -d /dev/loopX" where X is the loop number.
thirdly... we need to format the disk as swap.
CODE
mkswap /dev/loop5finally, activate the swap
CODE
swapon /dev/loop5if you ever need to remove the swap file, first de-activate, then delete the interface, then delete the file.
CODE
swapoff /dev/loop5losetup -d /dev/loop5
rm /SWAP.img
to make the added swap activate automatically add the following lines to the end or your rc.local startup script. this script is in different places for different distro's but i will be somwhere in your /etc/ folder.
most likely /etc/init.d/rc.local
CODE
losetup /dev/loop5 /SWAP.imgswapon /dev/loop5
I don't know that by mounting a virtual device you could extend you swap. It's a great an easy solution if you do not want to re-partition your drive.
But what about performance?
Because one of the advantages of Unix systems over Windows is that "virtual memory" is stored in an individual and exclusive partition (swap) and Windows stores it in the same partition of the system (usually C:).
The advantage of having an exclusive partition for virtual memory is that the swapped pages do not need to "compete" for allocation and virtual memory is faster, may be in this solution you propose the performance is similar as to having the complete virtual memory as one unit because I see that you pre-allocate this memory file.
But what about performance?
Because one of the advantages of Unix systems over Windows is that "virtual memory" is stored in an individual and exclusive partition (swap) and Windows stores it in the same partition of the system (usually C:).
The advantage of having an exclusive partition for virtual memory is that the swapped pages do not need to "compete" for allocation and virtual memory is faster, may be in this solution you propose the performance is similar as to having the complete virtual memory as one unit because I see that you pre-allocate this memory file.
Similar Topics:
Help Installing Windowsxp On A Part...
okay.. ive given up on Linux's professional dvd authoring software... i cant get my head round it.
its too powerfull for my basic needs, and im not an AV expert.. all the multiplexing is driving me mad.
i got a simple tool that got bundles with my dvd-writer, its very simple.. ...more
To Swap, Or Not To Swap ?
Do any of you guys tweak your virtual memory / swap settings ?
(either with windows, or linux kernel)
have you noticed an increace in performance after your tweaks ?
if so, how did you tweak, how much ram do you have, and on a typical use, how many applications are you runni ...more
Reiser4 How To Use It As A Root P...
This is by no means a complete tutorial,
Simply instruction on how I managed to install gentoo onto a reiser4 partiton.
This is not for beginers! I will assume you have a good understanding of linux, and are capable of more advanced things, such as patching, configureing, comp ...more
Howto: Change System Runlevel Of A Process & assign multiple runlevels to processes (0)
|
(4) Lm_sensors And The Vnf3-250 Or It8712f how to detect system specs.
|
HOME 





SD CARD PARTITION, FAT32 EXT2 & LINUX SWAP
How to create EXT3 partition on SD card with ClockworkMod Recovery?
Windows 7 How To: Resize a Partition

