Sunday, September 13, 2009

create a fixed device for udev

i stole this from
http://www.debianhelp.co.uk/udev.htm

fconfig eth0
eth0 Link encap:Ethernet HWaddr 00:AB:CD:12:34:56
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:3 errors:0 dropped:0 overruns:0 carrier:3
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:180 (180.0 b)
Interrupt:185 Base address:0xc000

In the above example HWaddr is your MAC address 00:AB:CD:12:34:56

Using udev

Create a new file in the udev rules directory, e.g. /etc/udev/rules.d/010_netinterfaces.rules

In it specify the renaming in the following way for each interface on its own line

KERNEL="oldnameprefix*", SYSFS{address}=="MACaddress", NAME="newname"

where the oldnameprefix is typically eth. Note that in the MAC address, the hexadecimal digits should be in lowercase, otherwise udev fails to match them properly with the network interface.

You have quite a bit of freedom in choosing the new name, We recommend to keep it short and without any spaces or weird characters though. You can e.g. specify a fixed eth0, eth1, eth2 for specific MAC addresses, or you can name them after their use, or anything really. Remember that some applications that poke on a low level may dislike them not being called in the normal fashion of eth0, eth1..etc

Examples using udev

Example: Three network interfaces being present on a computer, setting a fixed eth0, eth1 and eth2 as their names.

KERNEL=="eth*", SYSFS{address}=="00:12:34:fe:dc:ba", NAME="eth0"
KERNEL=="eth*", SYSFS{address}=="00:56:78:98:76:54", NAME="eth1"
KERNEL=="eth*", SYSFS{address}=="00:90:ab:32:10:fe", NAME="eth2"Example: Three network interfaces (one Intel, one NVIDIA, and one 3Com) being present on a computer, naming them after the manufacturer of the interfaces.

KERNEL=="eth*", SYSFS{address}=="00:12:34:fe:dc:ba", NAME="eth-intel"
KERNEL=="eth*", SYSFS{address}=="00:56:78:98:76:54", NAME="eth-nv"
KERNEL=="eth*", SYSFS{address}=="00:90:ab:32:10:fe", NAME="eth-3com"

Updating network configuration

If you named the interfaces in a different fashion as they were named before, the network configuration needs to be updated for the new interface device names to be used.

Edit the /etc/network/interfaces file, and change all instances of the old names to the new names.

E.g. if you previously used eth0 and have renamed it newname, you'd replace all instances of eth0 in that file with newname

But if you just put a fixed eth0, eth1, ... as their names, you just need to make sure the one you want to have as the primary network interface is set to the one you want in the file.

Example

Having renamed the existing eth0, eth1, and eth2 to eth-intel, eth-nv and eth-3com, choosing to use the eth-intel one as the primary interface

The /etc/network/interfaces file before changes

# The primary network interface
auto eth0
iface eth0 inet dhcp

# Currently unused network interfaces
iface eth1 inet dhcp
iface eth2 inet dhcpThe file after changes:

# The primary network interface
auto eth-intel
iface eth-intel inet dhcp

# Currently unused network interfaces
iface eth-nv inet dhcp
iface eth-3com inet dhcp

Reboot and verify your configuration

Reboot the computer and verify that the new network interface names are in use with e.g. ifconfig

#ifconfig newname

Where newname is the new interface name you specified. Repeat procedure for each one you renamed.

Friday, September 11, 2009

debian apt-get dist-upgrade makes login as root fail

i tried many rescue attempts
using
Linux init=/bin/sh
mount -o remount,rw /
passwd
but rejected new passwd ...

so then i found this
passwd -d root
passwd root
enter passwd twice and it works
good.
i found this at

http://openplug.org/plugforum/index.php?topic=110.0

great rescue....

vpnc: receiving packet message too long

check the router eth1 it has mtu set too small to 576 need to reset it to 1500
so go to
/etc/rc.local
add line
ifconfig eth0 mtu 1500
and done
hat tip:
http://metauser.net/2008/11/15/vpnc-receiving-packet-message-too-long/

Saturday, August 1, 2009

run X apps as root

su
password
cd
rm .Xauthority
ln -s /home/user_name/.Xauthority .Xauthority

that should do it.
there are other ways as well...

Friday, June 12, 2009

postgresql backup information

see http://linux-addiction.blogspot.com/2009/02/how-to-backup-and-restore-postgresql.html

How To Backup and Restore PostgreSQL Database Using pg_dump and psql
pg_dump is an effective tool to backup postgres database. It creates a *.sql file with CREATE TABLE, ALTER TABLE, and COPY SQL statements of source database. To restore these dumps psql command is enough.

