Archive for category Linux

SLES 11 SP1 and Novell / SUSE Autoyast with Intel / Dell Raid Controllers

When using an Intel raid controller, you have two options: let the raid controller handle the raid, or run a linux software raid (md). If you want to run a linux software raid, and use autoyast, a prompt box will popup during the middle of the installation. This becomes a problem if you are imaging several thousand Linux systems.

Add this to your bootup options (in our case PXE config, but you can type it manually also from the installation CD prompt):

libstorage_imsm_driver=mdadm

That is all there is to it. To configure the rest of autoyast, you can check out Uwe Gansert’s website as he maintains it: http://www.suse.com/~ug/

Other hard to find resources when tracking these things down:

Programming using IOCTL to interface with Linux kernel drivers

IOCTL is a function call that allows you to interface with kernel drivers, allowing you to adjust settings or set parameters from code without compiling a new module.

From a programming perspective, having the linux kernel source is a prerequisite. In this example, I cloned the main kernel:

git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git linux

Once I had the source, I specifically wanted to see exactly how I could interface with the driver called usblp. I was using a USB to parallel port converter, and wanted to see if there was any way to force it to operate differently as we needed a non-printer device to work with it.

After opening the kernel source, I found the driver file itself which was under /drivers/usb/class/usblp.c. In this file I found a section of information about which IOCTLs it supported, and put them in a header file for my program called usblp-hack.h:

#ifndef USBLP_HACK_H
#define USBLP_HACK_H

#include <linux/ioctl.h>

/* ioctls: */
#define IOCNR_GET_DEVICE_ID     1
#define IOCNR_GET_PROTOCOLS     2
#define IOCNR_SET_PROTOCOL      3
#define IOCNR_HP_SET_CHANNEL        4
#define IOCNR_GET_BUS_ADDRESS       5
#define IOCNR_GET_VID_PID       6
#define IOCNR_SOFT_RESET        7
/* Get device_id string: */
#define LPIOC_GET_DEVICE_ID(len) _IOC(_IOC_READ, 'P', IOCNR_GET_DEVICE_ID, len)
/* The following ioctls were added for http://hpoj.sourceforge.net: */
/* Get two-int array:
 * [0]=current protocol (1=7/1/1, 2=7/1/2, 3=7/1/3),
 * [1]=supported protocol mask (mask&(1<<n)!=0 means 7/1/n supported): */
#define LPIOC_GET_PROTOCOLS(len) _IOC(_IOC_READ, 'P', IOCNR_GET_PROTOCOLS, len)
/* Set protocol (arg: 1=7/1/1, 2=7/1/2, 3=7/1/3): */
#define LPIOC_SET_PROTOCOL _IOC(_IOC_WRITE, 'P', IOCNR_SET_PROTOCOL, 0)
/* Set channel number (HP Vendor-specific command): */
#define LPIOC_HP_SET_CHANNEL _IOC(_IOC_WRITE, 'P', IOCNR_HP_SET_CHANNEL, 0)
/* Get two-int array: [0]=bus number, [1]=device address: */
#define LPIOC_GET_BUS_ADDRESS(len) _IOC(_IOC_READ, 'P', IOCNR_GET_BUS_ADDRESS, len)
/* Get two-int array: [0]=vendor ID, [1]=product ID: */
#define LPIOC_GET_VID_PID(len) _IOC(_IOC_READ, 'P', IOCNR_GET_VID_PID, len)
/* Perform class specific soft reset */
#define LPIOC_SOFT_RESET _IOC(_IOC_NONE, 'P', IOCNR_SOFT_RESET, 0)
#endif

There are plenty of hints on usage here, and I was able to grab a little more info after searching for some of those defines in google code search. Using these IOCTLs I wanted to know exactly which modes the USB to parallel converter supported, and try to set it in mode 3, which I hoped would give me more options for talking to the device.

Here is my usblp-hack.c which was able to probe and update these settings, although in my case mode 3 didn’t work, but shows an example of exactly how to do it:

#include "usblp-hack.h"
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>		/* open */
#include <unistd.h>		/* exit */
#include <sys/ioctl.h>		/* ioctl */

main()
{
	int fd;
	int twoints[2];

	fd = open("/dev/usblp0", O_RDONLY | O_NONBLOCK);
	if (fd < 0) {
		printf("Cannot open device.\n");
		exit(-1);
	}

	if(ioctl(fd, LPIOC_GET_PROTOCOLS(sizeof(int[2])), &twoints) >= 0)
		printf("Great success: %d / %d\n", twoints[0], twoints[1]);
	else {
		printf("Fail!\n");
		exit(-1);
	}

	if(ioctl(fd, LPIOC_SET_PROTOCOL, 2) >= 0)
		printf("set protocol to version 2\n");
	else {
		printf("Fail!\n");
		exit(-1);
	}

	if(ioctl(fd, LPIOC_GET_PROTOCOLS(sizeof(int[2])), &twoints) >= 0)
		printf("Great success: %d / %d\n", twoints[0], twoints[1]);
	else {
		printf("Fail!\n");
		exit(-1);
	}

	if(ioctl(fd, LPIOC_SOFT_RESET) >= 0)
	{
		printf("Success reset device\n");
	} else {
		printf("Could not reset device\n");
		exit(-1);
	}

	close(fd);
	exit(0);
}

