I have strange problem with charging my phone (Xperia S) over USB on my Lenovo X220. I use Kubuntu 13.04 at this time. When I connect my phone to the computer, the charging icon on my phone blinks for just a second and then the phone stops being charged.
But the phone is connected and data can be moved between phone and computer.
Now I finally got a solution to this problem. I use TLP - Linux Advanced Power Management on my X220 to tune battery performance.
The problem is in USB autosuspend is applied to the connected phone and that's why it is not charging.
We will blacklist the phone to NOT use the USB autosuspend feature:
$ lsusb
Bus 001 Device 009: ID 0fce:0169 Sony Ericsson Mobile Communications AB
Now write down te USB ID of your device (0fce:0169 in my case).
Now open the TLP configuration
$ sudo nano /etc/default/tlp
and find the USB_BLACKLIST directive, uncomment it and change it to
USB_BLACKLIST="0fce:0169"
(use your USB ID in the directive)
and save the file.
And now just start TLP again
$ sudo tlp start
Now the phone is charging again.
Why not?
Beware false idols ...
Apr 9, 2013
Mar 29, 2012
How to enlarge a VirtualBox disk with Windows XP guest in Kubuntu 12.04
After years of using my VirtualBox instance of Windows XP in my laptop I realized there is not enough space on the disk.
So I decided to enlarge it.
Create a new vdi in ~/.VirtualBox/VDI by running:
where size is in MB, in this example 15000MB ~= 15GB, and new.vdi is name of new hard drive to be created.
Next the old vdi needs to be cloned to the new vdi, this may take some time so wait while it occurs:
Detach old harddrive and attach new hard drive, replace VMName with whatever you called your VM:
Boot the VM, run Partition Wizard to resize the partition on the fly, and reboot.
Remove old vdi from VirtualBox and delete it:
So I decided to enlarge it.
Create a new vdi in ~/.VirtualBox/VDI by running:
$ cd ~/.VirtualBox/VDI $ VBoxManage createhd -filename new.vdi --size 15000 --remember
where size is in MB, in this example 15000MB ~= 15GB, and new.vdi is name of new hard drive to be created.
Next the old vdi needs to be cloned to the new vdi, this may take some time so wait while it occurs:
$ VBoxManage clonehd old.vdi new.vdi --existing
Detach old harddrive and attach new hard drive, replace VMName with whatever you called your VM:
$ VBoxManage modifyvm VMName --hda none $ VBoxManage modifyvm VMName --hda new.vdi
Boot the VM, run Partition Wizard to resize the partition on the fly, and reboot.
Remove old vdi from VirtualBox and delete it:
$ VBoxManage closemedium disk old.vdi $ rm old.vdi
Resources:
https://wiki.archlinux.org/index.php/VirtualBox_%28%C4%8Cesky%29#Increase_the_size_of_a_virtual_hard_drive_for_a_Windows_guest
Mar 21, 2012
Laptop, SSD, tmpfs and Sendmail
After my previous post about setting up Apache with tmpfs I realized I also need to start Sendmail. So let's use similar method:
Create a file:
with this content:
Let's make this file executable:
And set it to start and stop before sendmail service when booting or halting the computer:
Create a file:
$ sudo nano /etc/init.d/sendmail-tmpfs
with this content:
#!/bin/bash
#
### BEGIN INIT INFO
# Provides: sendmail-tmpfs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Required-Start:
# Required-Stop:
# Short-Description: Create /var/spool/mqueue and /var/log/mqueue-client on tmpfs at startup
# Description: Create directory structure needed by Sendmail.
### END INIT INFO
#
# main()
#
case "${1:-''}" in
'start')
# create needed directory structure for sendmail
mkdir /var/spool/mqueue
mkdir /var/spool/mqueue-client
chmod 777 /var/spool/mqueue
chmod 777 /var/spool/mqueue-client
;;
'stop')
;;
'restart')
;;
'reload'|'force-reload')
;;
'status')
;;
*)
echo "Usage: $SELF start"
exit 1
;;
esac
#
### BEGIN INIT INFO
# Provides: sendmail-tmpfs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Required-Start:
# Required-Stop:
# Short-Description: Create /var/spool/mqueue and /var/log/mqueue-client on tmpfs at startup
# Description: Create directory structure needed by Sendmail.
### END INIT INFO
#
# main()
#
case "${1:-''}" in
'start')
# create needed directory structure for sendmail
mkdir /var/spool/mqueue
mkdir /var/spool/mqueue-client
chmod 777 /var/spool/mqueue
chmod 777 /var/spool/mqueue-client
;;
'stop')
;;
'restart')
;;
'reload'|'force-reload')
;;
'status')
;;
*)
echo "Usage: $SELF start"
exit 1
;;
esac
Let's make this file executable:
$ sudo chmod 0755 /etc/init.d/sendmail-tmpfs
And set it to start and stop before sendmail service when booting or halting the computer:
$ sudo update-rc.d sendmail-tmpfs defaults 20 20
Mar 14, 2012
Laptop, SSD, tmpfs and Apache
When you have SSD disk in your laptop, you probably use tmpfs for /var/log. There is usually no need to store logs between restarts. The number of writes to the disk is much lower with tmpfs. It means the SSD disk lasts longer ;-).
The problem with tmpfs is Apache won't start without /var/log/apache2 directory created. We have to create it before the apache2 service will start.
So let's create a file:
with this content:
Let's make this file executable:
And set it to start and stop before apache2 service when booting or halting the computer:
References:
http://bernaerts.dyndns.org/linux/50-compactflash-tune-apache
The problem with tmpfs is Apache won't start without /var/log/apache2 directory created. We have to create it before the apache2 service will start.
So let's create a file:
$ sudo nano /etc/init.d/apache2-tmpfs
with this content:
#!/bin/bash
#
### BEGIN INIT INFO
# Provides: apache2-tmpfs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Required-Start:
# Required-Stop:
# Short-Description: Create /var/log/apache2/error.log on tmpfs at startup
# Description: Create /var/log/apache2/error.log needed by Apache.
### END INIT INFO
#
# main()
#
case "${1:-''}" in
'start')
# create the /var/log/apache2/error.log needed by apache
mkdir /var/log/apache2
chmod 777 /var/log/apache2
touch /var/log/apache2/error.log
chmod 777 /var/log/apache2/error.log
;;
'stop')
;;
'restart')
;;
'reload'|'force-reload')
;;
'status')
;;
*)
echo "Usage: $SELF start"
exit 1
;;
esac
#
### BEGIN INIT INFO
# Provides: apache2-tmpfs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Required-Start:
# Required-Stop:
# Short-Description: Create /var/log/apache2/error.log on tmpfs at startup
# Description: Create /var/log/apache2/error.log needed by Apache.
### END INIT INFO
#
# main()
#
case "${1:-''}" in
'start')
# create the /var/log/apache2/error.log needed by apache
mkdir /var/log/apache2
chmod 777 /var/log/apache2
touch /var/log/apache2/error.log
chmod 777 /var/log/apache2/error.log
;;
'stop')
;;
'restart')
;;
'reload'|'force-reload')
;;
'status')
;;
*)
echo "Usage: $SELF start"
exit 1
;;
esac
Let's make this file executable:
$ sudo chmod 0755 /etc/init.d/apache2-tmpfs
And set it to start and stop before apache2 service when booting or halting the computer:
$ sudo update-rc.d apache2-tmpfs defaults 90 10
Mar 1, 2012
Transmission's web GUI is not accessible anymore
I have installed a transmission daemon on my home server. I have used to use it through integrated web GUI. After upgrading my server (from Ubuntu 11.04 Natty Narwhal to Ubuntu 11.10 Oneiric Ocelot) the web GUI was not accessible anymore. Only thing I got was this error:
409: Conflict
Your request had an invalid session-id header.
To fix this, follow these steps:
When reading a response, get its X-Transmission-Session-Id header and remember it
Add the updated header to your outgoing requests
When you get this 409 error message, resend your request with the updated header
This requirement has been added to help prevent CSRF attacks.
X-Transmission-Session-Id: CBcYiodnQIHKYkhr9EceZOMW3ICgMSgt6j2FTCOXbcunA1tK
After hours of searching the solution a decided to use transmission from natty repository. So I did:
$ wget http://security.ubuntu.com/ubuntu/pool/main/t/transmission/transmission-common_2.13-0ubuntu8_all.deb
$ wget http://security.ubuntu.com/ubuntu/pool/universe/t/transmission/transmission-cli_2.13-0ubuntu8_amd64.deb
$ wget http://security.ubuntu.com/ubuntu/pool/universe/t/transmission/transmission-daemon_2.13-0ubuntu8_amd64.deb
$ wget http://security.ubuntu.com/ubuntu/pool/universe/t/transmission/transmission_2.13-0ubuntu8_all.deb
Then install the downloaded files:
$ sudo dpkg -i transmission*.deb
And repair broken dependencies:
$ sudo apt-get install -f
Now the transmission web GUI works again.
Feb 22, 2012
Kubuntu 12.04 - computer won't power off
I've had a strange problem when powering off my home computer. It has never powered off. The blue screen with Kubuntu logo appeared and then it hung. I had to long press power off button to complete the shutdown. It was very uncomfortable.
Even stranger thing is that when I want to restart the computer it has restarted always without any problem.
Today I finally find out a solution:
Edit the kdmrc file:
Change one line in section [Shutdown]. It looked like this:
So I changed it to:
[Shutdown]
BootManager=None
HaltCmd=/sbin/shutdown -P now
RebootCmd=/sbin/reboot
Now logout from KDE. Switch to console with Ctrl+Alt+F1 and restart the kdm:
After login to KDE again, perform the shutdown. Now it works again!
Even stranger thing is that when I want to restart the computer it has restarted always without any problem.
Today I finally find out a solution:
Edit the kdmrc file:
$ sudo nano /etc/kde4/kdm/kdmrc
Change one line in section [Shutdown]. It looked like this:
[Shutdown]
BootManager=None
HaltCmd=/sbin/halt
RebootCmd=/sbin/reboot
BootManager=None
HaltCmd=/sbin/halt
RebootCmd=/sbin/reboot
So I changed it to:
[Shutdown]
BootManager=None
HaltCmd=/sbin/shutdown -P now
RebootCmd=/sbin/reboot
Now logout from KDE. Switch to console with Ctrl+Alt+F1 and restart the kdm:
$ sudo /etc/init.d/kdm stop
$ sudo /etc/init.d/kdm start
After login to KDE again, perform the shutdown. Now it works again!
Feb 17, 2012
Kubuntu 12.04: Waking up Lenovo X220 w/ or w/o multiple monitor connected
I use my Lenovo X220 laptop in two modes:
1. In the docking station with monitor connected
2. Without the docking station just with the display
I had problems with this setup when suspending / waking up in Kubuntu 12.04. When I suspend without docking station connected and wake up without docking station connected, everything goes well. But when I wake up in the docking station it has problems with recognizing the monitor. All I can do is to restart the Xserver. It means it is useless to suspend.
So I wrote the script to detect whether the laptop is in docking station or not while it is wakeing up.
Create new file:
With this content:
#!/bin/bash
. /usr/lib/pm-utils/functions
case "$1" in
hibernate|suspend)
;;
thaw|resume)
export DISPLAY=:0
export XAUTHORITY=/home/<username>/.Xauthority
xrandr --auto
if xrandr | grep -q -e "HDMI2 connected"; then
xrandr --output LVDS1 --off
xrandr --output HDMI2 --auto --primary
else
xrandr --output HDMI2 --off
xrandr --output LVDS1 --auto --primary
fi
;;
*)
;;
esac
exit
Than save it and set it executable:
And that's it. Waking up behaves well ;-)
1. In the docking station with monitor connected
2. Without the docking station just with the display
I had problems with this setup when suspending / waking up in Kubuntu 12.04. When I suspend without docking station connected and wake up without docking station connected, everything goes well. But when I wake up in the docking station it has problems with recognizing the monitor. All I can do is to restart the Xserver. It means it is useless to suspend.
So I wrote the script to detect whether the laptop is in docking station or not while it is wakeing up.
Create new file:
$ sudo nano /etc/pm/sleep.d/90_switch_display
With this content:
. /usr/lib/pm-utils/functions
case "$1" in
hibernate|suspend)
;;
thaw|resume)
export DISPLAY=:0
export XAUTHORITY=/home/<username>/.Xauthority
xrandr --auto
if xrandr | grep -q -e "HDMI2 connected"; then
xrandr --output LVDS1 --off
xrandr --output HDMI2 --auto --primary
else
xrandr --output HDMI2 --off
xrandr --output LVDS1 --auto --primary
fi
;;
*)
;;
esac
exit
Than save it and set it executable:
$ sudo chmod 755 /etc/pm/sleep.d/90_switch_display
And that's it. Waking up behaves well ;-)
Subscribe to:
Posts (Atom)