9

I am using my raspberry pi as a headless server. The problem is that after a couple of hours of inactivity it seems to enter a power suspend state where it disappears from the web and refuses ssh connections. After having prodded it via ssh it comes back after a couple of minuttes and uptime informs that it has been alive all the while. This makes me think it is some kind of power management scheme that is in effect but I have read other places that the pi is not able to suspend.

Does anyone have an idea what is wrong?


Update:

After having spent a great deal of time trying to figure this out it seems a number smaller issues have helped:

  1. Configure postfix to not use ipv6.
  2. Use fail2ban to blacklist ssh login attempts.
  3. Update firmware on router.

All three items seems to have had a positive effect on the pi's uptime. It is now reasonably stable and I have not the login-problem for about three weeks.

Kenneth
  • 731
  • 1
  • 4
  • 11
  • Which OS are you using? – xxmbabanexx Apr 11 '13 at 13:44
  • even I face the occasional ssh failure when using my pi headless which a few retries resolve almost all the time.I use shellinabox to login my shell which seems faster for some reason I don't know.I am not sure about the security when using shellinabox but I access my pi mostly from within the LAN. – SteveIrwin Apr 11 '13 at 18:48
  • I am on a standard Raspbian setup (the pre-installed sd-card) with all the graphical stuff removed. – Kenneth Apr 11 '13 at 18:58

2 Answers2

14

The wireless device goes to sleep after a period of no activity. It's a powersaving scheme.

You need to turn off the powersave feature of wlan0.

I'm using an edimax wireless usb receiver:

Bus 001 Device 005: ID 7392:7811 Edimax Technology Co., Ltd EW-7811Un 802.11n Wireless Adapter [Realtek RTL8188CUS]

It uses the 8192cu module in the kernel.

To turn off powersave, add the following to /etc/modules, or create a file (8192cu.conf) in /etc/modprobe.d/ with the line(s):

# prevent power down of wireless when idle
options 8192cu rtw_power_mgnt=0 rtw_enusbss=0

Next reboot (or rmmod/insmod) it should disable the sleepy mode and your pi will be accessible all the time.

I create the file for /etc/modprobe.d and it's part of a script I built to do preliminary setup on a new build.

lornix
  • 1,066
  • 8
  • 13
  • I am not using wlan. It is plugged directly into the router. – Kenneth Jun 10 '13 at 12:42
  • Hmm, the only other thing is to recommend using a good quality usb cable to power the pi. (shorter is better too) I had issues with my units 'disappearing' which stopped when I used a decent cable instead of one of my handful of cheapies. The pi is very sensitive to voltage dips. I imagine if you had a cheap usb cable and a 6V 1+A p/s you'd be fine, but the standard 5V 1+A p/s's voltage dips below pi's threshold due to I2R losses in the usb cable. – lornix Jun 13 '13 at 16:11
  • 1
  • You only need rtw_power_mgnt=0 2. You can verify it's taken effect with cat /sys/module/8192cu/parameters/rtw_power_mgnt, which should return 0.
  • – Air Sep 06 '15 at 00:41