2015년 1월 26일 월요일

Bash script to update a Beeminder Pomodoro goal

I sometimes use the Pomodoro technique to help me focus in 25-minute bursts with forced breaks of 5 minutes in between work blocks and longer extended breaks after 3~4 pomodoros. I thought it would be cool to write a script that would keep track of pomodoros as well as integrate with the Beeminder API, but then I realized that I could more easily use existing applications in the Linux ecosystem and glue them together with a bash script.

Ingredients

The Script





Usage

Both pystopwatch and xfce4-timer-plugin allow the user to launch an application when a timer completes its countdown. See screenshots below:



For pystopwatch, you access the alarm command dialog by right-clicking on the face of the timer after changing to Countdown Mode. To launch a cli script, I invoke my terminal program, terminator, with the -e option flag to make it run a specified command contained in double quotes (btw, pystopwatch asks that you add & to the end of any alarm commands so that they run in the background without locking the main program). You could simply specify sh ~/path/to/pomo2beeminder.sh to make pystopwatch run the script above.

For xfce4-timer-plugin, you must right-click on the timer icon, select Properties, and click edit on your timer to specify a command to run. Unlike pystopwatch, it is not necessary to append & at the end of your command invocation.

Careful readers will note that the script I am invoking through both timer apps is NOT pomo2beeminder.sh (although this will work fine). I created a separate timer-launched script that first calls mplayer to play a wav file and then executes pomo2beeminder.sh:


#!/bin/bash
# Script to be executed by pystopwatch or xfce4-timer-plugin
# when the timer for 1 pomodoro completely counts down

MUSIC=~/Music/zen_temple_bell-soundbible-com.wav

mplayer $MUSIC
sh ~/Documents/MyProjects/pomodoro/pomo2beeminder.sh

This way I can hear a sound effect when the timer completes after which the pomodoro script is executed.

Format for emails to the Beeminder bot

When sending emails to bot@beeminder.com how does it know which goal to update and how much to increment the graph? It parses this info from the subject line of the email, which must be in the format

username/goalName

The body of the email to the Beeminder bot must contain a line starting with a caret followed by a space and then a positive integer. The graph will be incremented by the integer value. Comments can also be added by placing them in between double quotes. Example:

^ 1 "sent by pomo2beeminder.sh"


smtp-cli parameters

The pomo2beeminder script uses smtp-cli to send emails through your webmail provider's smtp server. I use the Gmail smtp server, but other webmail services probably work, too.

