Search This Blog

Monday, November 28, 2005

[Not only] Crux and swapfile

I prefer swapfile to swap partition in Linux. The file is much more flexible and have the same performance (in 2.6 kernel). The way to create swapfile in Crux is standard, but you have to hack /etc/rc file to make in turning on in the system start sequence (see point 5).
  1. First you have to create the file. The size of a swap should be equal to a memory size (of course if you have a lot of memory you don't need swap). In example, we are creating 256Mb swapfile:
    dd if=/dev/zero of=/swapfile bs=1M count=256
  2. Now, we are creating swap on our file:
    mkswap /swapfile
  3. Next we have to edit the /etc/fstab file, by adding:
     /swapfile  none   swap   defaults  0 0
  4. After that, we can easily turn on our swapfile:
    swapon -a
  5. It will be nice to have swap turning on it the time of system start. To get this we have to edit the /etc/rc. In the standard Crux configuration a swap is turn on before mounting filesystems. To change it we move
    # Activate swap
    /sbin/swapon -a
    after lines which mounting partition where our swapfile is:
    # Mount local filesystems
    /bin/mount -n -o remount,rw /
    /bin/rm -f /etc/mtab*
    /bin/mount -a -O no_netdev
Post a Comment