This is an old revision of the document!
Table of Contents
dCore Swap
Overview
A swap primer for dCore users with minimal Linux or Tiny Core Linux experience.
Depending on intended use, a Linux swap partition or swap file is recommended for systems with < 1-2 GB RAM. Swap is especially useful on low RAM systems to import/update large extensions, run numerous/heavier applications, compile software or set up hibernation.
By default, dCore will seek and utilize any existing swap partition at boot. It also by default utilizes zswap at boot. A boot code is necessary to enable a previously set up swap file. Review the swap related boot codes below for more information related to enabling a swap file or disabling swap and zswap.
The following commands are useful to confirm swap utilization:
cat /etc/fstab cat /proc/swaps dmesg | grep swap free -m
Example outputs outlined below utilizing a system with 512 MB RAM, 729 MB swap partition plus zswap. Note total swap indicated by free -m
includes all available swap (eg. swap partition + zswap).
tc@box:~$ cat /etc/fstab | grep swap /dev/zram0 swap swap defaults,noauto 0 0 /dev/sda5 none swap defaults 0 0
tc@box:~$ cat /proc/swaps Filename Type Size Used Priority /dev/zram0 partition 116524 5224 -1 /dev/sda5 partition 746984 0 -2
tc@box:~$ dmesg | grep swap [ 2.968436] Adding 116524k swap on /dev/zram0. Priority:-1 extents:1 across:116524k SSFS [ 10.644207] Adding 746984k swap on /dev/sda5. Priority:-2 extents:1 across:746984k FS
tc@box:~$ free -m total used free shared buffers cached Mem: 500 484 15 80 62 233 -/+ buffers/cache: 188 311 Swap: 843 5 838
Swap Partition
Setting up a swap partition during a fresh installation using fdisk is outlined in the Partition Hard Drive and Create Hard Drive File Systems sections of dCore Install from ISO to Hard Drive Without Pre-Existing Boot Loader. For systems with a pre-partitioned drive, it may be easier to use a Linux LiveCD that contains GParted. Alternatively set up a swap file, outlined below. To confirm the swap partition is being used, reboot system and run the commands outlined above.
Swap File
If a swap partition was not set up prior to the installation of dCore, it would be easiest to set up a swap file rather than create a new swap partition. From a graphic environment open Control Panel (cpanel) → Swapfile Tool (swapfile) and enter the desired mounted partition to utilize along with the desired swap file size. Then add the swapfile bootcode to the system's boot loader to activate upon reboot, example swapfile=sda1
. To confirm the swap file is being used, reboot system and run the commands outlined above.
Boot Codes
For more information regarding Tiny Core Linux boot codes review boot codes explained.
The following swap related boot codes are available:
- swapfile: use the specified partition's swap file (eg. swapfile=sda2).
- noswap: disable use of any swap partition(s) (eg. noswap).
- nozswap: disable zswap (eg. nozswap).
Miscellaneous
As outlined, dCore automatically seeks available swap partition(s) at boot. If using the swapfile boot code, a swapfile needs to be set up in advance. By default dCore uses zswap, which sets aside a block of RAM to use as compressed swap space, so systems with adequate RAM may not require dedicated swap. Review the Wikipedia zswap link above for more information, especially the CPU cycles vs I/O tradeoff. Actual system experimentation is recommended to determine which swap options or boot codes are required, if any. This Linux Swap File How To is a valuable resource for manually creating a swap file or experimenting with swappiness.