Obviously you will have to change the values for the variables HOST (if you don't use Gmail), USER, FROM, TO and SUBJ. You should also create a separate smtp server password file named pass.txt that resides in the same path as the pomo2beeminder.sh script. It is good practice not to hardcode passwords in your scripts which might end up in VCS - git users out there could blacklist the password file from being tracked by adding it to .gitignore, for example. Within the script itself, the value of variable PW will be read from the separate file, pass.txt.

*Note: For those of you planning to use smtp-cli with gmail, you cannot use your regular webmail password to send mails through the Google smtp server -- please refer to a previous blog post of mine in which I explain how to generate an application-specific password for gmail which you can use with third-party apps.

Here's sample output from pomo2beeminder.sh

[archjun@arch pomodoro]$ ./pomo2beeminder.sh
Did you successfully complete your pomodoro?(y/n)
y
Connection from 192.168.0.9:42780 to 74.125.203.108:25
[220] 'mx.google.com ESMTP i3sm10596671pdf.39 - gsmtp'
> EHLO localhost
[250] 'mx.google.com at your service, [220.76.214.86]'
[250] 'SIZE 35882577'
[250] '8BITMIME'
[250] 'STARTTLS'
[250] 'ENHANCEDSTATUSCODES'
[250] 'PIPELINING'
[250] 'CHUNKING'
[250] 'SMTPUTF8'
Starting TLS...
> STARTTLS
[220] '2.0.0 Ready to start TLS'
Using cipher: ECDHE-RSA-AES128-SHA
Subject Name: /C=US/ST=California/L=Mountain View/O=Google Inc/CN=smtp.gmail.com
Issuer  Name: /C=US/O=Google Inc/CN=Google Internet Authority G2
> EHLO localhost
[250] 'mx.google.com at your service, [220.76.214.86]'
[250] 'SIZE 35882577'
[250] '8BITMIME'
[250] 'AUTH LOGIN PLAIN XOAUTH XOAUTH2 PLAIN-CLIENTTOKEN'
[250] 'ENHANCEDSTATUSCODES'
[250] 'PIPELINING'
[250] 'CHUNKING'
[250] 'SMTPUTF8'
AUTH method (LOGIN PLAIN XOAUTH XOAUTH2 PLAIN-CLIENTTOKEN): using LOGIN
> AUTH LOGIN
[334] '....' (redacted)
> .......... (redacted)
[334] '....' (redacted)
> .....
[235] '2.7.0 Accepted'
Authentication of gojun077@gmail.com@smtp.gmail.com succeeded
> MAIL FROM:
[250] '2.1.0 OK i3sm10596671pdf.39 - gsmtp'
> RCPT TO:
[250] '2.1.5 OK i3sm10596671pdf.39 - gsmtp'
> DATA
[354] ' Go ahead i3sm10596671pdf.39 - gsmtp'
[250] '2.0.0 OK 1422308096 i3sm10596671pdf.39 - gsmtp'
> QUIT
[221] '2.0.0 closing connection i3sm10596671pdf.39 - gsmtp'

[archjun@arch pomodoro]$ ./pomo2beeminder.sh
Did you successfully complete your pomodoro?(y/n)
a
Please answer y or n
Did you successfully complete your pomodoro?(y/n)
a
Please answer y or n
Did you successfully complete your pomodoro?(y/n)
;Please answer y or n
Did you successfully complete your pomodoro?(y/n)
q
Please answer y or n
Did you successfully complete your pomodoro?(y/n)
e
Please answer y or n
Did you successfully complete your pomodoro?(y/n)
r
Please answer y or n
Did you successfully complete your pomodoro?(y/n)
ty
Please answer y or n
Did you successfully complete your pomodoro?(y/n)
1111
Please answer y or n
Did you successfully complete your pomodoro?(y/n)
n
Concentrate harder next time!



If you have any comments or suggestions about the script, please let me know!

2015년 1월 19일 월요일

Open Source OCR on Linux using GUI Frontends for Tesseract

Although I use Linux both at home and at work, for some tasks, like OCR for Korean and Chinese, I have had to rely on proprietary software on Windows (ABBYY Finereader provides excellent recognition results, by the way). This is starting to change, thanks to the tesseract OCR engine currently sponsored by Google.

Tesseract has been around for several years, but it wasn't easily accessible before the advent of GUI frontends that make it easy to select the area of an image to be recognized. The two more popular frontends to tesseract are YAGF (which also works with the Cuneiform OCR engine) and gimagereader both of which now use the QT framework (the latter used to be based on gtk, but in recent versions, QT can also be used).

Screenshot of YAGF



Screenshot of gimagereader


Tesseract's English-language recognition is almost on par with ABBYY Finereader for 300 dpi images, but much worse than Finereader at detecting images less than 300 dpi resolution. When it comes to non-English text, especially Asian text such as CJK (Chinese, Japanese, Korean) and other scripts, however, the performance of the tesseract engine still has a long way to go before matching the performance of Finereader.

YAGF doesn't give the option to use Asian languages, despite the existence of tesseract data files for many Asian languages. For example, here is a listing of the available tesseract-data packages for various languages in Archlinux:

[archjun@lenovoS310 cam1]$ sudo pacman -Ss tesseract-data
[sudo] password for archjun: 
community/tesseract-data-afr 3.02.02-5 (tesseract-data)
    Tesseract OCR data (afr)
...
community/tesseract-data-chi_sim 3.02.02-5 (tesseract-data)
    Tesseract OCR data (chi_sim)
community/tesseract-data-chi_tra 3.02.02-5 (tesseract-data)
    Tesseract OCR data (chi_tra)
...
community/tesseract-data-jpn 3.02.02-5 (tesseract-data)
    Tesseract OCR data (jpn)
...
community/tesseract-data-kor 3.02.02-5 (tesseract-data) [installed]
    Tesseract OCR data (kor)
...
community/tesseract-data-vie 3.02.02-5 (tesseract-data)
    Tesseract OCR data (vie)

Piping the output through wc -l gives a line count of 130, divided by 2 (two lines per entry) gives 65 unique languages supported by Tesseract. As you can see in the sample output above, Asian languages CJK and Vietnamese are supported. According to the YAGF developer, Asian language OCR will be added to the GUI menu after European languages.

Fortunately, gimageview does support OCR for Asian languages as long as the necessary language data for tesseract has been installed. You may notice that the screenshot of gimagereader shows Korean text being recognized. Unfortunately, tesseract does a poor job of recognizing Korean. Although I haven't done a meticulous count, I would say off the top of my head that the results in the second screenshot above represent a recognition accuracy of maybe 70%. This is much worse than ABBYY Finereader. The tesseract-ocr project page offers some tips for improving OCR accuracy, such as upping the scan resolution, deskewing pages, etc., but the scanned image I used to test tesseract for Korean returned 90%+ OCR accuracy in ABBYY Finereader on Windows.

My conclusion: circa Jan. 2015, tesseract is good for English, not so good for Hangul/Korean.

2015년 1월 12일 월요일

Dell Latitude D630 from 2007 has Gigabit Ethernet!

Today I looked up the specs for my 2007 Dell Latitude D630 and noticed that it supposedly supports Gigabit Ethernet.

I ran lspci and ethtool to get more info on the Ethernet controller:

[archjun@arch ~]$ ethtool -i enp9s0
driver: tg3
version: 3.137
firmware-version: 5755m-v3.29
bus-info: 0000:09:00.0
supports-statistics: yes
supports-test: yes
supports-eeprom-access: yes
supports-register-dump: yes
supports-priv-flags: no
[archjun@arch ~]$ ethtool enp9s0
Settings for enp9s0:
Supported ports: [ TP ]
Supported link modes:   10baseT/Half 10baseT/Full 
                        100baseT/Half 100baseT/Full 
                        1000baseT/Half 1000baseT/Full 
Supported pause frame use: No
Supports auto-negotiation: Yes
Advertised link modes:  10baseT/Half 10baseT/Full 
                        100baseT/Half 100baseT/Full 
                        1000baseT/Half 1000baseT/Full 
Advertised pause frame use: Symmetric
Advertised auto-negotiation: Yes
Link partner advertised link modes:  10baseT/Half 10baseT/Full 
                                     100baseT/Half 100baseT/Full 
                                     1000baseT/Full 
Link partner advertised pause frame use: Symmetric
Link partner advertised auto-negotiation: Yes
Speed: 1000Mb/s
Duplex: Full
Port: Twisted Pair
PHYAD: 1
Transceiver: internal
Auto-negotiation: on
MDI-X: off
Cannot get wake-on-lan settings: Operation not permitted
Current message level: 0x000000ff (255)
       drv probe link timer ifdown ifup rx_err tx_err
Link detected: yes


[archjun@arch ~]$ lspci
...
09:00.0 Ethernet controller: Broadcom Corporation NetXtreme BCM5755M Gigabit Ethernet PCI Express (rev 02)

ethtool also verifies that the speed is 1000Mb/s and indicates that the Broadcom card uses the tg3 driver.

I was unaware that my old D630 Latitude had Gigabit Ethernet because I never had the chance to connect this machine to Gigabit-capable network hardware until recently. It is ironic that this old notebook that is 8 years old has more capable Ethernet than my Lenovo S310 work laptop, which only supports up to 100Mb/s and uses the Realtek r8169 driver:

[archjun@lenovoS310 bin]$ sudo ethtool enp1s0
[sudo] password for archjun: 
Settings for enp1s0:
Supported ports: [ TP MII ]
Supported link modes:   10baseT/Half 10baseT/Full 
                       100baseT/Half 100baseT/Full 
Supported pause frame use: No
Supports auto-negotiation: Yes
Advertised link modes:  10baseT/Half 10baseT/Full 
                       100baseT/Half 100baseT/Full 
Advertised pause frame use: Symmetric Receive-only
Advertised auto-negotiation: Yes
Speed: 10Mb/s
Duplex: Half
Port: MII
PHYAD: 0
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: pumbg
Wake-on: g
Current message level: 0x00000033 (51)
      drv probe ifdown ifup
Link detected: no
[archjun@lenovoS310 bin]$ sudo ethtool -i enp1s0
driver: r8169
version: 2.3LK-NAPI
firmware-version: 
bus-info: 0000:01:00.0
supports-statistics: yes
supports-test: no
supports-eeprom-access: no
supports-register-dump: yes
supports-priv-flags: no

2015년 1월 5일 월요일

Using a Virtualbox VM stored on a shared partition in several different OS'es

  On my notebook I use at work, I have one shared 250 GB btrfs partition that stores all my RHEL, CentOS, Debian/Ubuntu, etc installation .iso images as well as Virtualbox VM .vdi files The remaining space on the 500 GB disk is divided up into separate /boot partitions for various Linux distros while system partitions for each distro reside within LUKS containers containing separate LVM partitions (1 PV, 1 VG, and several logical volumes within the VG for mounting / /home /var and swap).

Since all the Virtualbox .vdi virtual disk images reside on the shared 250 GB partition, within each OS (i.e. Win7, Ubuntu, Arch...) we can import .vdi files into Virtualbox using VBoxManager thereby enabling us to use the VM's from multiple OS'es.

There are some caveats, however. If you want to use the VM's on multiple OS'es, you must not keep any save states; after finishing up your session, be sure to do a proper shutdown of the VM. This is of particular importance for WinXP or Win7 VM's. In the case of XP, I had a saved state residing on CentOS 7, but then I tried to load the VM from Arch which totally corrupted the image making booting no longer possible. In the case of a Win7 VM, even if there are no save states, on the first boot from a new host OS Win7 will restart itself to apply new configurations for the "new" host.

Another issue is that MAC addresses for existing network interfaces are randomized when an existing VM is imported into Virtualbox residing on a different host. This was problematic for me because my CentOS 6.5 VM serves as a PXE installation server. Within the VM there is a single network interface eth0 (note the host OS may have a different name for the wired network interface, i.e. enp1s0 etc) with the following MAC address:


The original MAC for our network interface is 08:00:27:3C:8A:03 but when we imported the CentOS 6.5 VM into Virtualbox on an Archlinux host, Virtualbox randomized the MAC address to another value.

When I started the CentOS 6.5 VM, I noticed that eth0 failed to come up and returned an error, "interface eth0 does not exist", and network interface eth1 was generated by the OS instead. This was problematic because my dhcp server config and PXE install scripts all assume that the network interface is on eth0.

Solution

I shut down the VM and, taking note of the original MAC above, simply replaced the randomized MAC address with 08:00:27:3C:8A:03 in the VBoxManager administration interface. Upon starting the VM once more, eth0 came up at boot without any problems.

2014년 12월 29일 월요일

Review of 1-day LFCS Preparation Course - LFS202

  On Friday, Dec. 12th Central Standard Time (CST in the United States), I participated in a one-day Linux Foundation class LFS202 offered through Google Hangouts with an optional dial-in telephone bridge in case the class suffered from audio problems. The class is designed as a prep session to briefly go over each of the topics from the LFCS (Linux Foundation Certified System Administrator) exam syllabus which is as follows (circa Dec. 2014):

Command-line
  • Editing text files on the command line
  • Manipulating text files from the command line
Filesystem & storage
  • Archiving and compressing files and directories
  • Assembling partitions as RAID devices
  • Configuring swap partitions
  • File attributes
  • Finding files on the filesystem
  • Formatting filesystems
  • Mounting filesystems automatically at boot time
  • Mounting networked filesystems
  • Partitioning storage devices
  • Troubleshooting filesystem issues
Local system administration
  • Creating backups
  • Creating local user groups
  • Managing file permissions
  • Managing fstab entries
  • Managing local users accounts
  • Managing the startup process and related services
  • Managing user accounts
  • Managing user account attributes
  • Managing user processes
  • Restoring backed up data
  • Setting file permissions and ownership
Local security
  • Accessing the root account
  • Using sudo to manage access to the root account
Shell scripting
  • Basic bash shell scripting
Software management
  • Installing software packages

Our teacher for the 8-hour class (7 hours of instruction, 1 hour break for lunch) was Kevin C. Smallwood, a Computer Science graduate from Purdue University who began his career in IT back in the days of ARPAnet and Motorola 6800 assembly language and worked on UNIX, BSD, and later LINUX machines while on staff at the Purdue University Dept. of Computer Science and the Computing Center. He possesses RHCS, RHCE, LFCS, and LFCE certifications. He is also a certified Redhat instructor.

In the LFS202 session I participated in, we had a total of 7 people in a Google Hangout (in addition to 1 'participant' which was actually a telephone voice bridge). Here is a screenshot of the Google Hangout:



When entering the G+ Hangout, Kevin asked everyone to turn off their cameras and microphones so we wouldn't hear ambient noise from each others' microphones. Although all participants are welcome to unmute their mics to ask questions, everyone seemed more comfortable asking questions through the group chat window on the right-hand side of the Hangout.

Kevin went through each of the topics on the syllabus above and showed examples using the Google Hangout screenshare feature. Since the LFCS and LFCE allow candidates to choose among Ubuntu, OpenSUSE, and CentOS as their testing platform, Kevin used several different virtual machines in VMware Player to illustrate how to accomplish various system administration tasks across the three distros.

This class is suited to those with an intermediate level of Linux knowledge. At the beginning of the class, Kevin pointed out that students should be familiar with all the topics covered in the free Linux Foundation LFS101x offered on edX. In fact, Kevin actually developed some of the curriculum for the first edition of the LFS101x course for Autumn 2014, namely, Chapter 13 Manipulating Text (covering sed, awk, grep and piping multiple commands together).

Although I am familiar with most of the GNU coreutils, it was enlightening to (virtually) look over Kevin's shoulder as he illustrated the infinite ways we could pipe output of one command to many others. For example, the LFCS exam might give you the following task:

Print all user accounts, sort them, remove duplicates, and count how many lines remain.

awk -F : '{ print $1 $6}' /etc/passwd | sort | uniq | wc -l

The first command prints the 1st and 6th columns from /etc/passwd which is then piped to sort, uniq and finally wc to count the number of unique lines. Kevin showed us countless other examples which I found very helpful, as I am not very familiar with sed and awk.

I felt more comfortable with the other topics on the syllabus having to do with filesystem administration tasks like manual partition creation using fdisk, creating LVM partitions, and editing /etc/fstab, as I encounter these tasks day-to-day in my job as a Linux System Engineer.

The class was a real pleasure to take and I think the Linux Foundation is lucky to have access to such experienced instructors. The only gripes I have are administrative.

(1) The class times on the Linux Foundation Training page are incorrectly listed in UTC, but in reality, the classes are on American Central Standard Time which is UTC -6 hours. See the screenshot below:




You can see that Start Time reads 00:00 UTC

This really confused me, because Korea is UTC +9 hours, so I thought that maybe the class might start at 9am Korea time. During the winter, there is a 15-hour time difference between American CST and KST (Korean Standard Time). Therefore I started class at midnight 0:00 on Saturday, Dec. 13 after a long day at work. It would be nice if the LF listed the proper time in UTC or got rid of UTC entirely and just listed times in CST to avoid confusion.

(2) More Flexible Class Hours for Non-US Students

I know there are some excellent English-speaking engineers in India, which is just a few hours behind the UTC+9 time zone that included Korea and Japan. Also Australia is in roughly the same time zone with East Asia. I think adding Australian or Indian instructors would be one way to expand the reach of Linux Foundation live sessions to more students around the world.

If the time difference wasn't such a big obstacle, I would definitely register for more online courses offered through the Linux Foundation!

2014년 12월 21일 일요일

Editing /usr/bin/brainworkshop and /usr/share/.../brainworkshop.pyw to share BW data between machines using Dropbox

In January 2013, I wrote a post about sharing Brain Workshop data between several machines using Dropbox. I recently tried to follow these same instructions, only to discover that they no longer work.

I spent some time over the weekend coming up with another way to share my BW training data with other machines using Dropbox, and have found a solution that requires light editing of one bash script and a Python source file. This post will assume that there is only one user of Brainworkshop (this user is automatically named default by BW).

First, let's take a look at the important files that brainworkshop package 4.8.4-4 installs on Archlinux:

[archjun@lenovoS310 ~]$ sudo pacman -Ql brainworkshop
[sudo] password for archjun: 
brainworkshop /usr/
brainworkshop /usr/bin/
brainworkshop /usr/bin/brainworkshop
...
brainworkshop /usr/share/brainworkshop/
brainworkshop /usr/share/brainworkshop/brainworkshop.pyw
brainworkshop /usr/share/brainworkshop/data/
brainworkshop /usr/share/brainworkshop/data/Readme-stats.txt
...

btw, commands on other distros to list files installed by pkgName are rpm -ql pkgName (RHEL/CentOS/Fedora etc) and dpkg-query -L pkgName (Debian/Ubuntu).

The file /usr/bin/brainworkshop is simply a bash script that calls /usr/share/brainworkshop/brainworkshop.pyw


#!/bin/sh
python2 /usr/share/brainworkshop/brainworkshop.pyw

A cautionary note -- on Archlinux, invoking python from the CLI will actually bring up the Python 3 REPL, as it is the default in Arch. On other distros, invoking python from the CLI will probably bring up the Python 2 REPL instead. To invoke Python 2 in Arch, you have to explicitly invoke python2 on the CLI or in scripts. The particulars of brainworkshop launch scripts will differ slightly between Linux distros.

I know that the official brainworkshop project is hosted on Sourceforge, but looking through the trunk branch of their SVN repo, I cannot find any brainworkshop.sh bash script file. Apparently the BW launch scripts for Linux are created separately by each distro.

In order to make Brainworkshop store config files and training data in a Dropbox folder instead of locally, we must make some edits to the launch script above. There are several config flags, --configfile, --statsfile, and --datadir that we need to add to our invocation of brainworkshop.pyw. The last flag was added at the end of March 2013, according to the brainworkshop Github repo for Slackware. (Click here for an example of how this flag can be used in a script or when invoking brainworkshop.pyw from the CLI). Below you can see my edited version of /usr/bin/brainworkshop.sh that specifies a Dropbox folder as the location for saving data and configuration files:

#!/bin/sh
BRW_CONFIGFILE=$HOME/Dropbox/.brainworkshop/data/.brainworkshop.ini
BRW_STATFILE=$HOME/Dropbox/.brainworkshop/data/.brainworkshop.stats
BRW_DATADIR=$HOME/Dropbox/.brainworkshop/data/

python2 /usr/share/brainworkshop/brainworkshop.pyw --configfile $BRW_CONFIGFILE --statsfile $BRW_STATFILE --datadir $BRW_DATADIR

But we are still not done, as the Python 2 script, brainworkshop.pyw, has slightly different names for the statistics and data files. We will change these manually. The function we need to find is named rewrite_configfile() and it should be around line 691 (Meta-g-g 691 for my fellow Emacs users out there).

Below is an edited version of /usr/share/brainworkshop/brainworkshop.pyw that changes the names of the stats and data files to match the settings in our launch script above:





You will see that I have commented out the following three lines:

#statsfile = 'stats.txt'
...
#STATS_BINARY = 'logfile.dat'
...
#newconfigfile_contents = CONFIGFILE_DEFAULT_CONTENTS.replace('stats.txt', statsfile)

and replaced them with the following (to make stats and data filenames consistent with settings in our custom /usr/bin/brainworkshop.sh)

statsfile = '.brainworkshop.stats'
...
STATS_BINARY = 'default-sessions.dat'
...
newconfigfile_contents = CONFIGFILE_DEFAULT_CONTENTS.replace('.brainworkshop.stats', statsfile)

Now when you open Brain Workshop, it will access data files from Dropbox instead of looking in your home directory!

2014년 12월 15일 월요일

[SOLVED] PXE booting woes on ATCA blade server hardware (ENP & Adlink)

Background

At my current company, we do a lot of work for two of the "Big Three" (SKT, LGU+, KT) mobile telecom providers in Korea. Interestingly, most of the 3G and 4G mobile communications infrastructure here runs on RHEL 5.X and 6.X.

In addition to more conventional server hardware like the HP Proliant line, Korean telecoms also use ATCA (Advanced Telecom Architecture) blade servers made by ENP (Emerson Network Power) and AdLink. ATCA blades are unique because they do not possess regular back panels with RJ45 network ports. Instead, the ATCA server backplane plugs directly into an ATCA switch.

Another oddity of ATCA hardware is that in many cases, there is no VGA port to connect to (as in the ENP ATCA 7350 and 736X series). Instead, to get video output, you must connect via serial console cable and use serial/modem communications through a terminal emulator like minicom or putty. Although the ATCA hardware engineers usually provide console speed settings (i.e. 57600 8N1, 115200 8N2, etc.) for getting video output through a terminal emulator, in many cases you still have to play around with the speed until you get a screen that doesn't show gibberish.

Unlike 4U servers which have PCI expansion slots for plugging in network cards, everything on ATCA blades is on-board, including the network adapters. This makes it unfeasible to flash updated PXE ROMs onto the NIC itself. Instead, you would have to get a BIOS upgrade to update outdated PXE implementations.

Problem

gpxelinux.0 from syslinux 4.05-8.el7 for RHEL 7 / CentOS 7 returns a kernel error when attempting to boot from PXE on various models of ATCA blades from ENP and Adlink. If I use pxelinux.0, at least I can get as far as the PXE menu (menu.c32), but then the boot seems to hang after sending the Linux kernel image vmlinuz and an associated initrd.img

My PXE server setup using dnsmasq and darkhttpd works just fine when installing via PXE to more conventional server hardware like the HP Proliant series.

The pxe config I used for PXE on ATCA blades is as follows:


The syslinux documentation mentions that broken PXE implementations are not uncommon, and presents a list of hardware known to have problems with syslinux PXE. I didn't see any mention of ATCA in the list, but I suspect that differences in PXE implementation are causing problems for me.

Stabs at a solution

Other engineers at my company use relatively old versions of syslinux, generally version 4.X available from the CentOS 6 repos, yet are able to install Linux over PXE using pxelinux.0 and a more conventional pxe server setup with httpd, xinetd, dhcpd, tftp, etc. I plan to recreate their setup and see if that resolves my issues with PXE on ATCA hardware.

I also need to make note of what kind of PXE boot agents (i.e. Intel Boot Agent, etc) are being used by ATCA as well as the PXE firmware version numbers.

Starting from syslinux 5.X, lpxelinux.0 became available, which natively supports sending pxe images by http and nfs instead of tftp. Perhaps trying lpxelinux.0 or the most recent version of syslinux (6.03 in Dec. 2014) pxe files will address my problem.

Postscript 2014-12-26:

It turns out that the PXE booting problems I experienced were due to "luser" error, not any problems with ATCA hardware.

Luser Error 1:

Incorrect syntax in the append initrd= block specifying serial console settings

Since most ATCA blades don't have VGA connectors, to get any kind of video output you must connect via remote serial console (through serial-to-RJ45 cable). The variable console= must be appended to the invocation of initrd (initramfs image). The correct syntax is

console=tty0 console=ttyS0,X (where X is serial communication speed in bps)

Unfortunately, I specified console=ttyS0 first, which won't work, according to the tldp Remote Serial Console HOW-TO:

The Linux kernel is configured to select the console by passing it the console parameter. The console parameter can be given repeatedly, but the parameter can only be given once for each console technology. So console=tty0 console=lp0 console=ttyS0 is acceptable but console=ttyS0 console=ttyS1 will not work.

Information from kernel.org regarding console over serial port:

tty0 for the foreground virtual console
ttyX for any other virtual console
ttySx for a serial port
lp0 for the first parallel port
ttyUSB0 for the first USB serial device 

You can specify multiple console= options on the kernel command line.
Output will appear on all of them. The last device will be used when
you open /dev/console. So, for example:
console=ttyS1,9600 console=tty0
defines that opening /dev/console will get you the current foreground
virtual console, and kernel messages will appear on both the VGA
console and the 2nd serial port (ttyS1 or COM2) at 9600 baud.

Since I specify console=ttyS0,57600 last, it will be the device used when /dev/console is opened.


Luser Error 2:

Incorrect vmlinuz and initrd.img

The PXE boot .cfg file above indicates that RHEL5.4 will be installed, but I accidentally used vmlinuz and initrd.img from RHEL5.6!


In addition to fixing errors 1 and 2, I also tried using lpxelinux.0 from syslinux 6.03 as the dhcp-boot image and am happy to report that it works fine. Now PXE boot and RHEL 5.X installation over http works for me!