2012/03/02

CPU fan on Lenovo Thinkpad T420

Content:

Debian 8


While the fan behaves reasonably under Debian 8, I wanted to increase its usage as I often run short but CPU consuming processes. Thinkfan, originally created to solve the problem of unnecessary  high fan consumption (see the section below about Ubuntu). It provides an easy way in general to control the fan level for given temperature ranges.

Configuration

Install the packages
# apt-get install thinkfan lm-sensors

I encountered an error during installation, which is a known bug. This happens because it tries to load the service before it is properly configured. This error does not prevent the following steps for a proper configuration.
Setting up thinkfan (0.9.2-1) ... Job for thinkfan.service failed. See 'systemctl status thinkfan.service' and 'journalctl -xn' for details. invoke-rc.d: initscript thinkfan, action "start" failed. dpkg: error processing package thinkfan (--configure): subprocess installed post-installation script returned error exit status 1 Errors were encountered while processing: thinkfan E: Sub-process /usr/bin/dpkg returned an error code (1)

Scan the system (answer all the default options)
# sensors-detect

Search for thermal sensors
$ find /sys/devices -type f -name "temp*_input"

My output looks like:
/sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/hwmon/hwmon3/temp1_input
/sys/devices/virtual/hwmon/hwmon0/temp1_input
/sys/devices/platform/coretemp.0/hwmon/hwmon2/temp3_input
/sys/devices/platform/coretemp.0/hwmon/hwmon2/temp1_input
/sys/devices/platform/coretemp.0/hwmon/hwmon2/temp2_input

Add the devices to the file
/etc/thinkfan.conf 
appending 'hwmon' to each line (in my case I excluded the first line of the previous output), so that the file would look something like this:
hwmon /sys/devices/virtual/hwmon/hwmon0/temp1_input
hwmon /sys/devices/platform/coretemp.0/hwmon/hwmon2/temp3_input
hwmon /sys/devices/platform/coretemp.0/hwmon/hwmon2/temp1_input
hwmon /sys/devices/platform/coretemp.0/hwmon/hwmon2/temp2_input

(0,    0,    55)
(1,    48,    60)
(2,    50,    61)
(3,    52,    63)
(4,    56,    65)
(5,    59,    66)
(7,    63,    32767)

The numbers correspond to:
(LEVEL, LOW, HIGH)
LEVEL is the fan level to use (0-7 with thinkpad_acpi)
LOW is the temperature at which to step down to the previous level
HIGH is the temperature at which to step up to the next level
All numbers are integers.

For more informations see the comments in the template configuration file
/usr/share/doc/thinkfan/examples/thinkfan.conf.simple

Enable the service

Enable the kernel module:
# modprobe thinkpad_acpi fan_control=1

Now that the module parameter fan_control=1 has been given to thinkpad-acpi, the fan levels can be set manually, e.g.:
echo level 4 | sudo tee /proc/acpi/ibm/fan
where the level can be set to an integer between 0 (no fan) 7 (high fan level). Note that level 7 (about 4500 rpm) does not correspond to the maximum speed reachable by the fan. It is possible to increase further the fan usage manually by setting the level to 'disengaged' (about 5500rpm)
echo level disengaged | sudo tee /proc/acpi/ibm/fan
and return back to automatic mode as
echo level auto | sudo tee /proc/acpi/ibm/fan
It is however preferable and more safe to start an automatic service, such as thinkfan, to control the fan level given certain temperature ranges.

Start the thinkfan service:
# systemctl start thinkfan.service

In no error appears, the service should be enabled. The following should inform you that thinkfan is active
$ systemctl status thinkfan.service

You can also check the fan level
$ cat /proc/acpi/ibm/fan
status:        enabled
speed:        1985
level:        1
commands:    level ( is 0-7, auto, disengaged, full-speed)
commands:    enable, disable
commands:    watchdog ( is 0 (off), 1-120 (seconds))

where ' level' is set between 0-7. If instead of being set to a number it is set to 'auto', then probably thinkfan is not active.
or using the command
$ sensors

Finally, load the module at boot:
# echo "options thinkpad_acpi fan_control=1" | sudo tee /etc/modprobe.d/thinkpad_acpi.conf
and enable the service at boot
# systemctl enable thinkfan.service

Avoid overheating

The temperature can still rise significantly (> 90C) when intense CPU usage is required. First, you may want to clean the heat sink. If it does not help, or if to clean the fan you wish anyway to disassemble the machine, it is probably required also the replacement of the thermal paste. Check your hardware maintenance manual to see how to disassemble the heatsink. Other unofficial sources (e.g. videos) may also be useful, but the official manual should be consulted, since this is a potentially dangerous procedure (even if easy).

Apart from mechanical solutions, it is also possible to force a reduced CPU usage. E.g., it may be required that CPUs are loaded only up to 80% of their capacities:
# echo 80 > /sys/devices/system/cpu/intel_pstate/max_perf_pct
A systemd script to set automatically the CPU levels at boot can be downloaded from here. Of course, this is not the optimal long term fix, but it is not invasive and requires no purchase.


Ubuntu 11.10

