Wednesday, January 11, 2012

Adding a swap file in Linux


Program which we will use is the 'dd', which serves to convert and double (duplicate) a file.

#free
total used free shared buffers cached

Mem: 255828 207108 48720 0 7428 112220

-/+ buffers/cache: 87460 168368

Swap: 562232 112408 449824

This time we will add a swap file of 500 Mb. 
#dd if=/dev/zero of=/swapbaru bs=1024 count=512000

512000+0 records in

512000+0 records out

if=/dev/zero, /dev/zero sebagai file input
of=/swapbaru, write file output ke /swapbaru

ibs=1024, ibs of 1024

count=512000, only 512Mb meng'copy block for input

#mkswap /swapbaru
Setting up swapspace version 1, size = 524283 kB

#swapon /swapbaru
If we want to use these additional swap automatically add the following line in /etc/fstab.



/swapbaru none swap sw 0 0

See the size of the swap after adding the file /swapbaru
#free -o

total used free shared buffers cached

Mem: 255828 208640 47188 0 7816 112220

Swap: 1074224 112408 961816

No comments:

Post a Comment