You can compile the above example just using gcc:

gcc -o usblp-hack usblp-hack.c

You can see in the example above I was able to probe the device to see what mode it was currently in and supports (LPIOC_GET_PROTOCOLS), attempt to set the device mode (LPIOC_SET_PROTOCOL), and soft reset the device (LPIOC_SOFT_RESET).

So in the end, nothing here too complex or mind blowing, but if you are just getting your feet wet it might take you a minute to dig this sort of information up.

Tenda W322P Wireless N PCI Card

Purchased this card at Microcenter (http://www.microcenter.com/single_product_results.phtml?product_id=0316296). Out of the box works on Ubuntu 9.10, supports WEP, WPA, WPA2 and has no stability issues transferring large files etc.

Attempted to install the card under Windows 7 x64, x32, and Windows XP SP3, all of which did not recognize the card without additional drivers.

Summary: PCI wireless N card that is Ubuntu compatible with a price under $25
Grade: A+

Tags: , ,

Pygoocanvas, pygtk etc

I was reading a post about PyGoocanvas, and decided to take a look at some code and see what fun could be had. I haven’t done much yet, but this screenshot of it is pretty entertaining in it’s own right:

Ohio Linux Fest

I will be at Ohio Linux Fest all day Saturday, hope to see a lot of Ubuntu people there!

I am looking forward to “Python for Linux System Administration”, “Linux Boot Process”, “Introduction to GNOME 3.0″, “The Ubuntu Kernel”, “Understanding Debian” and “Building a Community Around Your Project”.

Should be a good time, official schedule is: http://www.ohiolinux.org/schedule.html

Tags: , ,

SLES / SLED 10 with Intel 965 Graphics

If you need to update your installation to work with Intel graphics, there is an RPM you can install that will likely resolve your issues:

http://download.opensuse.org/repositories/home:/mhopf:/hp/SLE_10/i586/intel-i810-xorg-x11-6.9.0.2-8.1.i586.rpm

Install that, then run Sax or edit xorg.conf, and make sure to pick the i810 driver. (This post is in response to the number of forum posts on this subject offering no solutions)

Tags: , , , ,

Creating a virtual machine using ubuntu-kvm-builder

I was playing with ubuntu-kvm-builder, and used apt-cacher for the mirror, and the build time is right around 2:30 which is pretty impressive. Using recordmydesktop I made a quick video of it, wanted to test the embedded video:

If you can’t see the video directly above this, you are not running a web browser that supports embedded videos (or you are seeing this on a planet).

Encrypted Swap

This post was spawned from my own misconception that my swap partition contained no sensitive data on systems with a lot of ram.

All of my systems I work with have atleast 4GB of ram, so my swap usage is usually under 2 megabytes. Why should I worry what’s in my swap partition?

Instead of going into it, just try it yourself. My swap partition is /dev/sda5. Run the command:

$ sudo strings /dev/sda5 | more

What came up was a ton of interesting data, from files I had looked at, print jobs, and bash scripts. So yes, even if you have enough ram, your swap is still very vulnerable to storing a lot of data about you.

Good news is Ubuntu 9.10 / Karmic will have the option to encrypt swap, which is on the wiki.

Tags: , ,

Manpages

Its almost the end of 2009, and I read on Planet Debian today a entry on writing man pages.

So man pages… where do we start? We have HTML / CSS / XML / RST which are all generally globally accepted formats of communication. Unfortunately, man pages do not use those.

And quite frankly, I am a fairly busy person, and have quite enough things to accomplish in a day. Why would I learn yet another formatting language? What justifies these files being in their own little world, when the whole world as a courtesy is supposed to provide them with their packages?

There really needs to be a movement to kill man pages in their current form, and bring them up to speed. A dialect for the sake of having a dialect really isn’t worth it when we have abundant alternatives.

Xorg / X11 programming update

So I have been looking into Xorg development. I posted about it a few months ago, but little to no help came of asking where to start looking. After asking several places without any useful help, I actually found a great book:

However, in my haste to order that one, I ordered 2 of these:

So if you are looking to get started with X11 / Xlib / Xorg these are handy to have around. Since I have 2 copies of the pink reference manual, if you want one, email me at sharms at ubuntu period com and I will send you my extra copy for free. Or if you want I can bring it to Ohio Linux Fest 2009 and give it to you there.

Update: Book claimed already

Tags: , , , ,