Using pg_dump, you can backup a local database and restore it on a remote database at the same time, using a single command. In this article, let us review several practical examples on how to use pg_dump to backup and restore.

For the impatient, here is the quick snippet of how backup and restore postgres database using pg_dump and psql:

Backup: $ pg_dump -U {user-name} {source_db} -f {dumpfilename.sql}

Restore: $ psql -U {user-name} -d {desintation_db}-f {dumpfilename.sql}

How To Backup Postgres Database
1. Backup a single postgres database

This example will backup erp database that belongs to user geekstuff, to the file mydb.sql

$ pg_dump -U geekstuff erp -f mydb.sql


It prompts for password, after authentication mydb.sql got created with create table, alter table and copy commands for all the tables in the erp database. Following is a partial output of mydb.sql showing the dump information of employee_details table.

--
-- Name: employee_details; Type: TABLE; Schema: public; Owner: geekstuff; Tablespace:
--

CREATE TABLE employee_details (
employee_name character varying(100),
emp_id integer NOT NULL,
designation character varying(50),
comments text
);

ALTER TABLE public.employee_details OWNER TO geekstuff;

--
-- Data for Name: employee_details; Type: TABLE DATA; Schema: public; Owner: geekstuff
--
COPY employee_details (employee_name, emp_id, designation, comments) FROM stdin;
geekstuff 1001 trainer
ramesh 1002 author
sathiya 1003 reader
\.
--
-- Name: employee_details_pkey; Type: CONSTRAINT; Schema: public; Owner: geekstuff; Tablespace:
--
ALTER TABLE ONLY employee_details



ADD CONSTRAINT employee_details_pkey PRIMARY KEY (emp_id);

2. Backup all postgres databases

To backup all databases, list out all the available databases as shown below.
Login as postgres / psql user:

$ su postgres

List the databases:

$ psql -l

List of databases
Name | Owner | Encoding
-----------+-----------+----------
article | sathiya | UTF8
backup | postgres | UTF8
erp | geekstuff | UTF8
geeker | sathiya | UTF8

Backup all postgres databases using pg_dumpall:

You can backup all the databases using pg_dumpall command.

$ pg_dumpall > all.sql

Verify the backup:

Verify whether all the databases are backed up,

$ grep "^[\]connect” all.sql
\connect article
\connect backup
\connect erp
\connect geeker

3. Backup a specific postgres table

$ pg_dump --table products -U geekstuff article -f onlytable.sql

To backup a specific table, use the –table TABLENAME option in the pg_dump command. If there are same table names in different schema then use the –schema SCHEMANAME option.
How To Restore Postgres Database
1. Restore a postgres database

$ psql -U erp -d erp_devel -f mydb.sql

This restores the dumped database to the erp_devel database.
Restore error messages

While restoring, there may be following errors and warning, which can be ignored.

psql:mydb.sql:13: ERROR: must be owner of schema public
psql:mydb.sql:34: ERROR: must be member of role "geekstuff"
psql:mydb.sql:59: WARNING: no privileges could be revoked
psql:mydb.sql:60: WARNING: no privileges could be revoked
psql:mydb.sql:61: WARNING: no privileges were granted
psql:mydb.sql:62: WARNING: no privileges were granted

2. Backup a local postgres database and restore to remote server using single command:

$ pg_dump dbname | psql -h hostname dbname

The above dumps the local database, and extracts it at the given hostname.
3. Restore all the postgres databases

$ su postgres
$ psql -f alldb.sql

4. Restore a single postgres table

The following psql command installs the patientinfo table in the database pacs.

$ psql -f patientinfo.sql pacs

Thursday, May 7, 2009

repair usb drive

nice article in linux-journal

http://www.linuxjournal.com/article/8366


How a Corrupted USB Drive Was Saved by GNU/Linux
June 14th, 2005 by Collin Park in

* HOWTOs

Would SUSE and fsck be able to recover the data in a usable way?
Average:
Cancel rating
Poor
Okay
Good
Great
Awesome
Your rating: None Average: 5 (15 votes)

My friend's brother had a 512MB Lexar Media Jumpdrive Pro USB drive that became corrupted after using it with Windows 2000. His IT department was able to get back some but not all of the file contents, but without any file names. On his own, he tried some recovery utilities, but all failed. Using a typical Linux distro--in this case SuSE 8.0--however, it wasn't hard to recover almost all of the data from the drive along with the filenames and to burn a CD-ROM of the contents.
USB Drive Ruined by Windows

