swap byte size?!

Cameron Simpson cs at zip.com.au
Wed Jul 21 05:50:14 UTC 2004


On 20:48 20 Jul 2004, kalin mintchev <kalin at el.net> wrote:
| i want to add a swap file to my system. following the rule of 2 to 1 the
| file would need to be 2 gigs because the ram is a gig. but using the dd
| command what do i put for bs and count?
| i was looking around on google but couldn't exactly find it..

block size * count should equal your swap file size.
You want count to be "small". So:

	% dc
	1024 1024 *p
	1048576
	% dd if=/dev/zero count=1024 bs=1048576 of=your-swap-file
	%

In fact, you can probably do it in a single write:

	% dc
	1024 1024 1024 **p
	1073741824
	% dd if=/dev/zero count=1 bs=1073741824 of=your-swap=-file

I just did that on a machine here and it took quite a while.  That may
be because a big block size will map a chunk of memory, virtually,
and as you fill it from /dev/zero that will cycle your RAM to swap as
things fill. So probably you want a big blocksize, but not as big as
possible. One megabyte should do nicely - big enough to move a lot of
data per write, small enough that its memory footprint doesn't blow your
RAM usage.

The basic deal is that small block size and large count means lots of
write() calls, and that is inefficiency because each such call has some
overhead; to minimise that you minimise count and maximise blocksize
without getting silly.

Cheers,
-- 
Cameron Simpson <cs at zip.com.au> DoD#743
http://www.cskk.ezoshosting.com/cs/

The problem is, every time something goes wrong, the paperwork is found
in order...     - Walker on NASA





More information about the redhat-list mailing list