DISCLAIMER: while we keep this section for reference, we strongly discourage usage of Ubuntu, in particular those versions released between year 2012 and 2016 implementing spyware.

After installing Ubuntu 11.10 on a Lenovo Thinkpad T420, the fan always run too much, even if there is a minimal CPU usage. The solution is installing the package thinkfan, and care attention to wisely configure the fan options.

These steps solve the problem:

1. Install thinkfan package:

$ sudo apt-get install thinkfan

2. Add kernel module ‘coretemp’ to /etc/modules

$ sudo sh -c ‘echo coretemp >> /etc/modules’

3. Load kernel module ‘coretemp’

$ sudo modprobe coretemp

4. Add the following three sensor entries to /etc/thinkfan.conf just before the temperature levels:

sensor /sys/devices/platform/coretemp.0/temp1_input
sensor /sys/devices/platform/coretemp.0/temp2_input
sensor /sys/devices/platform/coretemp.0/temp3_input
sensor /sys/devices/virtual/hwmon/hwmon0/temp1_input


5. Add the following to /etc/modprobe.d/thinkfan.conf: ‘options thinkpad_acpi fan_control=1′

$ sudo sh -c ‘echo “options thinkpad_acpi fan_control=1″ >> /etc/modprobe.d/thinkfan.conf’

6. Reload kernel module ‘thinkpad_acpi’

$ sudo modprobe -r thinkpad_acpi
$ sudo modprobe thinkpad_acpi

7. Set START=”yes” in /etc/default/thinkfan

8. Start thinkfan:

$ sudo /etc/init.d/thinkfan start

9. Check whether it works

$ sudo cat /proc/acpi/ibm/fan

if level has a value between 0 and 7, and changes by times, your thinkfan daemon works.

10. Add thinkfan to startup applications.

Ref: Putokaz, Debian forum and mailing list, thinkwiki, stackexchange

Gnuplot

Basic code to print plots, also using symbols like greek letters:

set term post color eps enh
set output "plot.eps"
set title "{/Symbol abcdefghijklmnopqrstuvwxyz \245}"


See also this page and, in particular, this script.

2011/03/28

PDF editor

DISCLAIMER: while we keep this section for reference, we strongly discourage the use of proprietary software, since it violates fundamental user freedoms.
 
List of PDF editor software under linux:
  • Foxit Phantom PDF, the best choice with Ubuntu 11.10. Versions Suite 2.2.4 and Business Edition 5.0.1 have been reported to work very well with WINE.
  • Xournal, the best choice in my opinion. It turns the PDF file into an image that can be annotated. Then, the file can be exported as PDF;
  • PDFEdit, highly unstable;
  • Okular is the only tool that actually has a real annotation tool for PDFs. However, the annotations are not saved withing the PDF, but written separately. This makes them unusable for any other reader;
  • PDF-XChange Viewer via WINE. Under Fedora 12 it did not work. It works with Ubuntu 11.04 (natty), PDF-XChange Viewer v.2.50.193 and Wine 1.2.

Ref: gnurou, linux.aldeby.org.

2009/12/29

VirtualBox

Installation

The virtualbox-ose package in the official repositories does not support USB peripherals. Hence one can install the non-ose version downloading the deb package from official site, or adding a non-official repository in /etc/apt/sources.list:

# VirtualBox
deb http://download.virtualbox.org/virtualbox/debian jaunty non-free


The authentication key is

wget -q http://download.virtualbox.org/virtualbox/debian/sun_vbox.asc -O- | sudo apt-key add -


and than the package list must be updated.

sudo aptitude update


and the package can be installed

sudo aptitude install virtualbox-3.1



After the insallation

We need to add the user to the vboxusers group:

sudo adduser $LOGNAME vboxusers


sudo -u $USER -s


Than we can enable the usb support:

echo "none /proc/bus/usb usbfs devgid=$(grep plugdev /etc/group | sed 's/plugdev:x:\(.*\):.*/\1/'),devmode=664 0 0" | sudo tee -a /etc/fstab


mount the usb devices

sudo mount /proc/bus/usb


and recompiling the module

sudo /etc/init.d/vboxdrv setup





Ref: Ubuntu Wiki.

2009/08/02

GMPlayer - Errore nella scelta del dispositivo video

Se GMPlayer dà l'errore

Error opening/initializing the selected video_out (-vo) device.

bisogna modificare nel file

~/.mplayer/gui.conf

la riga che riguarda il dispositivo video impostando

vo_driver = "x11"


Ref: ubuntuforums

2009/04/05

Azureus Vuze

N.B. Per le distribuzioni debian la procedura sotto riportata non è più necessaria, basta installare il pacchetto vuze.

Installazione

Installare java

sudo aptitude install sun-java6-jre

Scaricare Azureus Vuze dal suo sito ed estrarre l'archivio di Azureus in /opt:

cd ~/Scrivania (se il file è stato scaricato in ~/Scrivania)
sudo tar xfvj Vuze_Installer.tar.bz2 -C /opt/

e modificare i permessi della directory

sudo chown -R utente:utente /opt/vuze/

dove al posto di utente va il nome dell'utente.

Ottimizzazione condivisione

