Friday, December 21, 2012

Problem setting up HP LaserJet P1102 on Linux

If you have problem setting up driver for HP LaserJet P1102, it most probably because of Smart Install feature of the device. You can see it in dmesg output:


[353279.710023] usb 6-1: new high-speed USB device number 22 using ehci_hcd
[353279.824940] usb 6-1: New USB device found, idVendor=03f0, idProduct=002a
[353279.824944] usb 6-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[353279.824947] usb 6-1: Product: HP LaserJet Professional P1102
[353279.824950] usb 6-1: Manufacturer: Hewlett-Packard
[353279.824952] usb 6-1: SerialNumber: 000000000Q84CF03SI1c
[353279.826253] scsi16 : usb-storage 6-1:1.0
[353280.838094] scsi 16:0:0:0: CD-ROM            HP       Smart Install    1.0  PQ: 0 ANSI: 2
[353280.868209] sr1: scsi3-mmc drive: 0x/0x caddy
[353280.868365] sr 16:0:0:0: Attached scsi CD-ROM sr1
[353280.868452] sr 16:0:0:0: Attached scsi generic sg2 type 5

it is useful for Windows users as it will create a virtual cdrom drive in order to install the printer's driver. For Linux, this feature will prevent the setup utility to detect it as a USB printer as it sees it as a disk. The solution to this problem is by deactivating the feature using usb_modeswitch utility as below:


usb_modeswitch -m 4 -r 4 -v 0x03f0 -p 0x002a -M 55534243287E778400000000000006D0000000000000000000000000000000 -n

Please login as root before issuing the command.

The output is something like this:


Looking for default devices ...
   found matching product ID
   adding device
 Found device in default mode, class or configuration (1)
Accessing device 023 on bus 006 ...
Getting the current device configuration ...
 OK, got current device configuration (1)
Using first interface: 0x00
Using endpoints 0x04 (out) and 0x04 (in)
Not a storage device, skipping SCSI inquiry

USB description data (for identification)
-------------------------
Manufacturer: Hewlett-Packard
     Product: HP LaserJet Professional P1102
  Serial No.: 000000000Q84CF03SI1c
-------------------------
Looking for active driver ...
 No driver found. Either detached before or never attached
Setting up communication with interface 0
Using endpoint 0x04 for message sending ...
Trying to send message 1 to endpoint 0x04 ...
 Sending the message returned error -5. Trying to continue
Reading the response to message 1 (CSW) ...
 Response reading got error -5
 Device is gone, skipping any further commands
-> Run lsusb to note any changes. Bye.

(This output is after I ran the command once. You may see something like removing/deactivating the disk.) 

Then restart the printer or turn it off and on again. You should now run hp-setup utility to setup the printer and this time it can see the attached USB printer listed and you can select the printer to install the driver.

Hope this helps. Have fun!

Update: Whenever you restart your pc,  it can't connect to the printer. So this is not permanent solution. What you have to do is run the command of usb_modeswitch again and there you go. It will recognize the printer but this time you dont have to reinstall the driver. For permanent solution, from what I have read, I need to use Windows to run the printer's utility software but I never tried it before. if I have tried it, i will post it here.

Sunday, December 9, 2012

Postfix: smtp_address_preference

For mailserver/system  administrator :

If your mailserver has problem to connect to ipv6 address (especially if your mailserver doesn't support it) and throw errors something like this:

Dec 10 00:05:57 localhost postfix/smtp[16925]: connect to mta7.am0.yahoodns.net[2404:160:0:f:0:2:42c4:7621]:25: Network is unreachable
Dec 10 00:05:57 localhost postfix/smtp[16925]: connect to mta6.am0.yahoodns.net[2404:160:0:f:0:1:6288:d9ca]:25: Network is unreachable
Dec 10 00:05:57 localhost postfix/smtp[16925]: connect to mta7.am0.yahoodns.net[2404:160:0:f:0:2:42c4:7624]:25: Network is unreachable
Dec 10 00:05:57 localhost postfix/smtp[16925]: connect to mta6.am0.yahoodns.net[2404:160:0:f:0:1:43c3:a8e6]:25: Network is unreachable
Dec 10 00:05:57 localhost postfix/smtp[16925]: connect to mta6.am0.yahoodns.net[2404:160:0:f:0:1:42c4:7622]:25: Network is unreachable

then you may want to check the default smtp_address_preference parameter in main.cf. Most probably it is defaulted to ipv6 which is true on my postfix installation (Mageia). Change it to ipv4 to instruct postfix to look up MTA with ipv4 address only (which is I think supported by all major players like Yahoo!, Gmail and Hotmail for compatibility reason or they will lose lots of their customers) . So:

smtp_address_preference = ipv4

will save you before you consider to upgrade your infrastructure to ipv6. :-)

Have fun!

Sunday, September 9, 2012

Migrating and upgrading mailserver

I have new and powerful server for mail server. So now I am in the process of migrating my mail data and settings to the new server. But it is not as simple as copying a directory. It involves many things. Luckily some of them, you can just copy to the new server.

