Welcome! Log In Create A New Profile

Advanced

swap space on pogo E02

Posted by Adam 
swap space on pogo E02
February 03, 2015 07: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 08: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 04: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 (buy bodhi a beer)
Re: swap space on pogo E02
February 04, 2015 07: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 01: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 (buy bodhi a beer)
Re: swap space on pogo E02
February 05, 2015 06: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 11: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 12:32PM
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 (buy bodhi a beer)



Edited 1 time(s). Last edit at 02/05/2015 12:42PM by bodhi.
Re: swap space on pogo E02
February 05, 2015 12:41PM
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 (buy bodhi a beer)
Re: swap space on pogo E02
February 06, 2015 03: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 (buy bodhi a beer)



Edited 1 time(s). Last edit at 02/06/2015 03:29PM by bodhi.
Re: swap space on pogo E02
February 08, 2015 03: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 04: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 (buy bodhi a beer)
Re: swap space on pogo E02
February 08, 2015 05: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 05: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 (buy bodhi a beer)
Re: swap space on pogo E02
February 12, 2021 07:19PM
What's the best way to make a mount point?

I'm booting Debian from sda and created my swapfile on sdb1, everything seems fine except it doesn't survive a reboot.
It's probably a misunderstanding on my part, but I assumed that once Debian booted up, that I wouldn't have to manually create mount points for anything mounted in the USB ports. I thought Debian would take care of that?

On my rootfs boot USB I created a USB directory in media, where I can manually mount:
mount /dev/sdb1 /media/usb
swapon /media/usb/swapfile.img

In my fstab I have the following:
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
LABEL=rootfs    /               ext3    noatime,errors=remount-ro 0 1
tmpfs          /tmp            tmpfs   defaults          0       0
UUID=4d425bde-537c-45c2-9852-13b8fa32481e /media/usb ext3 defaults 0 0
/media/usb/swapfile.img none swap sw,nofail 0 0

It all seems to be fine, but the USB doesn't mount on powerup, what am I missing? do I really have to manually create mount points
Re: swap space on pogo E02
February 12, 2021 08:38PM
Rhodess,

See here for how to set up automount:

https://forum.doozan.com/read.php?2,24139

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: swap space on pogo E02
February 13, 2021 05:31AM
And also, there are many different ways to mount the swap file, too. Such as in /etc/rc.local.

I'll come back and explain it later.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: swap space on pogo E02
February 13, 2021 01:11PM
Thanks bodhi.

I just made another post regarding memory limitations. I think I'll restore my original image and then spend time setting up the swapfile and the udev mounts first, and ensure I have a stable system with optimized memory. I think the issues I'm seeing are trying to run before I can walk, trying to do too much too fast.

Essentially, all I want is to be able to plug in and mount USB devices, be in ram, or a printer etc.
Author:

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: