Tuesday, June 8, 2010
Linux, Thinkpad, HDAPS: battery mode
ThinkPad laptops have a lot of amazing features. HDAPS is one of them. HDAPS stands for Hard Disk Active Protection System; it is intended to protect ThinkPad's HDD from damage in case of a notebook drop or other kind of impact while it is running.
But HDAPS doesn't work 'out of the box' on Linux by default. On my Debian too. But there is so indispensable website named ThinkWiki with the tons of information how to make Linux and ThinkPad friends forever. And there is a cool article how to enable HDD APS (http://www.thinkwiki.org/wiki/How_to_protect_the_harddisk_through_APS): just compile few modules and install a special daemon -- nothing difficult. And APS will begin to work. Every time.
But there are cases when there are no need in active HDD protection when laptop is running from AC but required when the battery mode. How to handle this? The answer is to use capabilities of pm-utils package -- it allows to make hooks on special events like 'Laptop is on battery more' or vice-versa. So here a little tip'n'trick.
1. Create an executable hdaps file in /etc/pm/power.d folder with the following contents:
3. Disable hdapsd daemon autorunning on system startup: # update-rc.d -f hdapsd remove
That's all! On Battery the script will load required HDAPS modules and run the daemon. Or will stop the daemon and unload the corresponding modules otherwise.
Tested and works well for my Debian Squeeze and Thinkpad T410.
But HDAPS doesn't work 'out of the box' on Linux by default. On my Debian too. But there is so indispensable website named ThinkWiki with the tons of information how to make Linux and ThinkPad friends forever. And there is a cool article how to enable HDD APS (http://www.thinkwiki.org/wiki/How_to_protect_the_harddisk_through_APS): just compile few modules and install a special daemon -- nothing difficult. And APS will begin to work. Every time.
But there are cases when there are no need in active HDD protection when laptop is running from AC but required when the battery mode. How to handle this? The answer is to use capabilities of pm-utils package -- it allows to make hooks on special events like 'Laptop is on battery more' or vice-versa. So here a little tip'n'trick.
1. Create an executable hdaps file in /etc/pm/power.d folder with the following contents:
#!/bin/sh
HDAPS_MODULES="thinkpad_ec tp_smapi hdaps"
HDAPSD_INIT_SCRIPT=/etc/init.d/hdapsd
MODPROBE=/sbin/modprobe
RMMOD=/sbin/rmmod
case "$1" in
### CASE: Work on battery
true)
echo "Enabling HDAPS"
for module in $HDAPS_MODULES; do
$MODPROBE $module
done
$HDAPSD_INIT_SCRIPT start
;;
### CASE: Work on AC-adapter
false)
echo "Disabling HDAPS"
$HDAPSD_INIT_SCRIPT stop
### NOTE: modules should be unloaded in the reverse order
for module in `echo $HDAPS_MODULES | tac -s' '`; do
$RMMOD $module
done
;;
esac
2. Disable hdaps modules autoloading from /etc/modules3. Disable hdapsd daemon autorunning on system startup: # update-rc.d -f hdapsd remove
That's all! On Battery the script will load required HDAPS modules and run the daemon. Or will stop the daemon and unload the corresponding modules otherwise.
Tested and works well for my Debian Squeeze and Thinkpad T410.
Wednesday, June 2, 2010
APT suggests to remove (autoremove) required packages
After another packages update (or after my attempts to remove Evolution out from the system, I do not know exactly) on my Debian Squeeze, APT began to suggest me to remove 'non-required' packages using 'autoremove' option like this:
The following packages were automatically installed and are no longer required: totem-common libempathy-gtk28 libaprutil1-ldap vinagre odbcinst seahorse-plugins libgeoclue0 xdg-user-dirs gnome-user-share libgalago3 libtelepathy-farsight0 gconf-defaults-service guile-1.8-libs unixodbc
...
Use 'apt-get autoremove' to remove them.
It'd be Ok if packages to remove were really non-required for my system. But they ain't! W/o them my Gnome desktop would be definitely broken. Seems that something went wrong with 'Depends' field of some package.
This had been annoying me until I found a solution:
# apt-get install <list-of-packages-suggested-to-remove>
All above-mentioned packages were installed automatically due 'Depends' field of some (name it 'primary') very important package. Hence APT believes that it's Ok to remove them out when the primary package is purged. By explicitly using 'apt-get install' we tell APT that these packages ain't automatically installed anymore but manually. Pretty easy, yeah?
Alternative ways
The following packages were automatically installed and are no longer required: totem-common libempathy-gtk28 libaprutil1-ldap vinagre odbcinst seahorse-plugins libgeoclue0 xdg-user-dirs gnome-user-share libgalago3 libtelepathy-farsight0 gconf-defaults-service guile-1.8-libs unixodbc
...
Use 'apt-get autoremove' to remove them.
It'd be Ok if packages to remove were really non-required for my system. But they ain't! W/o them my Gnome desktop would be definitely broken. Seems that something went wrong with 'Depends' field of some package.
This had been annoying me until I found a solution:
# apt-get install <list-of-packages-suggested-to-remove>
All above-mentioned packages were installed automatically due 'Depends' field of some (name it 'primary') very important package. Hence APT believes that it's Ok to remove them out when the primary package is purged. By explicitly using 'apt-get install' we tell APT that these packages ain't automatically installed anymore but manually. Pretty easy, yeah?
Alternative ways
- Use 'aptitude unmarkauto' to mark packages manually installed;
- Update /etc/apt/apt.conf with debug::pkgAutoRemove=false key to disable APT's autoremoving feature.
Enjoy.
Saturday, May 22, 2010
Twitter and my solution for Debian + Thinkpad issues
Having the latest Debian Squeeze (kernel 2.6.32) I got in some issues (hm... Seems that for some time I'm going to write about Debian and my Thinkpad only :)) with my laptop.
The common issues that I (and Google proves that not only my Thinkpad T410 run into them) had were:
Meanwhile there was an announce about Linux 2.6.34 kernel with the fix of famous bug #12309...
So I decided to try it out but unfortunately there were (still are) no Debian packages with the latest kernel sources for Squeeze/Sid. Only vanilla kernel w/o corresponding Debian patches. But Debian Experimental already has it! So what we do:
After booting the new Debian kernel I got that those Thinkpad issues became resolved for me.
P.S. BTW, I finally decided to start my personal twitter. Sometimes I have a lot ideas and thoughts I want to share but they ain't so big or not so significant or even I do not have enough time to make standalone posts about them. Hence such 'dumps' are go to my twitter; I hope they are useful and interesting.
The common issues that I (and Google proves that not only my Thinkpad T410 run into them) had were:
- LCD brightness up/down doesn't work with loaded up ``thinkpad_acpi'' module; ``hotkeys'' module param does not help. Even ``acpi_listen'' does not show about corresponding events.
- On resume after suspend/hibernate USB goes to sleep or even become disabled;
- On resume after suspend/hibernate the system receives a kernel trace error with registers dump.
Meanwhile there was an announce about Linux 2.6.34 kernel with the fix of famous bug #12309...
So I decided to try it out but unfortunately there were (still are) no Debian packages with the latest kernel sources for Squeeze/Sid. Only vanilla kernel w/o corresponding Debian patches. But Debian Experimental already has it! So what we do:
- Download linux-kbuild-2.6.34 from http://ftp.de.debian.org/debian/pool/main/l/linux-kbuild-2.6/ and install it;
- Download linux-source-2.6.34 from http://ftp.de.debian.org/debian/pool/main/l/linux-2.6/ and install it;
- Go to /usr/src/ and extract .tar.gz with linux sources; then go to the newly created dir with the linux 2.6.34 sources;
- Copy current copy config (has a name like ``config-2.6.32-686'') from /boot as .config to the current directory;
- Build the kernel with 'make-kpkg' command as described in http://www.debian-administration.org/article/Building_your_own_v2.6.x_Kernel_in_the_Debian_manner.
You will be prompted to answer several questions about using new features (and devices support, of course) added to the new version of kernel. When this kind of survey is finished you can go to take some cups of coffee.
After booting the new Debian kernel I got that those Thinkpad issues became resolved for me.
P.S. BTW, I finally decided to start my personal twitter. Sometimes I have a lot ideas and thoughts I want to share but they ain't so big or not so significant or even I do not have enough time to make standalone posts about them. Hence such 'dumps' are go to my twitter; I hope they are useful and interesting.
Thursday, May 20, 2010
Debian Lenny + Thinkpad T410: network adapter issue
Since I chose Debian to be my primary and favorite Linux distribution on my new Lenovo Thinkpad T410, I agreed to myself to spend my time to solve various specific issues related to it.
So the first issue I met was that the Debian Lenny installation system didn't manage to find my Thinkpad's Intel 1000 ethernet adapter. Google 'said' that appropriate driver for the adapter was 'e1000e'. Manual 'e1000e' module loading (through 'modprobe' on another virtual console) didn't help: seems the driver is slight outdated and doesn't support newer Intel's network adapter.
The solution is simple: to use an alternative disk image made by Kenshi Muto to install Debian Lenny. This ISO can be downloaded from http://kmuto.jp/debian/d-i/.
Thankfully to the latest version of kernel, Debian installation system will detect Thinkpad's network adapter and the user will be able to continue installation from Internet not from CD/DVD only.
Or there is an alternative way: to compile the latest version of Intel's driver and load it from USB-stick during the installation.
So the first issue I met was that the Debian Lenny installation system didn't manage to find my Thinkpad's Intel 1000 ethernet adapter. Google 'said' that appropriate driver for the adapter was 'e1000e'. Manual 'e1000e' module loading (through 'modprobe' on another virtual console) didn't help: seems the driver is slight outdated and doesn't support newer Intel's network adapter.
The solution is simple: to use an alternative disk image made by Kenshi Muto to install Debian Lenny. This ISO can be downloaded from http://kmuto.jp/debian/d-i/.
Thankfully to the latest version of kernel, Debian installation system will detect Thinkpad's network adapter and the user will be able to continue installation from Internet not from CD/DVD only.
Or there is an alternative way: to compile the latest version of Intel's driver and load it from USB-stick during the installation.
Thursday, May 6, 2010
My new laptop: Lenovo Thinkpad
Today I bought my first Thinkpad -- Thinkpad T410. I know that since 'Thinkpad' trademark was bought out from IBM by Lenovo many people believe that they lost their legendary advantages. I think so also. A bit :). Anyway I still like them and their spirit.
Buying Thinkpads in Russia has its own unique peculiarities.
First one: you have to do your best to find a laptop w/ tech specs you like/need. You are able to find only 3-5 models of each series. But sometimes these models may not satisfy you and you have to choose from what they offer not from you like.
Second: there is no shipping directly from Lenovo using post/DHL. I believe that Russian post service is the worst in the World. And Lenovo (AFAIK) doesn't ship to Russia; USA/Europe only.
Third and not the coolest one: you should play kinda 'roulette' game; if you buy your laptop at an Internet shop and have not unboxed it on receiving, it's hard to return it back or to have a replace. If I didn't check today Thinkpad's keyboard I would get the problem called 'flex keyboard' (check out YouTube for it to get the idea of what it is).
Here is some positive. The one of shop assistants asked me what I'm gonna to install on my new laptop. When I told him that my choice is Linux, he became more energetic and the rest of the time of shopping we periodically were discussing Linux and Open Source. He was a newbie (2 years experience of playing around with Linux) but he is already fan of Open Solaris -- believes that it is a future of OS`s, fan of upcoming `btrfs' file system and XFCE as DE :). Believe me -- it is a rarity (at least it was before) for Russian shop assistants :).
Buying Thinkpads in Russia has its own unique peculiarities.
First one: you have to do your best to find a laptop w/ tech specs you like/need. You are able to find only 3-5 models of each series. But sometimes these models may not satisfy you and you have to choose from what they offer not from you like.
Second: there is no shipping directly from Lenovo using post/DHL. I believe that Russian post service is the worst in the World. And Lenovo (AFAIK) doesn't ship to Russia; USA/Europe only.
Third and not the coolest one: you should play kinda 'roulette' game; if you buy your laptop at an Internet shop and have not unboxed it on receiving, it's hard to return it back or to have a replace. If I didn't check today Thinkpad's keyboard I would get the problem called 'flex keyboard' (check out YouTube for it to get the idea of what it is).
Here is some positive. The one of shop assistants asked me what I'm gonna to install on my new laptop. When I told him that my choice is Linux, he became more energetic and the rest of the time of shopping we periodically were discussing Linux and Open Source. He was a newbie (2 years experience of playing around with Linux) but he is already fan of Open Solaris -- believes that it is a future of OS`s, fan of upcoming `btrfs' file system and XFCE as DE :). Believe me -- it is a rarity (at least it was before) for Russian shop assistants :).
Wednesday, April 28, 2010
'cp' command with a wget-like progress bar
Can not help re-posting: a tip and trick to make 'cp' command have a wget-like progress bar.
Source: http://chris-lamb.co.uk/2008/01/24/can-you-get-cp-to-give-a-progress-bar-like-wget/
I think that's amazing idea!
#!/bin/sh
cp_p()
{
strace -q -ewrite cp -- "${1}" "${2}" 2>&1 \
| awk '{
count += $NF
if (count % 10 == 0) {
percent = count / total_size * 100
printf "%3d%% [", percent
for (i=0;i<=percent;i++)
printf "="
printf ">"
for (i=percent;i<100;i++)
printf " "
printf "]\r"
}
}
END { print "" }' total_size=$(stat -c '%s' "${1}") count=0
}
% cp_p /mnt/raid/pub/iso/debian/debian-2.2r4potato-i386-netinst.iso /dev/null 76% [===========================================> ]
Source: http://chris-lamb.co.uk/2008/01/24/can-you-get-cp-to-give-a-progress-bar-like-wget/
I think that's amazing idea!
Tuesday, March 16, 2010
How to return back buttons layout in Ubuntu 10.04
Ubuntu wants to be more user-friendly than other Linux`es. It is the fact. Each new Ubuntu release always introduces a set of features which make user's life easy. But not all these features are cool. Is the fact too.
Upcoming Ubuntu 10.04 also introduces a Mac-like approach when window-control buttons (to minimize, to maximize and to close a window) are placed on the top-left side of the window, not on the top-right. Not everyone will definitely like it. Or not all GNOME (Metacity, if be more specific) themes will be look OK in this case. Anyway there should be a way to affect on window's button layout in Ubuntu.
So how to return it back?
(the screenshot from http://news.softpedia.com/news/Ubuntu-10-04-Drops-the-Human-Theme-for-a-Fresh-New-Look-136537.shtml)
The solution is simple, but not so obvious (as usual :)). After execution of the following command in a terminal window
gconftool-2 --set "/apps/metacity/general/button_layout" --type string ":minimize,maximize,close"
all buttons responsible for minimization, maximization and closing will be shown on the right side of the windows as it was before in the previous versions of Ubuntu. It is also a fact :).
Subscribe to:
Posts (Atom)

