[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: System performance using swap partition vs. swap file



Mark Knecht wrote:
Rick,
   You made my Linux day to think that I might have provided a good idea
back to you after all of your work here! <broad smile> Unfortunately, it
wasn't my idea personally, but I don't mind being the messenger.

   My current swap partition is a 1GB partition, so I shouldn't have any
problems with size. The machine currently has 256MB in it, but I might
go to 512MB one of these days, so I chose 1GB to get ready for that.

Good idea. I have two 2GB swap partitions myself, but only have 512MB of RAM.

   I don't understand the use for multiple swap partitions, but I'm
guessing it's either a server or SMP issue? Possibly really large memory
machines, say 4GB or DRAM, need 8GB or swap, so you have to break it
into pieces?

That's it. It goes back to ye old days of having a signed long as the file offset variable. The biggest signed, 32-bit value is 2GB. Why signed? Because lseek()'s prototype was:

long lseek(int filedes, long offset, int whence);

so you could "lseek(fd, -256, SEEK_CUR)" and move back 256 bytes in
the file.  This is also the cause of problems with some programs
using files >2GB (e.g. apache).

lseek now uses "off_t" types, which are "long long" ints, giving you an
unsigned 64-bit integer.  Newer programs know this and have been
recompiled with the bigger value.

Details, details!

   Anyway, I'll have to see if any of my books cover making and
installing swap files.

Make your partition and mount it. Create a contiguous file of the size you want filled with zeroes (for example, 2GB):

# dd if=/dev/zero of=/mountpoint/swapfile1 bs=1M count=2048

Then "swapon /mountpoint/swapfile1" to activate it.  You can also
add a line like:

/mountpoint/swapfile1 swap swap defaults 0 0

to your /etc/fstab and the system will activate it (via "swapon -a")
on the next boot automatically.

   I can't see the need for ext3 on a swap file.I know you didn't really
suggest it, but the possibility crept in the way you responded.

No, I just meant that the label is stored in the filesystem's header. swap filesystems do not support labels. ---------------------------------------------------------------------- - Rick Stevens, Senior Systems Engineer rstevens vitalstream com - - VitalStream, Inc. http://www.vitalstream.com - - - - We look for things. Things that make us go! - ----------------------------------------------------------------------





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]