Agregar Swap
El WRT54GL tiene 16 Mb de memoria RAM las cuales se pueden llenar con mucha facilidad a la hora de realizar alguna operación que consuma un poco de memoria RAM para ello se debe crear una partición en la SD de tipo swap y luego adicionarla al sistema.
el comando free nos puede servir para saber cuanto tenemos disponible de la RAM y cuanto se encuentra utilizando:
root@OpenWrt:~# free
total used free shared buffers
Mem: 14304 8856 5448 0 1024
Swap: 0 0 0
Total: 14304 8856 5448
Creando la partición
instalamos fdisk en el WRT54GL
ipkg install fdisk
luego se va a entrar al dispositivo /dev/mmc/disc0/disc donde se encuentra la SD
fdisk /dev/mmc/disc0/disc
Command (m for help): p
Disk /dev/mmc/disc0/disc: 2013 MB, 2013265920 bytes
16 heads, 15 sectors/track, 16384 cylinders
Units = cylinders of 240 * 512 = 122880 bytes
Device Boot Start End Blocks Id System
/dev/mmc/disc0/part1 1 10000 1199992+ 83 LinuxCon la opción n se crea una nueva partición se coloca que va ser primaria y se escoge el tamaño
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 4
First cylinder (10001-16384, default 10001):
Using default value 10001
Last cylinder or +size or +sizeM or +sizeK (10001-16384, default 16384):
Using default value 16384
Command (m for help): p
Disk /dev/mmc/disc0/disc: 2013 MB, 2013265920 bytes
16 heads, 15 sectors/track, 16384 cylinders
Units = cylinders of 240 * 512 = 122880 bytes
Device Boot Start End Blocks Id System
/dev/mmc/disc0/part1 1 10000 1199992+ 83 Linux
/dev/mmc/disc0/part4 10001 16384 766080 83 Linux
Command (m for help): Como se puede ver /dev/mmc/disc0/part4 10001 16384 766080 83 Linux tiene el ID 83 se debe cambiar al ID 82 el cual pertenece a un tipo de partición Swap, esto se realiza con la opción t
Command (m for help): t
Partition number (1-4): 4
Hex code (type L to list codes): 82
Changed system type of partition 4 to 82 (Linux swap / Solaris)
Command (m for help): p
Disk /dev/mmc/disc0/disc: 2013 MB, 2013265920 bytes
16 heads, 15 sectors/track, 16384 cylinders
Units = cylinders of 240 * 512 = 122880 bytes
Device Boot Start End Blocks Id System
/dev/mmc/disc0/part1 1 10000 1199992+ 83 Linux
/dev/mmc/disc0/part4 10001 16384 766080 82 Linux swap / Solarisy para finalizar se coloca w para guardar los cambios seguido de ello se debe reiniciar el router.
Dando formato a la Swap
para darle el formato a la Swap se debe instlar el paquete swap-utils
ipkg install swap-utils
luego de ello se formatea la partición
mkswap /dev/mmc/disc0/part
Agregando la Swap a la memoria RAM
Para agregar la partición creada se realiza con swapon y ejecutamos el comando free para comprobar cuanta RAM tenemos
root@OpenWrt:~# swapon /dev/mmc/disc0/part4
root@OpenWrt:~# free
total used free shared buffers
Mem: 14304 8940 5364 0 1024
Swap: 166192 0 166192
Total: 180496 8940 171556