
2) Initialize the swap file with the mkswap (using the file path instead of a device name)To setup a swap file, it is necessary to create that file before
initializing it with mkswap , e.g. using a command like
# dd if=/dev/zero of=swapfile bs=1024 count=65536
Note that a swap file must not contain any holes (so, using cp(1)
to create the file is not acceptable).
Ok, I issued the commands and created a 512 MB swapfile in /mnt. It seems to work but let me test it for a whileplatojones wrote:[UPDATE]You should be able to test the file before commiting it to fstab with the swapon 'swapfilepath' command. I've never done this, so let me know how it works out
yeah, it did work. But the problem is that initializing a swapfile takes an eternity in the first place. So I stopped mouting the swapfile at boot, and rather do it whenever I need to after having booted the system. This way, it can be done in the background while I am already working on the system. I guess buying another stick of ram is the best solution if one wants to spend the money. Having a Gigabyte of permanent swap-partition is the next best thing to have. The last alternative to resort to is to use a swapfile. But for me this is the only viable alternative, since I am not going to change my partition-scheme and I am not yet willing to pay another 100 Euro for a ram-stick.chetan13 wrote:so did your problem with the system getting locked for hours go away? I'm facing the same problem and if using the swap file worked for you, i'll also do the same.

Do you mean that mounting the swap file takes a long time? You only have to initialize it once with mkswap. From that point on, all you have to do is 'mount' it.But the problem is that initializing a swapfile takes an eternity in the first place. So I stopped mouting the swapfile at boot, and rather do it whenever I need to after having booted the system. This way, it can be done in the background while I am already working on the system.
It takes almost one and a half minutes.platojones wrote: Do you mean that mounting the swap file takes a long time? You only have to initialize it once with mkswap. From that point on, all you have to do is 'mount' it.
If it does take a long time to mount, there may be a problem with the setup. There may be some tuning that can be done to alleviate that.
Code: Select all
/mnt/swapfile none swap sw 0 0Code: Select all
date && swapon /mnt/swapfile && date
Do Okt 6 19:21:23 CEST 2005
Do Okt 6 19:22:50 CEST 2005
That is surprising. I can't imagine what swapon is doing that takes 1.5 minutes, though I'm not questioning your results. The test I did was with a very small swap partition, so it was obviously not respresentative of a 512 Mb swap file. I have a 2 Gb swap partition on my box and it probably takes less than a second to mount it, so I've never even bothered to time it. I'm assuming your swap entry in fstab comes after you've mounted the partition which it resides on. That would be the only thing I can think of that might cause problems, though I would expect that to result in a deadlock, not a long delay. Ah well, it works, in a fashion, and thus saves some money. I would advise that you set aside a swap partition in the future, should you re-install, no matter how much memory you have. In my years working with Unix-like systems, even if you have more RAM than you think you will ever need, the system performs much better with it. Unix is tightly bound to the VM concept and it suffers without it.It takes almost one and a half minutes.

momesana wrote:Code: Select all
date && swapon /mnt/swapfile && date Do Okt 6 19:21:23 CEST 2005 Do Okt 6 19:22:50 CEST 2005
Code: Select all
time swapon /mnt/swapfileI have reiserfs partitions and with those its easy to enlarge partitions but hard or impossible to shrink themiTux wrote:Hi,
You could always have shrink one of your partition and create a new one with the available space after that partition.
Some other people had the same problem. The system normally recovers after it terminates Firefox etc. and kwin always crashes so I have to restart it with kwin -replace ...iTux wrote: When no more memory is available, the OOM killer is invoked and it starts killing processes to get memory. It should not lock or bring the system down. Some of your applications (includes the possibility of X - graphical system) might get terminated though. But should not locked out for hours or bring it down. So there is some issue with your system.
I have now over 300 GB of diskspace since I recently bought a new 200 GB hard. I will repartition the discs as soon as Reiser4 is included in the vanilla kernel (I guess/hope 2.6.16 - 2.6.18), until then the swapfile trick will suffice and it really does work! The system doesn't lock anymore.iTux wrote: But start by adding swap space, you should had created some in the first place when you installed your system - unless you are really limited in disk space...

I just tried it on reiserfs:It takes almost one and a half minutes.
Code: Select all
[scourge]swp # time dd if=/dev/zero of=swap.img bs=1k count=524288
524288+0 records in
524288+0 records out
536870912 bytes (537 MB) copied, 8.97858 seconds, 59.8 MB/s
real 0m8.980s
user 0m0.228s
sys 0m8.489s
[scourge]swp # time mkswap swap.img
Setting up swapspace version 1, size = 536866 kB
no label, UUID=133c485e-223f-4b6f-8cf8-9cd856726143
real 0m6.004s
user 0m0.000s
sys 0m0.152s
[scourge]swp # time swapon swap.img
real 0m2.638s
user 0m0.000s
sys 0m2.632sCode: Select all
[scourge]home # time dd if=/dev/zero of=swap.img bs=1k count=524288
524288+0 records in
524288+0 records out
536870912 bytes (537 MB) copied, 9.97572 seconds, 53.8 MB/s
real 0m10.006s
user 0m0.160s
sys 0m3.980s
[scourge]home # time mkswap swap.img
Setting up swapspace version 1, size = 536866 kB
no label, UUID=f9f984d1-a600-46c5-bfeb-5c75ebd043cc
real 0m1.444s
user 0m0.000s
sys 0m0.068s
[scourge]home # time swapon swap.img
real 0m0.419s
user 0m0.000s
sys 0m0.420sCode: Select all
[scourge]tmp # time dd if=/dev/zero of=swap.img bs=1k count=524288
524288+0 records in
524288+0 records out
536870912 bytes (537 MB) copied, 7.50266 seconds, 71.6 MB/s
real 0m7.516s
user 0m0.200s
sys 0m6.760s
[scourge]tmp # time mkswap swap.img
Setting up swapspace version 1, size = 536866 kB
no label, UUID=cbb5deda-5d03-4caf-b6dc-61e80170cd4b
real 0m0.440s
user 0m0.000s
sys 0m0.356s
[scourge]tmp # time swapon swap.img
real 0m1.024s
user 0m0.000s
sys 0m1.012sCode: Select all
[scourge]winshare # time dd if=/dev/zero of=swap.img bs=1k count=524288
524288+0 records in
524288+0 records out
536870912 bytes (537 MB) copied, 25.3896 seconds, 21.1 MB/s
real 0m25.390s
user 0m0.192s
sys 0m5.260s
[scourge]winshare # time mkswap swap.img
Setting up swapspace version 1, size = 536866 kB
no label, UUID=b334d198-b660-4fb6-a912-93d193ab38d8
real 0m23.959s
user 0m0.000s
sys 0m0.976s
[scourge]winshare # time swapon swap.img
real 0m0.474s
user 0m0.000s
sys 0m0.444sCode: Select all
swapon /path/to/file &Code: Select all
localhost mnt # time swapon swapfile
real 0m0.546s
user 0m0.000s
sys 0m0.468s
localhost mnt # free -m
total used free shared buffers cached
Mem: 756 718 38 0 10 256
-/+ buffers/cache: 451 304
Swap: 511 0 511
localhost mnt #