Skip to main content

Convert VMWare to KVM

I used to run vmware (specifically VMWare Workstation), but I had to move away from it for a variety of reasons. It was fairly stable (I did run into a few issues, but always found a way around them after some work), so that wasn't the reason. (For those who care, every time I received a new kernel under Linux, I would have to recompile some modules and load them into VMWare and I just got tired of the hassle of doing that).

So I wanted to move almost a dozen vmware machines to another Virtualization stack. I looked at both VKM and Virtual Box and settled on KVM. I found some basic instructions on the KVM website here ( but they are so cryptic, I had trouble following them!

So this is an attempt to remedy that problem.

Read more…


File transfer

Most of the time we are trying to transfer file over network and stumble upon the problem which tool to use. There are again numerous methods available like FTP, SCP, SMB etc. But is it really worth the effort to install and configure such complicated software and create a sever at your machine when you only need to transfer one file and only once.

Suppose you want to transfer a file “file.txt” from A to B

Anyone can be server or client, lets make A as server and B as client.


$ nc -l 1567 < file.txt


$ nc -n 1567 > file.txt

Here we have created a server at A at redirected the netcat input from file file.txt, So when any connection is successfull the netcat send the content of the file.

Again at the client we have redirect the output of netcat to file.txt. When B connects to A , A sends the file content and B save that content to file file.txt.

It is not necessary do create the source of file as server we can work in the eopposeit order also. Like in the below case we are sending file from B to A but server is created at A. This time we only need to redirect ouput of netcat at to file and input at B from file.

B as server (Server)

$ nc -l 1567 > file.txt


$ nc 1567 < file.txt


Presentation on collectd / Graphite for PLUG

Below is my presentation from April for the Portland Linux/Unix Group (PLUG) Computer Group Advanced Topics Meeting. I wish I could thank the second person who jumped in and help answer some of the questions that I didn't have answers to.

There is a Version 1.0 (my draft), as well as a Version 1.1 (what I presented from) LibreOffice Presentation attached. Please contact me if you have any questions. I'm hoping to add some more Articles on this website when time allows (when does it ever?).

[] []

  • These files need to be moved into a subdirectory. *

PostgreSQL Sequences and Drupal

I was using Drupal and after one of my upgrades, something changed in the database (I wish I'd taken better notes of which upgrade and saved a copy of my backup, but I didn't do that quick enough so I've lost the data). In any case, my database sequences no longer matched up with what the database was expecting.

In fact, I was getting the following error:

* warning: pg_query(): Query failed: ERROR: duplicate key value violates unique constraint “node_revisions_pkey” in /path/to/drupal-6.2/includes/ on line 139.
* user warning: query: INSERT INTO node_revisions (nid, uid, title, body, teaser, log, timestamp, format) VALUES (0, 1, ‘test’, ‘test test test test test test test test test test test vv’, ‘test test test test test test test test test test test test test vv’, ”, 1294612270, 4) in /path/to/drupal-6.2/includes/ on line 3538.

All my research led me to believe that it was an issue with my sequence not being bound to my column correctly. However, I could see through psql that my column in the table was bound correctly. Finally, tired of debugging on and off over several months, I turned full logging onto my database and saw another error (now, if I'd really looked at the message, I might not have had to do that as I was able to get a clue from this web site:

By looking at the sequences and the tables (with the following commands), I discovered that my sequence was reset to a lower value.

tim=# SELECT nextval('node_nid_seq');
(1 row)

tim=# SELECT max(nid) FROM node;
(1 row)

tim=# SELECT nextval('node_revisions_vid_seq');
(1 row)

tim=# SELECT max(vid) FROM node_revisions;
(1 row)

Looking at the sequence for node_devisions_vid_seq and lookign at the max number of the vid from node_revisions...hey, I've got a mis-match. Resetting the sequence to be 146 solved my problem. Here is the actual SQL:

tim=# ALTER SEQUENCE node_revisions_vid_seq RESTART WITH 146;

And that seems to have fixed my problem for the database.

Change Table Ownership in PostgreSQL

I wanted to fix a problem with all the tables that were owned by a specific user. I looked up the user and found out it was a user with the ID (OID) of 16387.

Then I could use the following command to generate sql to fix the ownership in my database.

select 'ALTER TABLE ' || relname || ' OWNER TO web_user;' from pg_class where relkind = 'r' and relowner = 16387 order by relname;

This generated the following SQL for me (some people might recognize this as a way to generate dynamic SQL):

ALTER TABLE access OWNER TO web_user;
ALTER TABLE accesslog OWNER TO web_user;
ALTER TABLE actions OWNER TO web_user;
ALTER TABLE vocabulary OWNER TO web_user;
ALTER TABLE vocabulary_node_types OWNER TO web_user;
ALTER TABLE watchdog OWNER TO web_user;
ALTER TABLE webfm_attach OWNER TO web_user;
ALTER TABLE webfm_file OWNER TO web_user;
ALTER TABLE wysiwyg OWNER TO web_user;
ALTER TABLE wysiwyg_web_user OWNER TO web_user;

I could then run this output in my Postgresql client (psql as one example) to apply these ownership changes to all the tables (notice that my list above is NOT complete). (Just don't forget to be connected to the correct database or it will fail with a message like: ERROR:  relation "url_alias" does not exist.)

Fix Editing a Drupal Web Page

I had another recent challenge with Drupal (again, some other upgrade or change to my web server / database server) where I was no longer able to edit a page after loggging into my Drupal website.

Since I was using PostgreSQL I was able to update a few specific fields in a couple tables when I could no longer update my content on a particular page (node 145). I used pgadmin3 to run this query.

You need to update two different tables to fix the problem with unable to edit a page. Both the node and node_revisions tables need to be updated.

Then run the following code to update the page:

This allowed me to fix it so I could now EDIT the page inside Drupal.

NOTE: This worked for me with Drupal 7. This may not work for you. And any changes you make directly in the database could have other impacts. Validate your data and how Drupal is working (tracing queries, etc) before you directly make changes to your backend database.

MySQL Security Concern

Soemtimes when I encounter bugs, I have to sit and determine if they are a bug or just an issue. Or maybe, sometimes, it's how I think about something. In this case, maybe it's my process. In any case, I'm writing this up so I don't forget about it, and to share it with the larger community. This "bug" is with both MySQL v3.21 and v4.01 (I found it on 3.21 and verified it against v4.01 in my test environment).

For a little background. Several months ago I built a database for a friend on my web / database server. I added his user account so he could log in directly and created a database for him. I guess the name I chose for the database I built wasn't the best, as I deleted the database and removed his account from my system as the software (I named the database after the software I installed) didn't meet his needs (I used the MySQL commands "DROP USER 'xxx'@'localhost' and DROP USER 'xxx'@'%'". Everything looked good and I didn't see his name under the list of logins anymore (SELECT * FROM users WHERE user_login = 'xxx').

Having completely forgotten about this, I installed a newer version of the software for myself to look at a couple of weeks ago. And then last week, I re-added my friend back onto the server and granted him access to a different database. Imagine my surprise when he Instant Messaged me and asked why "his" database was still there, and what was all my data doing in it. It turned out that just dropping the user didn't remove the account access to the database, and I should also have executed a "REVOKE ALL PRIVILIGES FROM 'xxx'@'localhost' and REVOKE ALL PRIVILIGES FROM 'xxx'@'%'" on his account.

I'm not sure if this is a bug or just a detail in implementation. (And lucky for me I didn't have anything critical in there and that I trust him completely on my systems!)

This script is called from a cron job (scheduled task) and emails me on a daily basis this data so I can track disk space usage. I install it on all my systems (though I should probably do something different, like store the values in a database or something).

click to read the rest of the article

A required reading list for Geeks

Excuse the formatting. Copying it over from OpenOffice it threw off my tab marks and things. I've included references for all my sources at the bottom (end).

Many people have written a recommended reading list for “geeks.” I'm not sure I can claim to be all knowing, but at my first brush with this, I figured I'd take some books from various lists and add them with my own (there was already a lot of overlap) to produce my own list. While I've read many of them, I still have quite a way to go.

Read more…