I am most concerned with the mail messages as they contain important messages for day-to-day operations and conversations. I will tell you more after the migration is complete.

cheers,

Tuesday, January 24, 2012

Perl: Terminal does not support AddHistory

If you see the error when running Perl shell, you need to install Term::ReadLine::Perl.




That's all there is to it. Have fun!.

changing manually wireless connection to be controlled by knetworkmanager

knetworkmanager is a Network Manager for KDE4. It is hated or liked by users and usually not in between. I personally like it although it has its fair share of bugs. But I like Mandriva's net_applet more. It is stable and more reliable. It is prefered by many Mandriva users. However, if you are stuck with recent problems (bug?) of perl in Mandriva Cooker like me, you are forced to use command line of wpa_supplicant or iwconfig or using gui application like knetworkmanager. 

In Mandriva, you can change which network manager control the wireless connection by changing the option in net_applet or you can manually change in file /etc/sysconfig/network-scripts/ifcfg-wlan0. If you want knetworkmanager in control of it, you just have to change this line to yes:


NM_CONTROLLED=yes


Sunday, January 22, 2012

Connecting to wireless AP with WPA/2 security using wpa_supplicant

Recently, my cooker updated perl packages and it broke all of drak* family especially drakconf and net_applet. net_applet is the network manager for Mandriva in applet form. I can also use draknetcenter. Now the problem is I cant open net_applet and knetcenter due to this error:
/usr/bin/perl: symbol lookup error: /usr/lib/libDrakX/auto/c/stuff/stuff.so: undefined symbol: Perl_Gthr_key_ptr
So how do I connect to wireless AP? I dont know how to use iwconfig to connect to such AP or can I? After googling, I found a solution: wpa_supplicant. In Mandriva, I just have to run this command (as root):
wpa_supplicant -Dwext -iwlan0 -c/etc/wpa_supplicant.conf &
If you have setup the connection before with draknetcenter, you dont have to edit the file wpa_supplicant.conf. If not, you have to manually edit the file to suit your environment. it is heavily documented. 

Then you have to run dhclient to get IP address from the AP or other dhcp server:
 dhclient wlan0

wlan0 is my wireless interface. Please change it according to your environment. I bet the broken packages will be updated sooner so that I can use net_applet again.

Have fun!

Monday, January 2, 2012

Happy New Year and distros for router

Happy New Year everbody. Hope 2012 will be a great year for Linux. In 2011, I tested several distros for different purposes. For routers, I found several free distros that serve as a really good gateway for my network. Among others are:

  1. Zentyal - this is the best distro for routers. Fully featured with webcache, url filtering, load balancing for multiple lines and has 32-bit and 64-bit version. It is based on Ubuntu.
  2. ClearOS - Also the best but it doesn't have 64-bit version (at the time of this writing. recently there's a 64-bit release but still in beta stage). Has many features as Zentyal. Based on Redhat.
  3. pfSense - this is not Linux-based. It is freeBSD-based firewall and router. It has bug with my servers pertaining to PCI-E. So I dumped it. It's good but the bug prevent it from being operational.
Others:
  • Untangle - didn't try it because the free version has no webcache feature.
  • Zeroshell - tried it but a little awkward to use.
So I chose Zentyal as my distro for my server router and info from its web, I need to add more RAM and bigger hard disk to serve more than 500 users.

Happy New Year everybody! Thanks for reading.

Monday, October 17, 2011

Changing konqueror web browser's engine to WebKit

Konqueror is a native KDE web browser and it uses KHTML as the rendering engine. Fortunately, the smart developers of Konqueror has made it possible to change not only the interface but also the engine that renders the webpage we visit and so far only webkit is supported. We hope many more in the future. or maybe not. :)

What is Webkit?
Webkit engine is derived from KDE's KHTML engine and contains many enhancements that made it better than its mother. It has been used for Apple's Safari and Google's Chrome web browsers.

For Mandriva 2011 users, to be able to change the engine to Webkit is by installing the engine package. It's called webkitkde. (for other distro, the package name might be a bit different) You might have installed it. Install it using this command:

urpmi webkitkde

Now open Konqueror (or restart if it is open) and go to Settings --> Configure Konqueror --> General --> Default web browser engine. You should have 2 options in there. KHTML and WebKit. Screenshot below.

*UPDATE:
For KDE 4.10.x, for Mageia, the package name is kwebkitpart. So,

urpmi kwebkitpart


That's all there is to it. You should now enjoy browsing the web using WebKit engine.

Tuesday, August 30, 2011

Mandriva 2011 codenamed Hydrogen is out

I just copy this as announced on Mandriva blog:

Hooray! As promised earlier, we are happy to announce that Mandriva 2011 is out. You can download ISO images from here.

When downloading an iso-image, perhaps you will want to read the Release Notes.

We prepared a small manual of how to upgrade to the new release for users of the Mandriva Desktop 2010.2.

If you have never tried Mandriva, take a look at the Mandriva 2011 Tour.

Happy upgrading :)


Monday, August 22, 2011

Merging video files

Recently I downloaded 2 video files which is actually a video file splitted into two for faster upload by the uploader. To merge them on Linux, we can use the command cat like this:

