I recently needed to rebuild a RAID1 array after a reboot for some odd reason and afterwards I was unable to assemble the array. mdadm came back and reported “Device or resource busy” on one of the drives. I couldn’t figure out what the issue was originally as it wasn’t mounted and no other processes were using the drive via lsof. Eventually I tracked it down to a changed UUID – my fstab was trying to mount the old mdadm array and it locked the resource. I checked it by doing ‘ls’ on /dev/disk/by-uuid/. Updating fstab with a new UUID, rebooting to clean up things and reassembling the array solved it. Just a useful item to keep in mind.
mdadm: Device or resource busy error
January 20th, 2012Debugging logcheck rules and security events
November 20th, 2011I’ve been a big fan of logcheck for monitoring my servers, when properly configured it works very well and is pretty flexible. Unless you are using a centralized logging system such as Splunk most of us are guilty of not thoroughly checking our logs. I like to use logcheck to perform a simple audit of what my systems are up to, it’s not perfect but certainly better then nothing.
My configuration has been tweaked a bit, adding some custom regex’s for ignoring a few common items. I found a nice debugging tip on a old posting from the logcheck-devel mailing list which mentions using egrep to test new rules:
cat <logfile> | egrep -v -f /etc/logcheck/ignore.d.workstation/regex
This has saved me a lot of time and frustration when making the final tweaks to a regex. However, recently I had some difficulties ignoring what seemed to be particularly stubborn security events. From best I could tell, grep suggested that my expression was filtering properly, yet logcheck was still reporting on these events. Finally reading through the README I discovered patterns cancelling security alarms must be places in violations.ignore.d, not ignore.d.workstation/server. Something to be mindful of.
Verizon/Samsung 4G MiFi and Ubuntu
October 6th, 2011I recently got a MiFi card for my on-call rotation with work and had some issues getting it to play nice with the Ubuntu install on my laptop. It’s a Samsung SCH-LC11 and various iMac’s in the office connected to it just fine. My laptop would connect, then almost immediately disconnect. Pretty much unusable. I connected to the office wifi just fine so I know that wasn’t an issue.
A quick search found a solution on the ubuntu forums. Basically, you need to connect to the device (obviously using a Windows or Mac) and log into the web admin page (default of 192.168.1.1). Check the wifi configuration security; the encryption protocol is probably set to WPA with TKIP. You need to set it to WPA2 with AES.
Samba shares multple connections to a shared resource
October 6th, 2011I don’t normally post much about Windows here as I have a limited presence with it at home – only a VM for Lightroom – but I came across this counter-intuitive problem earlier in the week. When building a new VM I discovered for some odd reason Windows would not allow me to map multiple shares to my Samba server under different paths with the same credentials. I kept getting the error:
Multiple connections to a server or shared resource by the same user, using more then one user name, are not allowed.
Now I was using the same user name on all of these and it worked perfectly fine on my old 2k3 VM and I changed nothing on the Samba side. No attempts at removing the shares and recreating them or reboots (even 3 of them!) seemed to help. Sigh… A bit of Googling suggested deleting all the shares explicitly on the command line, then try recreating them. This seemed to fix it!
net use * /delete
Interfacing sensors with the Bus Pirate
April 18th, 2011Spring has come and with it, storm season. In light of the recent historic multi-day tornado outbreak I’ve decided it was time to replace my initial Arduino weather station with something a bit more capable. The Arduino is a decent platform for a quick prototype, but I’ve been interested in PIC’s for some time and really would like some more experience with them. I recently picked up a Web Platform by Dangerous Prototypes and was impressed with its features, thought it would make a great platform for my new weather station. A quick order from SparkFun provided me with a few I²C sensors to experiment with.
Sidenote: The only downsides I thought of so far will be the inability to toss lots of sensors all on one bus. The 1-wire protocol provides each sensor with a unique address, somewhat similar to a MAC. However a basic weather station would only need a very few of these at the most (indoor/outdoor?) and this likely could easily be accomplished. Most sensors I’ve seen are configurable to allow at least 2-4 devices per bus and if needed more then one I²C bus could always be implemented on the PIC.
I figured some tinkering with my Bus Pirate to interface the sensors first would be a good start. This is a quick reference/demo for a few of SparkFun’s breakout sensors. Some of this is adapted from the example code provided on their website.
TMP102 – Digital Temperature Sensor Breakout (SEN-09418)
This is a tiny I²C sensor which provides a great resolution (12 bits), accuracy (0.5° 2° C), and nice features including programmable high/low alerting temperatures and low power consumption.
The ADDR/A0 pin allows for configuring the slave address to allow up to 4 devices on the same bus. It can be connected to either GND, V+, SDA or SCL; in my example here I’ve tied it to GND (using the AUX output of the Bus Pirate and setting it to low) I must state that it’s important to tie it to something, left floating the sensor did not seem to operate correctly. If using a different address reference the datasheet to see the necessary changes (Table 12). Also keep in mind this sensor needs 3.6V MAX, not 5V! Pullup resistors do not need to be enabled as they are already provided on the breakout board.
Set mode to I2C, set AUX low and turn on the power supplies:
HiZ> m 1. HiZ 2. 1-WIRE 3. UART 4. I2C 5. SPI 6. 2WIRE 7. 3WIRE 8. KEYB 9. LCD x. exit(without change) (1)> 4 Set speed: 1. ~5KHz 2. ~50KHz 3. ~100KHz 4. ~400KHz (1)> 3 Ready I2C> W Power supplies ON I2C> c a/A/@ controls AUX pin I2C> a AUX LOW I2C> (1) Searching I2C address space. Found devices at: 0x00(0x00 W) 0x90(0x48 W) 0x91(0x48 R)
To read the temperature you need to generate a start bit, send the device address, then specify the register to read (temperature read-only):
I2C> [0x90 0x00 I2C START BIT WRITE: 0x90 ACK WRITE: 0x00 ACK I2C> [0x91 r r I2C START BIT WRITE: 0x91 ACK READ: 0x19 READ: ACK 0x60
Our temperature data is 0×1960. The first byte is the MSB and the second LSB does not need to be read if not needed, in this case for a test it can be ignored – our temperature is 25°C (0×19). After pressing my finger on the sensor for a few seconds taking a second reading results in a MSB of 0x1F – 31°C, it indeed seems to work just fine.
Wisdom, Learning and Education
March 14th, 2011I wrote some time ago learning and briefly discussed how important it is for one to be continually learning. Along the same topic I recently stumbled across a posting by Ben Rockwood regarding knowledge, wisdom, and information. He wrote a very nice summary of the ideas of Russell Ackoff and W. Edwards Deming, Ackoff’s “Wisdom Hierarchy” being my favorite of the two. I won’t go into detail here, please read his excellent post for the juicy tidbits but it basically outlines the progression of things: from the low-level raw data, climbing up through information to knowledge, then understanding and finally (hopefully) arriving at wisdom.
It’s definitely something you can gloss over at first and think “yeah that’s obvious” but I highly recommend you read it and check out his second post with embedded videos from Dr. Ackoff himself on the subject. It’s very thought provoking and I think hits home the core reason behind a large amount of problems in the world around us today. One of the things I love the most is when he says there is a fundamental issue with our system of education; it’s not effective – who in the classroom learns the most? I’d have to agree with his answer – the teacher. We learn by teaching, not by being taught. This is definitely true and reminded me of recently watching a wonderful video on TED by Salman Khan of the Khan Academy, where he came to the same conclusion. The Khan Academy is an online compendium of educational videos which are helping to revolutionize the classroom and Salman is seeing the changes video teaching is bringing to students – peers are able to teach each other and therefore get a better grasp on the material themselves.
All in all, some very interesting ideas. I just wish this was more widely known among the general public.
Migrating mail server VM to a new host
February 19th, 2011I’ve been working on migrating a virtual host over to Rackspace which mainly runs a mail server among a few other small items. I wasn’t 100% sure how smooth the process would be, expecting to hit at least a few road bumps along the way. The first one I encountered was issues surrounding MX entries and the simplistic nature of the DNS record editor at Rackspace – most of my emails sent from my home PC were bouncing back 550 failed recipient verification. This was just a dry run however as when the domain was with my previous hoster I just used my registrar’s DNS, when I switched back the problem seemed to be resolved.
However the second issue I hit had me stumped for a few days. One of the reasons I migrated (besides price) was greater flexibility; Rackspace gave me more options for distros to choose from and I thought their overall interface was cleaner and designed better. So when I provisioned the new VM I gave Ubuntu a shot since I run it on my home network I’m a bit more familiar with how I want to configure the box for the software I run at least. After the DNS/mail issue was resolved everything seemed solid except for a random, albeit fairly minor problem. For some odd reason hostname resolution replied with “hostname: temporary failure in name resolution” randomly. I was getting emails from cronjobs running with this error which I found a bit strange. While I was tinkering with the mail problem I also built a CentOS VM real quick and didn’t notice the error occurring with that host. I double-checked and made sure the resolv.conf was identical, then /etc/hosts, then nsswitch.conf and so on, all the files seemed the same or at least close enough that I didn’t think it would be a problem. I made sure DNS resolution worked on the machine and ensured any iptables rules were not in place. What caught me as the strangest part was the fact it randomly worked and randomly didn’t, there did not seem to be any sort of reproducibility in the issue. I even ran an strace and compared logs from instances it worked and when it didn’t. ‘hostname -f’ also took a second or two to reply rather then an immediate response.
Eventually I figured I’d just add an alias to /etc/hosts with the local non-FQDN hostname. I also noticed then that the /etc/hosts didn’t seem to have an extra carriage return at the end, I put one in and bingo! Problem fixed. Looking back through the strace logs I saw upon closer inspection that it didn’t actually read in the second line which had the FQDN hostname, the first for localhost was OK but then it stopped further parsing. For some reason CentOS behaves differently as I saw – the hosts file was identical (except for the IP’s of course) – it too was missing a carriage return but strace revealed that it parsed the file just fine. Just in case any one is wondering I was testing this on Ubuntu Lucid 10.04.2 LTS and CentOS 5.5.
::sigh:: Ah well at least I can cancel the plan with my original hoster now.
Permission issues on slave BIND nameservers
January 21st, 2011I’m working on several projects at work to enhance our infrastructure and bring automation to our environment through tools such as Cobbler/Puppet/Kerberos and most of these rely on a working DNS system to operate correctly. After a quick refresh with BIND a primary nameserver was up and running pretty quickly. The zonefiles were populated easily enough after hacking together some Python to auto-generate configuration files from our server MySQL database. However I encountered issues when getting the slave nameserver up and running; I was getting errors such as “permission denied” when the slave was attempting to transfer the master zonefile. I was pretty sure it was configured correctly, it only seemed to fail when creating the temporary file. I checked the user permissions in the chroot and it all looked good, then I remembered this box was running SELinux. Checking the BIND FAQ I quickly found the answer: by default named is only allowed to write to the following directories:
- $ROOTDIR/var/named/slaves
- $ROOTDIR/var/named/data
- $ROOTDIR/var/tmp
with $ROOTDIR being the chroot specified in /etc/sysconfig/named. The configuration files are in $ROOTDIR/var/named and of course I was naming my file “sec.ourdomain.net” as opposed to “slaves/sec.ourdomain.net”. Oops. Have to keep this one in mind!



