Hardware Reference
In-Depth Information
shortening of life span. If you really want to add swap, the best possible case
is over an actual external hard drive connected via a SATA-to-USB converter.
Raspbian comes preconfigured with a 100 MB swap file enabled, via
dphys-swapfile
.
You can change the settings of this swapfile by editing
/etc/dphys-swapfile
. It has only
one option:
CONF_SWAPSIZE
. If you want to increase the size of the swapfile, change the
value from
100
to a larger value (depending on the free space on your SD card). Alter-
natively, you can disable this option by changingthe value to ++0.
Any changes to this value will not take effect until you run the following commands:
$ /etc/init.d/dphys-swapfile stop
$ /etc/init.d/dphys-swapfile start
Pidora configures 512 MB of swap by default at firstboot (unless the user specifies
otherwise). This is placed in the file
/swap0
and configured in
/etc/fstab
by the rootfs-
resize service.
For other Linux distributions (or to place a swapfile on a different location), you will
need to manually create the swapfile:
$ sudo dd if=/dev/zero of=/path/to/swapfile bs=1M count=1024
$ sudo mkswap /path/to/swapfile
$ sudo swapon /path/to/swapfile
These commands will generate a 1 GB swap file (1024 x 1 M = 1 GB) at
/path/to/
swapfile
, which you should change to the location of your swapfile. To make the swap
file automatically enabled on boot, add a new line to your
/etc/fstab
file:
/path/to/swapfile none swap defaults 0 0
You will see the additional memory (as swap) in the output of the
free
command:
$ free
total used free shared buffers cached
Mem: 448688 436960 11728 0 6776 395392
-/+ buffers/cache: 34792 413896
Swap: 1048572 0 1048572