cat video1.mkv video2.mkv >> video.mkv

And it took seconds to complete merging. Now I can watch the video in 1 file.

Have fun!.

Sunday, June 19, 2011

Testing bloggeroid


This post is for testing purposes only. Please <<ignore>> it.

posted with Bloggeroid


Saturday, June 4, 2011

Mageia 1 is out!


A distribution forked from Mandriva, Mageia, released its important milestone, Mageia 1 stable. Read the Changelog here to get an insight of this release after 9 months it was born.


Thursday, May 26, 2011

My Mandriva desktop

Sorry for not posting anything for a rather long time. I have been using Mandriva Cooker 2011 for about 2 months now since I bought my new ASUS laptop from someone with half the current market price. :) With RPM5, ROSA, and many exciting features of KDE 4 in Cooker, I didn't want to miss the chance to test and have fun with them.

Here is the screenshots of my desktop with urpmi and 3D effects in action.


Please click on the image to see bigger picture.

Friday, April 8, 2011

Load balance 2 WAN links BASH script

BASH script to load balance 2 WAN links.

#!/bin/bash
#
# bal_local Load-balance internet connection over two local links
#
# Version: 1.0.0 - Fri, Sep 26, 2008
#
# Author: Niels Horn
#

# Set devices:
DEV1=${1-eth0} # default eth0
DEV2=${2-ppp0} # default ppp0

# Get IP addresses of our devices:
ip1=`ifconfig $DEV1 | grep inet | awk '{ print $2 }' | awk -F: '{ print $2 }'`
ip2=`ifconfig $DEV2 | grep inet | awk '{ print $2 }' | awk -F: '{ print $2 }'`

# Get default gateway for our devices:
gw1=`route -n | grep $DEV1 | grep '^0.0.0.0' | awk '{ print $2 }'`
gw2=`route -n | grep $DEV2 | grep '^0.0.0.0' | awk '{ print $2 }'`

echo "$DEV1: IP=$ip1 GW=$gw1"
echo "$DEV2: IP=$ip2 GW=$gw2"

### Definition of routes ###

# Check if tables exists, if not -> create them:
if [ -z "`cat /etc/iproute2/rt_tables | grep '^251'`" ] ; then
echo "251 rt_dev1" >> /etc/iproute2/rt_tables
fi
if [ -z "`cat /etc/iproute2/rt_tables | grep '^252'`" ] ; then
echo "252 rt_dev2" >> /etc/iproute2/rt_tables
fi

# Define routing tables:
ip route add default via $gw1 table rt_dev1
ip route add default via $gw2 table rt_dev2

# Create rules:
ip rule add from $ip1 table rt_dev1
ip rule add from $ip2 table rt_dev2

# If we already have a 'nexthop' route, delete it:
if [ ! -z "`ip route show table main | grep 'nexthop'`" ] ; then
ip route del default scope global
fi

# Balance links based on routes:
ip route add default scope global nexthop via $gw1 dev $DEV1 weight 1 nexthop via $gw2 dev $DEV2 weight 1

# Flush cache table:
ip route flush cache

# All done...

To use the script, copy it to /usr/local/bin, make it executable with 'chmod +x' and call it with:
bal_local

Monday, January 31, 2011

Moving your mysql database to another hard disk

Recently, my server's only hard disk was almost full. I bought a new hard disk with bigger size and I decided to just add it as a second hard disk. Since I need to move it to the 2nd hard disk, I need to find a proper way to move the db with minimum downtime. So I googled around and found a solution.

First, I needed to format the 2nd hard disk and I chose xfs as the filesystem. I created 2 partitions using Linux's fdisk for this task. First partition is 10 GB and 2nd one is around 900 GB. That's approximately added up to 1 TB. Then I mounted the 2nd partition in current partition eg /media/hd2 as follows:

mount -t xfs /dev/sdb5 /media/hd2

where /dev/sdb5 is the partition and /media/hd2 is the mounting dir.

Stop mysql db before doing anything:

service mysql stop

Afterthat, I copied the entire db to newly mounted hard disk:

cp -rv /var/lib/mysql /media/hd2

It will take a while if you have huge databases.

Then, change the ownership of the dir to user and group of mysql:

chown -R mysql:mysql /media/hd2/mysql

You need to change the mysql config file in /etc/my.cnf to point to the dir:

[mysqld]
user = mysql
datadir = /media/hd2/mysql
port = 3306
socket = /var/lib/mysql/mysql.sock
pid-file = /var/run/mysqld/mysqld.pid

Now you can restart mysql db:

service mysql start

If there are no errors on startup, you can test by login to your mysql db and do sql query.

You can leave other settings as it is. If this doesn't work and if you use innodb, you may want to change these lines:

# Uncomment the following if you are using InnoDB tables
#innodb_data_home_dir = /var/lib/mysql/
#innodb_data_file_path = ibdata1:10M:autoextend
#innodb_log_group_home_dir = /var/lib/mysql/
#innodb_log_arch_dir = /var/lib/mysql/

Make sure you test your dbs before deleting the old ones. Have fun!