Archive for the ‘Debian GNU/Linux’ Category

What’s liblinuxcs?

Wednesday, December 9th, 2009

I’ve just uploaded a small library that I’ve been using for a while now. It’s called liblinuxcs (or Linux Critical Section library). So what does it do? Well it basically provides interfaces for InitializeCriticalSection(), DeleteCriticalSection(), EnterCriticalSeciton(), and LeaveCriticalSection() on Linux. If you don’t know what those functions are, then this library is probably not for you. For those that come from a Windows programming background, this library should prove to be very helpful. As you’ll see in the code, this library is built from pthread mutexes.

This library is free to use by anyone and can be modified to your heart’s desire (here’s the license). I do ask that if anyone makes any useful changes or bug fixes that they reply to this post so that everyone can benifit.

Linux Intel PRO/1000 GB Ethernet Controller

Sunday, November 15th, 2009

Back to the server that was sitting on my desk… The Debian Lenny installation did not seem to recognize the Intel Pro/1000 10/100/1000 server Ethernet cards, dual port, PCI-E x4.

I ran: # lspci | grep Ethernet to list the pci devices (duh :P ). This gave me the following output:

03:00.0 Ethernet controller: Intel Corporation Device 10c9 (rev 01)
03:00.1 Ethernet controller: Intel Corporation Device 10c9 (rev 01)
04:00.0 Ethernet controller: Intel Corporation Device 10c9 (rev 01)
04:00.1 Ethernet controller: Intel Corporation Device 10c9 (rev 01)
06:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection
07:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection

The last two are the on board Ethernet controllers that work fine using the e1000e driver. The ones that I really wanted working were the first 4 items displayed as “Device 10c9 (rev 01)”. I couldn’t find anything on the internet other than a German post, which looked like the guy was having the same problem (I can’t decipher German). So I started trying out some different Intel drivers.

I first tried the standard e1000 driver as I noticed even some PCI express cards used this driver. That didn’t work. Then on my second shot I tried out this one “igb-1.2.44.9.tar.gz”. I’m assuming “igb” stands for Intel Gigabit, which makes sense as that’s what those cards are. If you don’t have the Intel driver disc that came with your cards you can find this driver here: http://downloadcenter.intel.com/Detail_Desc.aspx?agr=Y&DwnldID=13663&lang=eng

To install this driver just do the following:

# tar xfv igb-1.2.44.9.tar.gz
# cd igb-1.2.44.9/src
# make
# make install
# modprobe igb

As soon as I executed “modprobe igb” I instantly had 4 new eth interfaces! You might want to add “igb” to /etc/modules, which is where you can also supply some parameters for the driver.

Hopefully this post will help out anyone else who is having trouble with these cards on Debian.

Debian netboot/net install from a USB Drive

Saturday, November 14th, 2009

Today I ran into an interesting problem. On my desk sits a brand new server which was configured and built for speed. I was all ready to pop in my Debian GNU/Linux DVD when I noticed it was missing a CD/DVD drive! I quickly searched for some options and chose to try the network install using a local area network TFTP server. This soon proved to be a problem as the BIOS on the server did not have an option for a network boot using that PXE whatever :) .

The solution: a simple and easy boot-able USB drive!

The first thing to do is insert your USB drive into a laptop already running Debian. If you’re running a desktop like Gnome be sure to unmount the USB drive if it was automatically mounted. Now open up a terminal and su to root access. Your going to need a couple of packages: mbr and syslinux. If you do not already have them do a quick:

# apt-get install mbr syslinux

The next thing to do is find which device file is mapped to your USB drive. You simply execute dmesg and scroll up a bit untill you see information on your USB drive. The easiest way I’ve found to do this is by the following:

# dmesg | grep sd

This command pipes the output to grep so that we may search for “sd”. You should see something like the following:

[79316.428044] sd 4:0:0:0: [sdb] 1994385 512-byte hardware sectors (1021 MB)
[79316.432683] sd 4:0:0:0: [sdb] Write Protect is off
[79316.432683] sd 4:0:0:0: [sdb] Mode Sense: 03 00 00 00
[79316.432683] sd 4:0:0:0: [sdb] Assuming drive cache: write through
[79316.432683]  sdb: sdb1
[79316.436328] sd 4:0:0:0: [sdb] Attached SCSI removable disk

You’ll quickly notice our USB drive is attached to /dev/sdb (your output could be something other than sdb). The other helpful hint is the line that says “sdb: sdb1″. Now that we know this, we can use the tools we just downloaded to get our USB drive ready by executing the following:

# install-mbr /dev/sdb
# syslinux /dev/sdb1

Now we’re ready to mount the USB drive. I typically use /mnt/usb as my mount point for USB drives, which you can do the same by creating the usb directory in /mnt and then mounting the drive:

# mkdir /mnt/usb
# mount /dev/sdb1 /mnt/usb

Now that your USB drive is all ready to go, we should grab the Debian Linux files that are necessary. We’re going to download the stable version of Debian amd64 and save them into /mnt/usb or whereever you mounted your USB drive. You can retrieve these files using a web browser or wget:

http://ftp.us.debian.org/debian/dists/stable/main/installer-amd64/current/images/netboot/mini.iso

http://ftp.us.debian.org/debian/dists/stable/main/installer-amd64/current/images/netboot/debian-installer/amd64/initrd.gz

http://ftp.us.debian.org/debian/dists/stable/main/installer-amd64/current/images/netboot/debian-installer/amd64/linux

Now that you have mini.iso, initrd.gz, and linux saved on your USB drive, you need to create one mroe file. This file is called syslinux.cfg. You can use a text editor, a command line editor like nano, or just simply run the following command:

# echo -e "default linux\nappend priority=low vga=normal initrd=initrd.gz ramdisk_size=12000 root=/dev/ram rw" > /mnt/usb/syslinux.cfg

Unmount your USB like so:

# umount /dev/sdb1

Your USB is now ready to install Debian!

The very last thing I want to share, is after booting up my new server with the USB drive inserted, I received a prompt like the following (which I have no idea what it is):

MBR FA:

To get past this hit the A key. The prompt then changes to the following:

MBR 1234F:

I *think* this prompt is giving you the options 1, 2, 3, 4, or F. To install Debian I hit the 1 key and away I went…
Update: Thanks to a reader this is no longer a mistery :) . Please read WofFS’s comment below. Thanks WofFS!

EDIT: Do yourself a favor and remove the USB drive once the installer is running. I left mine in and GRUB wrote itself to the master boot record of my USB instead of the hard drive.