UNIX IPC tutorial in C

Brian Hall, “Beej” wrote a cool tutorial explaining all the different aspects of traditional UNIX Inter Process Communication (IPC). He provides a lot of C code where you can compile / test these concepts yourself for a better understanding. The high level concepts in this tutorial would be great material to use in conducting technical interviews. =) Thanks Brian!

Wiping a hard drive with preclear_disk.sh

I recently picked up a couple of Seagate 1.5TB hard drives, and based on the reviews I wanted to conduct an EXTENSIVE burn on each drive (a number of people have reported these drives suffered from the “click of death”). There are various tools to read and write data to a drive, but the most thorough tool I’ve found for Linux is preclear_disk.sh. Preclear writes a bunch of data to the drives, and checks to make sure the data read matches the data that was written (it writes out a special signature to assist with this). It also monitors hard drive SMART counters, and will report errors as it detects them. Cool tool, and highly recommended!

My 1000th blog post

Wow, I can’t believe 999 blog entries have been posted to the prefetch blog! This blog started all the way back in October of 2004, and was a way for me to document technology as I learned it. I never thought people would actually read it, and am even more amazed that this site now generates close to 600k+ hits per month. Yikes! The past five years have been pretty awesome, and I can’t even begin to describe how blessed I am to be working with technology on a daily basis (it’s a blast!). Thanks to everyone who reads this blog, and a HUGE shout out to my bloging partner Mike Svoboda! I hope to keep using this blog as a technology journal, and look forward to an awesome future!

Configuring a caching only DNS server on Solaris hosts

While investigating a performance issue a few weeks back, I noticed that a couple of our Solaris hosts were sending 10s of thousands of DNS requests to our authoritative DNS servers. Since the application was broken and unable to cache DNS records, I decided to configure a local caching only DNS server to reduce load on our DNS servers.

Creating a caching only name server on a Solaris host is a piece of cake. To begin, you will need to create a directory to store the bind zone files:

$ mkdir -p /var/named/conf

After this directory is created, you will need to place the, localhost and root.hints file in the conf directory. You can grab the and localhost files from my site, and the root.hints file can be generated with the dig utility:

$ dig @a.root-servers.net . ns > /var/named/conf/root.hints

Next you will need to create a BIND configuration file (a sample bind configuration file is also available on my site). The BIND packages that ship with Solaris check for this file in /etc/named.conf by default, so it’s easiest to create it there (you can also hack the SMF start script, but that can get overwritten in the future and wipe out your changes). To start the caching only DNS server, you can enable the dns/server SMF service:

$ svcadm enable dns/server

If things started up properly, you should see log entries similar to the following in /var/adm/messages:

Jun 18 10:26:57 server named[7819]: [ID 873579 daemon.notice] starting BIND 9.6.1-P3
Jun 18 10:26:57 server named[7819]: [ID 873579 daemon.notice] built with –prefix=/usr –with-libtool –bindir=/usr/sbin –sbindir=/usr/sbin –libdir=/usr/lib/dns –sysconfdir=/etc –localstatedir=/var –with-openssl=/usr/sfw –enable-threads=yes –enable-devpoll=yes –enable-fixed-rrset –disable-openssl-version-check -DNS_RUN_PID_DIR=0

To test the caching only DNS server, you can use our trusty friend dig:

$ dig @ a cnn.com

If that returns the correct A record, it’s a safe bet that the caching only name server is doing its job! To configure the server to query the local DNS server, you will need to replace the nameserver entries in /etc/resolv.conf with the following:


This will force resolution to the DNS server bound to localhost, and allow the local machine to cache query responses. DNS caching is good stuff, and setting this up on a Solaris machine is a piece of cake!

The state of OpenSolaris

Matty and I haven’t really spoken much about the current state of the OpenSolaris project. Oracle has been pretty tight with releasing any type of information about their plans / directions in which they will be taking Solaris / OpenSolaris. Its caused a lot fusteration.

The OpenSolaris Governing Board threw down the gauntlet and has threatened to dissolve pending some direct interaction / involvement from Oracle. Ben Rockwood has made his opinion made and a lot of what he has to say makes sense.

Sun spent a lot of effort / time / money / energy / excitement in trying to build the OpenSolaris community while they were still an independent entity from Oracle. UNIX admins played / tinkered with Linux at home, and it made its way into the data center and into production applications as it matured and became a rock solid technology. There is value in having the community embrace your O/S in a non-enterprise setting — such is the target market for OpenSolaris adoption. Its how the popularity of Linux overtook the large traditional UNIX implementations. (Solaris, AIX, HP-UX) If Oracle abandons OpenSolaris and allows the OGB to dissolve, I believe it will be a step in the wrong direction.

Locating physical disk drives in Solaris

On “enterprise” Sun hardware, you can do nifty tricks like blink LED lights on disks to identify where logical disk names like c8t2d0 resides as Matty pointed out in the blog post here.

But what if you’re stuck on crufty (cheaper) regular SATA drives without the sexy LED support? How do you find c8t2d0 amongst a ton of other disks? Using cfgadm -alv, you can print out the serial number of the drive. The serial number of the drive is usually printed on the external area that is viable (hopefully) or on top of the disk itself. Then, you can go SN hunting amongst all the other disk in your array. Niiice!

$ cfgadm -alv
Ap_Id                          Receptacle   Occupant     Condition  Information
When         Type         Busy     Phys_Id
sata1/0::dsk/c8t0d0            connected    configured   ok         Mod: WDC WD800JD-75HKA1 FRev: 14.03G14 SN: WD-WMAJ95141282
unavailable  disk         n        /devices/pci@0,0/pci108e,534a@7:0
sata1/1::dsk/c8t1d0            connected    configured   ok         Mod: ST31000528AS FRev: CC37 SN: 9VP21P37
unavailable  disk         n        /devices/pci@0,0/pci108e,534a@7:1
sata2/0::dsk/c3t0d0            connected    configured   ok         Mod: WDC WD10EARS-00Z5B1 FRev: 80.00A80 SN: WD-WMAVU1311029

Update: iostat -En also shows this serial number info as well. I often use iostat -En to check for transport errors and it didn’t dawn on me to look for SN info here. Thanks Mark!

$ iostat -En
c8t0d0           Soft Errors: 0 Hard Errors: 0 Transport Errors: 0 
Vendor: ATA      Product: WDC WD800JD-75HK Revision: 3G14 Serial No:  
Size: 80.00GB 
Media Error: 0 Device Not Ready: 0 No Device: 0 Recoverable: 0 
Illegal Request: 9 Predictive Failure Analysis: 0