Welcome! Log In Create A New Profile

Advanced

swap space on pogo E02

Posted by Adam 
swap space on pogo E02
February 03, 2015 06:36AM
i made sure to partition my usb drive with a swap partition, but it doesnt look like my pogo is actually using it. before I started doing general linux swap research, i wanted to check here to see if i was missing something.
i verified that swap is not being used with " sudo swapon -s"

thanks!
Re: swap space on pogo E02
February 03, 2015 07:19AM
I run swap on my PogoPlugs that run Debian via the dphys-swapfile program, not a separate partition.
Re: swap space on pogo E02
February 03, 2015 03:25PM
Adam Wrote:
-------------------------------------------------------
> i made sure to partition my usb drive with a swap
> partition, but it doesnt look like my pogo is
> actually using it. before I started doing general
> linux swap research, i wanted to check here to see
> if i was missing something.
> i verified that swap is not being used with " sudo
> swapon -s"
>
> thanks!

Depending on memory usage of your processes. If you don't use a lot of memory intensive programs, it might never need swap. You could look at it from time to time:
free

However, it's simpler using swap file. Either use dphys-swapfile as Federick recommended, or set it up manually.

Manual setup:

Example for creating a 1G swap file in the root folder:
dd if=/dev/zero of=/swapfile1 bs=1024 count=1048576 
mkswap /swapfile1
swapon /swapfile1

The idea is you can add more swap files or move/delete them at any time. Turn off swap before changing them:
swapoff -a

-bodhi
===========================
Forum Wiki
bodhi's corner
Re: swap space on pogo E02
February 04, 2015 06:01AM
using "free" on my three pogos shows that i have 72M free on one, 5.6 free on another, and 159M free on the last one. im barely doing anything on any of them though...

here is what htop looks like on all three: http://imgur.com/4h3bnNn

does that seem normal?
Re: swap space on pogo E02
February 05, 2015 12:28AM
free command:
http://www.linuxnix.com/2013/05/find-ram-size-in-linuxunix.html

htop showed that you have no swap space (0/0MB). It means your swap file/partition setup was incorrected..

-bodhi
===========================
Forum Wiki
bodhi's corner
Re: swap space on pogo E02
February 05, 2015 05:42AM
right. this was prior to setting up swap.

I just wanted to see if there was anything weird about the memory usage in your opinion
Re: swap space on pogo E02
February 05, 2015 10:03AM
Another vote for keeping things simple and using a swapfile versus swap partition.

#This will create a 1024MB swap file
#Named "swapfile.img" in /media/usb (USB HD).
dd if=/dev/zero of=/media/usb/swapfile.img bs=1M count=1024
mkswap /media/usb/swapfile.img

#update swap file permissions
chmod 0600 /media/usb/swapfile.img

#You can now turn the swap file on using:
swapon /media/usb/swapfile.img

#check if swap is enabled
free

#turn swap off by using:
#swapoff /media/usb/swapfile.img

#enable swapfile on reboot
echo "/media/usb/swapfile.img none swap sw,nofail 0 0" >> /etc/fstab

#reboot and test
reboot
free
Re: swap space on pogo E02
February 05, 2015 11:32AM
grayman4hire,

> #enable swapfile on reboot
> echo "/media/usb/swapfile.img none swap sw,nofail
> 0 0" >> /etc/fstab

I would avoid adding this to fstab. Turn swap on in /etc/rc.local is better, IMO.

/etc/rc.local
....
swapon /swapfile1
swapon /swapfile2
....

-bodhi
===========================
Forum Wiki
bodhi's corner



Edited 1 time(s). Last edit at 02/05/2015 11:42AM by bodhi.
Re: swap space on pogo E02
February 05, 2015 11:41AM
Adam Wrote:
-------------------------------------------------------
> right. this was prior to setting up swap.
>
> I just wanted to see if there was anything weird
> about the memory usage in your opinion

They are normal. I did not see anything wrong. When you use free, subtract the cached and bufferred memory from the used memory to get the actual used memory.

-bodhi
===========================
Forum Wiki
bodhi's corner
Re: swap space on pogo E02
February 06, 2015 02:27PM
@grayman4hire,

I've modified my above post a bit to explain my swap files configuration.

I would avoid adding swap file to fstab if possible. Turn swap on in /etc/rc.local is better, IMO. However, if your box has a lot of stuff that start during kernel booting, then a swapfile in fstab would help a lot, perhaps preventing problem.

In my setup for boxes that boot with USB, and the main swap file is on an attached HDD. I have the first swap file on the USB rootfs, which is also specified in fstab. In rc.local, I turn off swap and switch to the main swap file on HDD if it is available.

-bodhi
===========================
Forum Wiki
bodhi's corner



Edited 1 time(s). Last edit at 02/06/2015 02:29PM by bodhi.
Re: swap space on pogo E02
February 08, 2015 02:11PM
I've always turn on swap via fstab. What's the downside?

bodhi Wrote:
-------------------------------------------------------
> @grayman4hire,
>
> I've modified my above post a bit to explain my
> swap files configuration.
>
> I would avoid adding swap file to fstab if
> possible. Turn swap on in /etc/rc.local is better,
> IMO. However, if your box has a lot of stuff that
> start during kernel booting, then a swapfile in
> fstab would help a lot, perhaps preventing
> problem.
>
> In my setup for boxes that boot with USB, and the
> main swap file is on an attached HDD. I have the
> first swap file on the USB rootfs, which is also
> specified in fstab. In rc.local, I turn off swap
> and switch to the main swap file on HDD if it is
> available.
Re: swap space on pogo E02
February 08, 2015 03:28PM
grayman4hire,

The only down side is that anything in fstab that is missing will cause the system to stop booting. However, as I mentioned, if you have a lot of stuff started during kernel booting then swap should be defined in fstab.

-bodhi
===========================
Forum Wiki
bodhi's corner
Re: swap space on pogo E02
February 08, 2015 04:46PM
Got it. That use to be a problem for me until I discovered the "nofail" option.

echo "/media/usb/swapfile.img none swap sw,nofail 0 0" >> /etc/fstab


bodhi Wrote:
-------------------------------------------------------
> grayman4hire,
>
> The only down side is that anything in fstab that
> is missing will cause the system to stop booting.
> However, as I mentioned, if you have a lot of
> stuff started during kernel booting then swap
> should be defined in fstab.
Re: swap space on pogo E02
February 08, 2015 04:50PM
grayman4hire,

> Got it. That use to be a problem for me until I
> discovered the "nofail" option.
>
> echo "/media/usb/swapfile.img none swap
> sw,nofail 0 0" >> /etc/fstab

Indeed! that would get around the problem, but silently so.

-bodhi
===========================
Forum Wiki
bodhi's corner
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: