Menu

Setup swap space

Georg

Setup swap space

Nanolinux will run fine in 64 MB RAM using the included applications. In case the installed RAM should be unsufficient anyhow for whatever reason you can either use a swap partition or a swap file to allow Nanolinux to temporarily swap part of its memory to disk.

If you enter the "free" command you will see that Nanolinux always sets up a "zram" or "compressed swap in RAM". The commands "swapon -s" and "cat /proc/swaps" will give more details about that. Nanolinux uses zram to compress loaded applications. There is the bootcode "nozswap" which will stop Nanolinux to setup "zram" automatically.

Use a Hard Drive partition

Use this alternative if you run Nanolinux in Qemu and have virtual disks or you have a hard drive where you can set up an addition partition for swap space.

Lets assume you have setup a partition for swap space called "sda1". The wiki page Nanolinux in Qemu on Windows describes how to partition a drive. The command "fdisk -l" will list the available partitions.

Now format this partition for swap space:

sudo mkswap /dev/sda1 

followed by

sudo swapon /dev/sda1

The command "cat /proc/swaps" will show that the swap partition is now added to Nanolinux. Nanolinux will mount swap partitions it finds during the boot process.

Use a swap file

If you do not want to use a partition as swap space you can also use a swap file within an existing partition. You create a 256 MB swap file with this command in partition sda1:

sudo dd if=/dev/zero of=/mnt/sda1/tc.swp bs=1024 count=262144

This may take a while. Then give root write permissions to this file:

sudo chmod 600 /mnt/sda1/tc.swp

Make this file a swap area:

sudo mkswap /mnt/sda1/tc.swp

enable it now:

sudo swapon /mnt/sda1/tc.swp

To get Nanolinux to use this file for swap space you have to add the boot code "swapfile=sda1". If you boot from CD press F2 and enter "mc swapfile=sda1". Nanolinux will search the file tc.swp and mount it during the boot process.


Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.