AMD Lenovo laptop hangs when using battery

I have a laptop that ironically, most of the time is connected to power outlet. Recently I started using its battery and noticed when in battery its performance was very poor.

Journal shows the following message:

oct 11 07:08:55 legion /usr/libexec/gdm-x-session[3458]: (II) event5 – MSFT0001:00 06CB:CE2D Touchpad: SYN_DROPPED event – some input events have been lost.

In summary hardware cursor was giving problems, so I enabled software cursor creating the file /etc/X11/xorg.conf.d/20-amdgpu.conf and restarting:

Section “OutputClass”
Identifier “AMD”
MatchDriver “amdgpu”
Driver “amdgpu”
Option “SWCursor” “True”
EndSection

Assigning the priority of services during the boot process

Linux provides the following choices for Process Scheduling:

  • SCHED_FIFO: Static Priority scheduling
  • SCHED_RR: round-robin variant of the SCHED_FIFO
  • SCHED_OTHER: default scheduling policy which uses the Completely Fair Scheduler (CFS)
  • SCHED_BATCH: for “batch” style execution of processes
  • SCHED_IDLE: for running very low priority background jobs

Usually to check and assign policies we use the chrt command, for example:

Checking Current policy of PID 1012:

# chrt -p 1012
pid 1012's current scheduling policy: SCHED_OTHER
pid 1012's current scheduling priority: 0

Assigning Policy FIFO with priority 50 to PID 1012:

#chrt -fifo -p 50 1-12 # chrt -p 1012
pid 1012's current scheduling policy: SCHED_FIFO
pid 1012's current scheduling priority: 50

 

But if we want a service to always have the same Scheduling policy, we may modify systemd service file as follows:

[Service]
....
CPUSchedulingPolicy=fifo
CPUSchedulingPriority=50

Then reloading daemon  (systemctl daemon-reload) and restarting service will show our service with new scheduling.

 

Redefining CFLAGS in Makefile

I am used to the old way of defining CFLAGS in the console when needed but recently in Debian exporting CFLAGS didn’t have the desired effect.

So In case CFLAGS variable for command line and even in makefile doesn’t work for you, this will make the trick in Makefile:

EXTRA_CFLAGS += foo bar baz

Squid 3.3 in Raspbian Wheezy

I have been playing recently with Squid and “Splash pages”, but this function works fine on Squid 3.2 and later; however Raspbian only offers Squid 3.1.

I looked for a ready to install 3.2+ version in the Webz but didn’t find one, so I backported the Debian Jessie version.

For the lazy ones, here are the links (try them at your own):

libecap2 (This dependency is not available in Wheezy)

libecap2_0.2.0-1_armhf.deb

libecap2-dev_0.2.0-1_armhf.deb

Then install squid3 (install according to your needs)

squid3_3.3.8-1.1_armhf.deb 

squid3-dbg_3.3.8-1.1_armhf.deb

squidclient_3.3.8-1.1_armhf.deb
squid3-common_3.3.8-1.1_all.deb

squid-cgi_3.3.8-1.1_armhf.deb

squid-purge_3.3.8-1.1_armhf.deb

 

Mounting a partition from a dd image

At some point, everybody may have done a dd image of a USB/SD stick, as the below example shows:

dd if=/dev/sdb of=foo.img 

But it is usual that at some point in time we would like to access the information inside the image, doing that is quite easy:

First,you should do a fdisk on the image:

fdisk -l foo.img

Disk foo.img: 7998 MB, 7998537728 bytes, 15622144 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0002fc6d

Device Boot      Start         End      Blocks   Id  System
foo.img1   *             15622143     7811071+   c  W95 FAT32 (LBA)

Then some maths are needed. The operators are the start of the partition and the sector size in bytes.  The operation is simply start * sector size in bytes.

In this particular case the operation is 1 * 512 = 512.

Now that we have the result, that we call the offset. In other words, 512 is the offset where the partition starts in this dd image.

So the command to mount the partition is:

mount -t vfat -o loop,ro,noexec,offset=512 foo.img /mnt/mountpoint

And then we can copy the information from the partition inside!

 

 

 

 

net-news/liferea-1.8.3 has improved its startup speed

For everybody out there complaining about liferea’s decreased performance in the 1.8.x releases, upstream has released 1.8.3 which uses sqlite 3 WAL journaling.

This basically improves the overall liferea’s performance, so if you are hating 1.8.x, please try the latest 1.8.3

Quick perl script to test smtp auth

#!perl

use warnings;
use strict;

use Net::SMTP;

my $smtpserver = 'xxx.yyy.zzz.www';
my $smtpuser   = 'foo@bar.com';
my $fromemail  = 'bleh@bar.com';

my $smtp = Net::SMTP->new($smtpserver, Timeout => 10, Debug => 1);
die "Could not connect to server!\n" unless $smtp;

  $smtp->auth ( 'user', 'secret' ) or die "Could not authenticate $!";
  $smtp->mail($smtpuser);
  $smtp->to('somebody@bar.com');
  $smtp->data();
  $smtp->datasend("To: somebody\@bar.com\n");
  $smtp->datasend("From: $fromemail\n");
  $smtp->datasend("\n");
  $smtp->datasend("Body message\n");
  $smtp->dataend();
  $smtp->quit;

 

Unmounting stale NFS mount points in Linux

Sometimes, a stale NFS mount point can be a real PITA, specially if you can’t mount the share somewhere else.

The following command line have helped me a lot lately:

umount -f -l /path/to/nfs/share

The first parameter forces umount, the second makes a “lazy umount”, detaching the filesystem and cleaning up all references.

Easy isn’t it?

Quick-n-Dirty duplicate mp3 finder script

René “Nepomusemo” Mayorga shared with me the following script to find out duplicate mp3 files in a specific directory:

find /media/music/ -not -empty -type f -printf “%s\n”  | sort -rn  | uniq -d  | xargs -I{} -n1 find /media/music/ -type f -size {}c -print0  | xargs -0 md5sum | sort | uniq -w32 –all-repeated=separate

This script might be used to find duplicate files, though

PHP: function.fopen : failed to open stream

Si en php al intentar utilizar fopen obtienen un resultado como:

Download Failed: Remote Server connection failed: fopen(http://jsitepoint.com/update/packages/joomla/update.xml) [function.fopen]: failed to open stream: no suitable wrapper could be found; Using Proxy: No(42)

La solución es editar php.ini modificando/agregando:

; Whether to allow the treatment of URLs (like http:// or ftp://) as files.
; http://php.net/allow-url-fopen
allow_url_fopen = On

Powered by WordPress with GimpStyle Theme design by Horacio Bella.
Entries and comments feeds. Valid XHTML and CSS.