Una volta aperto Vuze, cliccare su Advanced, andare su Strumenti e quindi Opzioni. Nella scheda Code impostare a 2 download massimi simultanei e massimo numero di torrent attivi.

Protocollo offuscamento

Nella scheda Connessioni, Cifratura di Strumenti → Opzioni, selezionare Richiedi il trasferimento codificato
e Autorizza le connessioni in uscita.

2009/03/14

Creative webcams on Debian and Ubuntu

DISCLAIMER: while we keep this post for reference, we strongly discourage the use of proprietary software, since it violates fundamental user freedoms.


Contents of the post:
  1. Creative Live! Cam Vista IM and Skype (Ubuntu 10.10+)
  2. Creative Live! Cam Vista IM (Debian Lenny e Ubuntu)
  3. Creative WebCam Live! (Ubuntu 8.10)

Creative Live! Cam Vista IM and Skype (Ubuntu 10.10+)

In order to make the webcam also compatible with Skype, one needs to install the gspca driver and libv4l.

Installing needed packages:
sudo aptitude install mercurial build-essential linux-headers libncurses5-dev
Retrieving sources (from Douglas Schilling Landgraf V4L/DVB backports repository):
hg clone http://linuxtv.org/hg/v4l-dvb/
Copy the configuration file:
cd v4l-dvb
sudo cp /boot/config-`uname -r` v4l/.config

Note: currently FireDTV drivers do not compile easily (you need all the kernel sources) and are rarely used, we will disable them in the configuration.
Launch configuration:
sudo make menuconfig
Disable FireDTV support (Multimedia Support -> DVB/ATSC adapters -> set the option blank on FireDTV and FloppyDTV):
Capture-4
Capture-5
Capture-6
Exit, Exit.
Now let’s take care of usb webcams (Multimedia Support -> Video Capture adapters -> V4L USB devices)
Activate new modules drivers (press M on those marked NEW), in gspca for example:
Capture-4
Capture-7
Capture-8
Capture-9
Capture-10
Once the new drivers are enabled (M for module instead of a space), we can leave. Exit, Exit, etc… and save:
Capture-11
Launch the compilation:
make
sudo make install
If everything ok go to the next step, because the drivers also require the latest versions of libv4l.
For karmic it’s easy:
sudo add-apt-repository ppa:libv4l
Get the latest version if necessary:
sudo aptitude update
sudo aptitude full-upgrade


In order to load skype with the new drivers:

cd /usr/bin
sudo mv skype skype.real
gksudo gedit skype
add the following lines

#!/bin/sh
LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so /usr/bin/skype.real "$@"
and make exxecutable the file

sudo chmod +x skype
Restart and enjoy your new drivers.

Ref: Le bazar de Stemp, Ispirazioni Informatiche .

Older versions

N.B. Con i kernel 2.6.27.xx le procedure sotto riportate falliscono. Esse si riferiscono ai kernel 2.6.24.xx.


Creative Live! Cam Vista IM (Debian Lenny e Ubuntu)

Scaricare il driver ov51x-jpeg (ad esempio tramite subversion)

sudo aptitude install subversion
mkdir webcam-driver
svn co svn://rastageeks.org/svn/ov51x-jpeg/trunk webcam-driver

compilare

cd webcam-driver
sudo aptitude install linux-headers-`uname -r`
make
sudo make install
sudo modprobe ov51x-jpeg

installare il modulo del pacchetto

sudo aptitude update
sudo aptitude install ov51x-jpeg-source module-assistant
module-assistant a-i ov51x-jpeg

Per utilizzare la webcam con skype (versione 2.0.0.72) è necessario forzare un parametro all'avvio, inserendo nel file /etc/modprobe.d/options la seguente riga

options ov51x-jpeg forceblock=1

Nel caso di Ubuntu 8.04 o 9.04 è inltre necessario installare libv4l

sudo aptitude install libv4l-0


e lanciare skype con il comando

LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so skype

Conviene quindi rinominare l'eseguibile

sudo mv /usr/bin/skype /usr/bin/skype.real

e creare un file

sudo nano /usr/bin/skype

inserendo la riga

LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so /usr/bin/skype.real

e renderlo eseguibile

sudo chmod 775 /usr/bin/skype



Ref: ubuntu forums, rastageeks, fireteam.


Creative WebCam Live! (Ubuntu 8.10)

La Creative WebCam Live! viene riconosciuta da ubuntu 8.10 e funziona correttamente con alcuni programmi come Cheese, ma skype 2.0.0.72 , pur riconoscendola, mostra una schermata verde invece del video.
E' quindi necessario installare il pacchetto libv4l (o lib32v4l per la versione amd64)

sudo aptitude install libv4l

rimuovere skype se già installato

sudo aptitude purge skype

e installare i repository Medibuntu

sudo wget http://www.medibuntu.org/sources.list.d/intrepid.list --output-document=/etc/apt/sources.list.d/medibuntu.list

aggiungendo anche la chiave GPG

sudo apt-get update && sudo apt-get install medibuntu-keyring && sudo apt-get update

e quindi reinstallare skype da questo repository

sudo aptitude install skype


Ref: Ispirazioni Informatiche.