Stop the annoying USB power autosuspend under GNU/Linux

Got a problem that the usb mouse will been poweroff/suspend periodically on Linuxmint 17 when the notebook is not in ac mode, here is a quick fix without rebooting system:

echo "-1" | sudo tee /sys/bus/usb/devices/*/power/autosuspend_delay_ms
echo "on" | sudo tee /sys/bus/usb/devices/*/power/control

For permanent change, for example on Debian / Ubuntu based GNU/Linux, with usbcore module:

echo "options usbcore autosuspend=-1" | sudo tee /etc/modprobe.d/disable-usb-autosuspend.conf 
options usbcore autosuspend=-1

Reference:

Linux kernel Power Management for USB documentation:
https://www.kernel.org/doc/Documentation/usb/power-management.txt

How to disable auto power off of usb devices like usb mouse?
http://askubuntu.com/a/301416

FreeBSD 的 kernel source…

今天在灌機器的時候想說source大概不會用到就沒選了

結果從ports安裝htop的時候…

===> Staging for htop-1.0.2
===> htop-1.0.2 depends on executable: lsof - not found
===> Verifying install for lsof in /usr/ports/sysutils/lsof
===> lsof-4.88.g,8 requires kernel sources.
*** [install] Error code 1

Stop in /usr/ports/sysutils/lsof.
*** [run-depends] Error code 1

Stop in /usr/ports/sysutils/htop.

原來lsof需要kernel source這玩意兒…

解法: 從安裝光碟/隨身碟抓source tarball出來,剛好主機在學術網路上我就用網路抓了…
(ftp.tw.freebsd.org這台主機目前在交大資工)

#wget http://ftp.tw.freebsd.org/pub/FreeBSD/releases/amd64/9.2-RELEASE/src.txz
#tar -C / -xf src.txz

按照主機所安裝的版本以及架構不同,amd64可能會需要替換為i386等,9.2-RELEASE也應該對應到該主機的系統版本

接下來的安裝就很順利,看來以後安裝都不要省src免得不時之需還要手動解,現在的硬碟空間根本不差那一點啊…

在 AWS 上的 Ubuntu 安裝 zram-config 出錯

放在 Amazon Web Services (AWS) 上的機器因為用途跟價格的關係, ram 的規格開很小,靠 swap 來緩衝的話吃 IO 吃比較兇會被多收錢,想要用 zram 來壓記憶體

zram 的說明可以參考 Wikipediahttp://zh.wikipedia.org/wiki/Zram

zram 是 Linux 核心的一個模組,之前被稱為「compcache」。zram 透過在RAM內的壓縮塊裝置上分頁,直到必須使用硬碟上的交換空間,以避免在磁碟上進行分頁,從而提高效能。由於 zram 可以用記憶體替代硬碟為系統提供交換空間的功能,zram 可以讓 Linux 在需要大量 RAM 的情況下在記憶體上進行交換/分頁,而提高記憶體的使用率,顯著得減少系統啟動時(此時 Linux 還不能使用外部儲存)對記憶體大小的要求。在實體記憶體較少的舊電腦上,尤其如此。

Lubuntu (13.10 開始) 以及 Chrome OS 預設都有啟用這項功能
所以就來安裝 zram-config,沒想到竟然失敗 …

錯誤訊息大概是這樣:

testuser@ubuntu:~$ sudo apt-get install zram-config
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
zram-config
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/3,078 B of archives.
After this operation, 42.0 kB of additional disk space will be used.
Selecting previously unselected package zram-config.
(Reading database ... 107939 files and directories currently installed.)
Unpacking zram-config (from .../zram-config_0.1_all.deb) ...
Processing triggers for ureadahead ...
Setting up zram-config (0.1) ...
start: Job failed to start
invoke-rc.d: initscript zram-config, action "start" failed.
dpkg: error processing zram-config (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
zram-config
E: Sub-process /usr/bin/dpkg returned an error code (1)
閱讀全文