Here's what I heard about the data loss:

Date: Sun, 1 Aug 2004 17:06:03 -0700
Subject: USB

... My USB drive is a
Lexar Media USB Jumpdrive Pro 2.0 (512 MB). I was working
on it in a computer with Windows 2000 and logged off before
ejecting the drive. Next time when I tried to use it,
it showed up as a Removable drive rather than the usual
Lexar Media drive and when I tried to open it, it said the
drive was not formatted; and under Properties, 0 bytes free
and used space and file system "RAW"

According to Lexar tech support, there is a bug with
Windows 2000 (that MS never bothered to fix) and can corrupt
the drive when it is removed without proper eject. They
recommend EasyRecovery Pro for data recovery which did
allow me to recover some files (> 500) using their RAW data
recovery program (all other tool failed because usually
said "no recognizable file on disc"). Unfortunately,
all the file names are lost and some files are gone.


The big questions was "can Linux read the drive?" A Web search of "linux usb jumpdrive pro" gave me hope that my kernel, 2.4.18 on SuSE 8.0, would recognize the drive in question. So, as root, I typed:

# tail -f /var/log/messages


and plugged the drive into a USB socket. Here's what appeared; I removed "Aug 5 01:32:15 linux kernel:" from each line below):

usb.c: registered new driver usb-storage
scsi0 : SCSI emulation for USB Mass Storage devices
usb-uhci.c: interrupt, status 3, frame# 1313
Vendor: LEXAR Model: JUMPDRIVE PRO Rev: 0
Type: Direct-Access ANSI SCSI revision: 02
Attached scsi removable disk sda at scsi0, channel 0, id 0, lun 0
SCSI device sda: 1001952 512-byte hdwr sectors (513 MB)
sda: Write Protect is off
sda: sda1
WARNING: USB Mass Storage data integrity not assured
USB Mass Storage device found at 4
USB Mass Storage support registered.


also according to one of the responders can try
http://www.brzitwa.de/mb/gpart/

Friday, May 1, 2009

MPX merged into X!! multi user mouse ideas

would like to use multiple mice at once

MPX for X gives multiple input devices multipointer x server
can convert already created applications to multipoint


http://www.neowin.net/forum/index.php?s=32dde4535c5ff99aacf474b8db4d4a54&showtopic=574028&pid=588710663&st=0&#entry588710663

now look at this

http://wearables.unisa.edu.au/mpx/?q=node/144
http://lists.freedesktop.org/archives/xorg/2008-May/035641.html

For those of you watching xorg-commits, you may have noticed that MPX has been
merged into master [1].
The client-side libraries and protocol headers have been merged quietly last
week already, this time is just the xserver itself.

A change in the previously proposed schedule [2]: the XKB rework didn't make
it. With the recent SSL issue and other workloads, Daniel wasn't able to get
it ready in time. We agreed on merging MPX without it, as it should not affect
XKB much anyway.

A number of changes went in since the announce, the most important being the
return of input device cordinate scaling. Tablets can thus be used. Thanks to
Magnus Vigerloef for his help on this matter.

The input ABI has been bumped and all the input drivers on fdo have been
updated to compile with the new API. You will need to get the latest version
however. I don't think the ABI will remain stable until the next release, but
I figured input modules not loading encourages people to fetch the latest
release rather than complaining about them not compiling anymore.

The video ABI has not been bumped yet, but you _must recompile_ your video
driver. No API changes, a recompile is enough.

As previously mentioned, existing setups should not be affected and anything
that changes is most likely a bug. Unless you create additional cursors/foci,
in which case the border between bug and broken UI paradigm is somewhat
blurry.

For the impatient, run the following commands:
Update xorg/app/xinput to the most recent version.

xinput --list --short
xinput --create-master "foobar"
xinput --reattach "MyMouse" "foobar pointer"
xinput --reattach "MyKeyboard" "foobar keyboard"

It is at this point you have a second set of devices that work independently.
It is at this point that you may realise that neither GNOME, KDE, nor any
other environment actually works decently with multiple devices. So start
fixing them right now.

To go back to a standard setup:

xinput --reattach "MyMouse" "Virtual core pointer"
xinput --reattach "MyKeyboard" "Virtual core keyboard"
xinput --remove-master "foobar pointer"

Have fun. Input bugs that result from the MPX merge can be assigned to me.
So long, and thanks for all the mice.

Cheers,
Peter

outrageous!