21.07.2015 Views

Linux Journal | September 2012 | Issue 221 - ACM Digital Library

Linux Journal | September 2012 | Issue 221 - ACM Digital Library

Linux Journal | September 2012 | Issue 221 - ACM Digital Library

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

SAVE THE DATE!26th Large InstallationSystem Administration Conferencesponsored by USENIXin cooperation with LOPSADECEMBER 9—14, <strong>2012</strong> | SAN DIEGO, CACome to LISA ’12 for training and face timewith experts in the sysadmin community.LISA ’12 will feature:6 days of training on topics including:• Virtualization• Security• Configuration Management• CloudPlus a 3-day Technical Program:• Invited Talks• Guru Is In Sessions• Paper Presentations • Vendor Exhibition• Practice and• WorkshopsExperience Reports • Posters and WIPsThe LISA '12 keynote address will be delivered by Vint Cerf, Google.Registration opens mid-<strong>September</strong>.www.usenix.org/lisa12


CONTENTSSEPTEMBER <strong>2012</strong>ISSUE <strong>221</strong>EMBEDDED70 LOGITECH SQUEEZEBOX PLATFORMFEATURES70 LogitechSqueezeboxPlatform: Livin’in the Land of(Open-Source)Hi-FiStop worrying aboutuploading gigabytes of musicfiles to the cloud, and startenjoying your music with theLogitech Squeezebox.Craig Maloney84 ArduinoTeachesOld CoderNew TricksAn Arduino-inspiredhardware projectusing the gEDAopen-source <strong>Linux</strong>software suite forprinted circuitdevelopment.Edward Comer106 TheRadicalFutureof NVMThink there hasto be a trade-offbetween highperformanceand storagepersistence?Not anymore.Richard Campbell4 / SEPTEMBER <strong>2012</strong> / WWW.LINUXJOURNAL.COM


COLUMNS32 Reuven M. Lerner’s At the ForgePL/R40 Dave Taylor’s Work the ShellBash Notational Shortcuts: Efficiencyover Clarity44 Kyle Rankin’s Hack and /Troubleshooting with Telnet21 PLUME50 Shawn Powers’ The Open-SourceClassroomA Domain by Any Other Name...118 Doc Searls’ EOFMaking the Case to MugglesREVIEW62 ZaTab: ZaReason’s Open TabletKevin Bush22 EXTREMAIN EVERY ISSUE8 Current_<strong>Issue</strong>.tar.gz10 Letters18 UPFRONT30 Editors’ Choice58 New Products123 Advertisers IndexON THE COVER• Telnet: a Handy Troubleshooting Tool, p. 44• Become a Knowledgable DNS User, p. 50• An Arduino-Inspired Hardware Project, p. 84• The Next Big Thing in Main Memory Is Going to Change Everything, p. 106• Stream Your Music with Logitech Squeezebox's Open Platform, p. 70• Bash Notational Shortcuts, p. 40• Reviewed: ZaReason's ZaTab, p. 62• Embed the R Language in PostgreSQL for Powerful Statistical Analysis, p. 32Cover Image: © Can Stock Photo Inc. / silvertiger62 ZAREASON’S ZATABLINUX JOURNAL (ISSN 1075-3583) is published monthly by Belltown Media, Inc., 2121 Sage Road, Ste. 310, Houston, TX 77056 USA. Subscription rate is $29.50/year. Subscriptions start with the next issue.WWW.LINUXJOURNAL.COM / SEPTEMBER <strong>2012</strong> / 5


lettersDaveTaylor’sWork theShell, July<strong>2012</strong>I just wantedto say thanksto Dave for thesubshell article!NOOK store at a low price. My questionis why is there no subscription availablethrough the NOOK store? I would bevery happy to purchase a subscriptionthrough there. Until then, I’ll continuepurchasing individual issues, but asubscription through the NOOK storewould be preferred.—Jeffery MathisI have to workwith a lot of .csv files and used to takea lot of time manipulating them with aspreadsheet program, but after learning justa small bit about shell scripting (and a bitof Perl too), I’ve found that I can trim thoselarge chunks of time to mere seconds andautomate out the tedium and drudgery.Since then, I continually look for as manytips as I can find about shell scripting, soplease continue!—Jeff ShuttDave Taylor replies: Thanks, Jeff!Appreciate hearing from you.NOOK SubscriptionThis isn’t a complaint, as I know therehave been many regarding the switchto the all-digital edition. As a NOOKColor owner, I was delighted to findissues available for purchase in theThanks for your support! We’redefinitely looking into the NOOKsubscription option. Keep in mindthough that if you order a subscriptionthrough <strong>Linux</strong><strong>Journal</strong>.com, you willreceive a monthly download linkthat contains .epub, .pdf and on-lineversions as well as .mobi. If you orderthrough B&N, you receive only the.epub version.—Ed.Android AppI have been reading your marvelousmagazine for more than 10 years.I recently got myself a new Android(Samsung Galaxy S2 4G) smartphone, andone of the first applications I installedwas yours, so I could read your magazineanytime, day or night. But, I have beenhaving a few issues with the app.1) I have to enter my e-mail address (4010 / SEPTEMBER <strong>2012</strong> / WWW.LINUXJOURNAL.COM


[ LETTERS ]characters in total) every time I try toaccess the magazine on-line!2) I often get the error “Subscriptionoptions are unavailable: device is off-lineor service is unavailable.”I live in the Federal Capital of Australia- Canberra and have ADSL 2+ athome, and I work for Unisys on federalgovernment accounts, and they havevery high-speed Internet access (I can’tdiscuss further for security reasons).The device is definitely not off-line. Itshows 4–5 bars of signal strength atwork and at home. I have alternatedbetween Wi-Fi and the phone networkfor access, but this is really starting tobug me. I have never had any other appissues—LinkedIn, Foursquare, Groupon,Gmail, eBay, Telstra (phone carrier),Amazon, RealEstate.com.au and heapsof other apps all work perfectly.I can’t find a “debug” setting in yourapp or setup options, such as “saveyour e-mail address”.How can I “save” my e-mail address? Howcan I get some debug details from the appto try to resolve the connectivity issue?—Nigel GrantWow, Nigel, I’m really sorry you’ve had somuch trouble with the app. It is certainlysupposed to keep your information, andalthough there were some on-line/off-lineissues with early versions of the app, theyshould be largely solved now. My firstrecommendation would be to troubleshootlike any other oddly acting app. Try clearingall the cached data (in settings/applications),and if that doesn’t help, try deleting andre-installing it. If you’ve moved the appto the SD card, make sure permissionsare correct and so on. Hopefully, it willstraighten out for you soon. Be sure tocheck out the .epub and .mobi versionstoo; they render nicely on the S2 as well.(I have the same phone myself.)—Ed.LJ .mobi to KindleAt Pragmatic Bookshelf, they offer theire-publication in .mobi format (amongothers). By giving them your Kindle’se-mail address and allowing e-mail fromthem on your Amazon account, they cansend your publications directly to yourKindle. Is this a possibility for LJ?—Jes D. NissenJes, although our distribution methoddoesn’t currently support a direct e-mail,some fellow readers have scripted automatedsolutions. Check the past couple issues,or read the next letter from Ward.—Ed.WWW.LINUXJOURNAL.COM / SEPTEMBER <strong>2012</strong> / 11


[ LETTERS ]Script to Send the .mobi Versionof LJ to an @kindle.com AddressI’ve written a Python script that fetchesthe monthly LJ e-mail from an IMAPserver, uses the URL inside to downloadthe .mobi version of LJ and send that to an@kindle.com address, so that when yousync your Kindle, LJ is added automatically.Just add the script to your cron job to runmonthly. Feel free to share the script. Youcan find it at http://goo.gl/C2IE3.—Ward PoelmansWard, you rock my face off (which myteenage daughter assures me is a goodthing, and not the nightmare-inducinghorror scene it sounds like). Seriously,thanks a ton.—Ed.Transition to All-<strong>Digital</strong>I greatly miss <strong>Linux</strong> <strong>Journal</strong> in hardcopy. There is no substitute for having amagazine around that you can just pickup and read anytime, anywhere. Theelectronic version, despite having someadvantages, simply fails to match thehard-copy experience.Now, I have passed through the grievingprocess—denial, anger, bargaining,depression—and have come toacceptance. As such, I will continue tosubscribe, because <strong>Linux</strong> <strong>Journal</strong> is partof the <strong>Linux</strong> ecosystem, and I want theecosystem to grow and evolve, even ifoccasionally some changes displease me.Since you have gone all electronic, pleaseadapt your style to the new media. It’s nolonger print, so lose the print format andcapitalize on the possibilities of digital.Two columns don’t work on displaysthat don’t show a complete page; someof the images need higher resolution(the photos of Reuven and the SiliconMechanics and iXsystems advertisementsin the July issue, for example); cut thepublishing cycle to be more timely;don’t go overboard with multimedia,but include it when it enhances theexposition and works creatively.It is going to be hard going for you andyour loyal readers, but I am preparedto continue to support <strong>Linux</strong> <strong>Journal</strong>through this difficult time.—Gordon GarmaiseGordon, I understand your process, andeven though I had to put on a happy face,I may have had some similar emotions!We have modified the PDF versionsignificantly to look better on devices, yetstill retain the magazine look and feel. Ifyou’ve seen the PDF on a 10" tablet, it’spretty stunning. Hopefully, the .epub and.mobi versions with their flowing text helpwith other devices.—Ed.12 / SEPTEMBER <strong>2012</strong> / WWW.LINUXJOURNAL.COM


[ LETTERS ]Love the E-FormatI’ve read numerous rants and raves aboutthe digital format of <strong>Linux</strong> <strong>Journal</strong>, andI felt the need to chime in with somepositive feedback. Personally, I love thedigital format. It’s the reason I renewedmy LJ subscription. Almost all themagazines I used to read in paper, I nowlook for in digital format. It’s much moreportable, and I no longer have to worryabout having stacks of magazine copiespiled under the coffee table or lined upon my bookcase. The electronic versionis also much more interactive. If a personwants to learn more about a particulararticle topic or an interesting product inan ad, there’s usually a hyperlink to clickon. I would like to see all magazines atleast offer a digital option for those of uswho prefer bytes over tree bark.—Jim Vaughn!! > new-script.shThis will not save the command. Itwill run the last command and saveits output. If you want to save the lastcommand, you want to say either:!!:p > new-script.shor:echo "!!" > new-script.sThey are almost the same but not quite.By the way, the !! syntax is from the Cshell and is a part of Bash as well. It isnot a part of the Bourne shell or ksh.You show how useful subshells can be:newname=$(echo $filename | sed 's/.JPEG/.jpg/')Thanks Jim! It’s certainly been apolarizing topic, that’s for sure.—Ed.Regarding My Letter to DaveTaylor in the Last <strong>Issue</strong>I just read Dave Taylor’s July <strong>2012</strong>column. Keeping in the same vein asbefore, I want to see if these commentsto Dave help.In fact, this is massive overkill. The $()is a subshell. The echo is built in, sono subshell there. Then, you use sedwith all of its footprint that is capableof powerful regex manipulations, for atotal of two subprocesses. Instead, howabout a simpler approach:newname="${filename/.JPEG/.jpg}" # Look Ma! No subprocesses.You refer to how you can build up acommand and then save it by saying:How graceful is the continuation of amulti-line command? But, there’s noWWW.LINUXJOURNAL.COM / SEPTEMBER <strong>2012</strong> / 13


[ LETTERS ]good compared with a simple .epubreader, which is what I’ll be using.Keep up the good work and sorry forranting. Maybe it’s just me, since I wouldthink that these issues would be seriousenough to prevent the release of the app.—MikeThanks for the feedback, Mike. We’llmake sure to get the info to the Texterityfolks. Sadly, cluebats aren’t indigenousto my area, so I may have to smack themwith a fruit bat instead.—Ed.Why Not Have a Happy Funeralfor the Paper Version of LJ?All right, I must admit that during thepast few months I have attempted to tryto guess which page the Letters to theEditor would end and start reading fromthere. The only other place I have heardmore complaining has been at church—ifpeople thought the song service was toolong, too short, not enough traditionalsongs, not enough new songs, not mynewly written song, and I haven’t eventouched the minster’s message critiques!I have been reading an interesting booktitled How to Change Your Church(Without Killing It). An intriguing chapterin the book describes how leaders needto honor areas of ministry that have runtheir course before phasing them out.This got me looking back at all of thewriters over the months that have beenangry about the removal of the paperversion of their favorite magazine. Iunderstand the economics of businessand am not suggesting you do somethingthat would jeopardize your bottom line,but I do think there is a solution to helpthose who are angry and disappointedabout the absence of their physicalmagazine. Why not rejoice in the articlesof the past? Summon all past subscribersof the print edition to tell you whichpaper article was the best in theiropinion. Rejoice and give credit to thosewho got their fingers dirty at the printingpress. It just may cause some disgruntledfolks to come back just because you areallowing them the opportunity to thumbthrough their old magazines and relivethe moments of breaking off work earlyto get to the mailbox for the magazine.They may start to await the e-mailprompt: “Your <strong>Issue</strong> of <strong>Linux</strong> <strong>Journal</strong> hasarrived and is ready for download”.If people have a chance to rejoice andrelive their positive experiences of thepast, they may just come back!—Dean AndersonDean, that’s an interesting idea. We’lltoss it around a bit and see if we can16 / SEPTEMBER <strong>2012</strong> / WWW.LINUXJOURNAL.COM


come up with something. I still have quite a stack of<strong>Linux</strong> <strong>Journal</strong> issues I can’t bear to part with. (Thearcade machine article in the August 2007 issue wasthe first time I was ever published. <strong>Issue</strong> 160 willalways have a home on my coffee table! Seehttp://www.linuxjournal.com/article/9732.)—Ed.Photo of the MonthI’d like to share this photo with readers.—Tim O’GradyAt Your ServiceSUBSCRIPTIONS: <strong>Linux</strong> <strong>Journal</strong> is availablein a variety of digital formats, including PDF,.epub, .mobi and an on-line digital edition,as well as apps for iOS and Android devices.Renewing your subscription, changing youre-mail address for issue delivery, paying yourinvoice, viewing your account details or othersubscription inquiries can be done instantlyon-line: http://www.linuxjournal.com/subs.E-mail us at subs@linuxjournal.com or reachus via postal mail at <strong>Linux</strong> <strong>Journal</strong>, PO Box980985, Houston, TX 77098 USA. Pleaseremember to include your complete nameand address when contacting us.ACCESSING THE DIGITAL ARCHIVE:Your monthly download notificationswill have links to the various formatsand to the digital archive. To access thedigital archive at any time, log in athttp://www.linuxjournal.com/digital.LETTERS TO THE EDITOR: We welcome yourletters and encourage you to submit themat http://www.linuxjournal.com/contact ormail them to <strong>Linux</strong> <strong>Journal</strong>, PO Box 980985,Houston, TX 77098 USA. Letters may beedited for space and clarity.WRITING FOR US: We always are lookingfor contributed articles, tutorials andreal-world stories for the magazine.An author’s guide, a list of topics anddue dates can be found on-line:http://www.linuxjournal.com/author.Are you an emacs or vi roo?WRITE LJ A LETTER We love hearing from our readers. Please send usyour comments and feedback via http://www.linuxjournal.com/contact.FREE e-NEWSLETTERS: <strong>Linux</strong> <strong>Journal</strong>editors publish newsletters on botha weekly and monthly basis. Receivelate-breaking news, technical tips andtricks, an inside look at upcoming issuesand links to in-depth stories featured onhttp://www.linuxjournal.com. Subscribefor free today: http://www.linuxjournal.com/enewsletters.Go to http://www.linuxjournal.com/rc<strong>2012</strong> to vote in this year'sReaders' Choice Awards!Voting ends <strong>September</strong> 16, <strong>2012</strong>.ADVERTISING: <strong>Linux</strong> <strong>Journal</strong> is a greatresource for readers and advertisers alike.Request a media kit, view our currenteditorial calendar and advertising due dates,or learn more about other advertisingand marketing opportunities by visitingus on-line: http://ww.linuxjournal.com/advertising. Contact us directly for furtherinformation: ads@linuxjournal.com or+1 713-344-1956 ext. 2.WWW.LINUXJOURNAL.COM / SEPTEMBER <strong>2012</strong> / 17


UPFRONTNEWS + FUNdiff -uWHAT’S NEW IN KERNEL DEVELOPMENTApparently, Cloud<strong>Linux</strong> recentlyaccidentally released a non-GPLeddriver that still used GPL-onlykernel symbols, and that claimedto the kernel to be GPLed code.Matthew Garrett noticed thisfirst, and he submitted a patchto cause the kernel to treat themodule as non-GPL automaticallyand deny it access to the GPL-onlysymbols. Because the violationwas so blatant, a number ofkernel developers seemed to favorpotentially taking legal action againstCloud<strong>Linux</strong>. Greg Kroah-Hartmanwas particularly dismayed, sincethe driver in question used kernelsymbols he himself had created forGPL use only.At one point the CEO ofCloud<strong>Linux</strong>, Igor Seletskiy,explained that this just had beenan engineering mistake. They haddecided to release their GPLed driverunder a proprietary license, whichas the copyright holders they wereallowed to do, but they mistakenlyhad failed to update the code tostop using GPL-only symbols. Hepromised to fix the problem withinthe next few weeks and to providesource code to the binary driver thathad caused the fuss.Chris Jones recently asked whatthe etiquette was for giving hisown personal version numbers tohis own customized kernels. GregKroah-Hartman replied that he wasfree to do whatever he wantedin that arena without offendinganyone. But, Greg suggested thatin order for Chris’ users to beable to understand the featuresand capabilities of the particularcustomized kernels, Chris probablywould be served best by relying onthe official version numbers andjust appending his own afterward—for example, <strong>Linux</strong> version 3.4-cj2.Apparently, the number of patchsubmissions coming into the <strong>Linux</strong>kernel is in the process of explodingat the speed of light, like a new BigBang. Thomas Gleixner remarkedon this trend and suggested thatthe kernel development processmight have to be modified to beable to handle such an E=mc 2 -esque18 / SEPTEMBER <strong>2012</strong> / WWW.LINUXJOURNAL.COM


[ UPFRONT ]Greg Kroah-Hartman even said he thoughtthe increase in patch submissions might bean intentional denial-of-service attack....situation. Greg Kroah-Hartmaneven said he thought the increasein patch submissions might be anintentional denial-of-service attack,designed to interfere with the abilityof the kernel developers to keepdeveloping. Thomas didn’t think thiswas likely, but he did point out thata number of companies assessedthe performance of their kernelhackingemployees by the numberof patches accepted into the kernel,or the total number of lines of codegoing into the tree. He speculatedthat this type of performanceevaluation, implemented bycompanies around the world, mightaccount for the DoS-seeming natureof the situation.Thomas Gleixner pointed outthat there was a problem withkernel code maintainers whopushed their own agendas tooaggressively and ignored theircritics just because they couldget away with it. Greg Kroah-Hartman agreed that this was atough problem to solve, but headded that in the past, problemmaintainers seemed to go awayon their own after a while. AlanCox said that in his opinion,maintainers who seemed to bepushing their own agendas werereally just doing developmentthe way they thought it shouldbe done, which was what amaintainer should be doing.But, Alan did agree thatmaintainers sometimes were lax onthe job, because of having childrenor illnesses or paid employmentin other fields. He suggested thathaving co-maintainers for any givenarea of code might be a good wayto take up some of the slack.Another idea, from TrondMyklebust, was to encouragemaintainers to insist on having atleast one “Reviewed-By” tag on eachpatch submission coming in, so thatanyone sending in a patch would besure to run it by at least one otherperson first. That, he said, could havethe effect of reducing the number ofbad patches coming in and easing theload on some of the maintainers.—ZACK BROWNWWW.LINUXJOURNAL.COM / SEPTEMBER <strong>2012</strong> / 19


[ UPFRONT ]Steam,Now withLess Wine!If you’ve everrun ValveSoftware’sSteam clienton your <strong>Linux</strong>box usingWine, youknow thateven if youpretend itworks well,it really doesn’t. Wouldn’t it be great if Valvefinally would release a native client for <strong>Linux</strong>?Thankfully, Valve agrees! On a recent blog post(http://blogs.valvesoftware.com/linux/steamd-penguins), the Valve folks verify thatthey’re creating a native Ubuntu 12.04 Steamclient. It’s bad news for zombies, however,because the first game they’re porting to thepenguin platform is Left 4 Dead 2.Granted, the Steam client alone doesn’tmean the <strong>Linux</strong> game library will explodeovernight, but it does mean game developerswill have one more reason to take <strong>Linux</strong> usersseriously. There have been rumors of Steamfor <strong>Linux</strong> for years, but this time, it looks likeit really will happen! Stay tuned to the Valveblog for more details.—SHAWN POWERSThey Said ItI don’t believe in e-mail.I rarely use a cell phoneand I don’t have a fax.—Seth GreenI was just in the middleof singing a songabout how broke wewere and now my cellphone rings.—Joel MaddenTo be happy in thisworld, first you need acell phone and then youneed an airplane. Thenyou’re truly wireless.—Ted TurnerYou have to take intoaccount it was the cellphone that becamewhat the modern-dayconcept of a phone callis, and this is a devicethat’s attached toyour hip 24/7. Beforethat there was “leavea message” andbefore that there was“hopefully you’rehome”.—Giovanni RibisiYou want to see anangry person? Let mehear a cell phone go off.—Jim Lehrer20 / SEPTEMBER <strong>2012</strong> / WWW.LINUXJOURNAL.COM


[ UPFRONT ]the equivalent script commands.The first thing you will need to dois get your data into Extrema. Data isstored in variables and is referenced bythe variable’s name. The first character ofa variable name must be alphabetic andcannot be any longer than 32 characters.Other than these restrictions, variablenames can contain any alphabetic ornumeric characters, underscores ordollar signs. Unlike most things in <strong>Linux</strong>,variable names are case-insensitive. Andremember, function names are reserved,so you can’t use them as variable names.String variables can contain either asingle string of text or an array of textstrings. Numeric variables can containa single number, a vector (1-D array), amatrix (2-D array) or a tensor (3-D array).All numbers are stored as double-precisionreal values. Unlike most other programminglanguages, these arrays are indexed startingat 1, rather than 0. There are no limitsto the size of these arrays, other thanthe amount of memory available on yourmachine. Indexing arrays in Extrema can beinteresting. If you want the eighth elementof array x, you simply can reference it withx[8]. You can grab elements 8, 9 and10 with x[8:10]. These indices can bereplaced with expressions, so you couldget the eighth element with x[2^3].There also are special characters thatyou can use in indexing arrays. Thestatement x[*] refers to all the values inthe vector. If you want the last element,you can use x[#]. The second-to-lastelement can be referenced with x[#-1].You likely have all of your data stored infiles. The simplest file format is a commaseparatedlist of values. Extrema can readin these types of files and store the datadirectly into a set of variables. If you have afile with two columns of data, you can loadthem into two variables with the statement:READ file1.dat x yYou also can read in all of the data andstore it into a single matrix with:READ\matrix file1.dat m nrowsIn order to do this, you need to providethe number of rows that are being readin. You also can generate data to be usedin your analysis. If you simply need aseries of numbers, you can use:x = [startval:stopval:stepsize]This will give you an array of numbersstarting at startval, incrementing bystepsize until you reach stopval.You can use the GENERATE command todo this as well. The GENERATE commandalso will generate an array of randomnumbers with:GENERATE\RANDOM x min max num_points24 / SEPTEMBER <strong>2012</strong> / WWW.LINUXJOURNAL.COM


[ UPFRONT ]Figure 3. Plotting a Vector of ValuesExtrema has all of the standardfunctions available, like the various typesof trigonometric functions. The standardarithmetic operators are:n + — additionn ^ — exponentiationn () — grouping of termsThere also are special operators formatrix and vector operations:n - — subtractionn >< — outer productn * — multiplicationn — inner productn / — divisionn


[ UPFRONT ]Figure 4. Graphing a Parametric Plotn >- — matrix reflectn /| — vector unionn /& — vector intersectionThere also is a full complement oflogical Boolean operators that give true(1) or false (0) results.Now that you have your data andhave seen some of the basic functionsand operators available, let’s take a lookat graphing this data and doing someanalysis on it. The most basic type ofgraph is plotting a one-dimensional array.When you do this, Extrema treats the dataas the y value and the array index as the xvalue. To see this in action, you can use:x = [1:10:1]GRAPH xThis plots a fairly uninteresting straightline (Figure 3).26 / SEPTEMBER <strong>2012</strong> / WWW.LINUXJOURNAL.COM


[ UPFRONT ]to get a nice plot. Many options areavailable for the graph command (Figure 5).More complicated data can be graphedin three dimensions. There are severaltypes of 3-D graphs, including contourplots and surface plots. The simplest datastructure would be a matrix, where theindices represent the x and y values, andthe actual numbers in the matrix are thez values. If this doesn’t work, you canrepresent the separate x, y and z valueswith three different vectors, all of thesame length. The most basic contourgraph can be made with the command:CONTOUR mwhere m is the matrix of values to begraphed. In this case, Extrema will makea selection of “nice” contour lines thatcreate a reasonable graph.You can draw a density plot of thesame data with the density command,where the values in your matrix areassigned a color from a color map, andthat is what gets graphed. Unless you saydifferently, Extrema will try to select acolor map that fits your data the best. Asurface plot tries to draw a surface in theproper perspective to show what surfaceis defined by the z values in your data.Let’s finish by looking at one of the moreimportant analysis steps, fitting an equationto your data. The point of much of scienceis to develop equations that describe thedata being observed, in the hope thatyou then will be able to predict what youwould see under different conditions. Also,you may learn some important underlyingphysics by looking at the structure of theequation that fits your data. Let’s look at asimple fitting of a straight line. Let’s assumethat the data is stored in two vectors calledx and y. You’ll also need two other variablesto store the slope and intercept. Let’s callthem b and a. Then you can fit your datawith the command:SCALAR\FIT a bFIT y=a+b*xThen, if you want to graph yourstraight line fit and your data, you cando something like:SET PLOTSYMBOL -1SET PLOTSYMBOLCOLOR REDGRAPH x ySET PLOTSYMBOL 0SET CURVECOLOR BLUEGRAPH x a+b*xNow that you have seen the basics ofwhat Extrema can do, hopefully you willbe inspired to explore it further. It shouldbe able to meet most of your data-analysisneeds, and you can have fun using thesame tool that is being used by leadingparticle physicists.—JOEY BERNARD28 / SEPTEMBER <strong>2012</strong> / WWW.LINUXJOURNAL.COM


[ EDITORS' CHOICE ]There’s anApp for ThatEDITORS’CHOICE★The conceptof standaloneWeb apps isn’tnew. Anyoneusing Prismwith Firefox orFluid with OSX understandsthe concept:a browserthat goes to asingle Web siteand acts likea standaloneapplication—sorta.With Fogger,however, Webapplicationstake on awhole newmeaning. Using a variety of desktop APIs and user scripts, applicationscreated with the Fogger framework integrate into the <strong>Linux</strong> desktopvery much like a traditional application. If you’ve ever found Webapps to be lacking, take a look at Fogger; it makes the Web a littleeasier to see: https://launchpad.net/fogger.—SHAWN POWERS30 / SEPTEMBER <strong>2012</strong> / WWW.LINUXJOURNAL.COM


MatCh your SErVErto your BuSInESS.only pay for what you nEED!with a 1&1 Dynamic Cloud Server, you canchange your server configuration in real time.n Independently configure CPU, RAM, and storagen Control costs with pay-per-configuration and hourly billingn Up to 6 Cores, 24 GB RAM, 800 GB storagen 2000 GB of traffic included freen Parallels ® Plesk Panel 10 for unlimited domains, reseller readyn Up to 99 virtual machines with different configurations1&1 DynaMIC ClouD SErVErSaVE $180$34.99/ month first year, baseconfiguration only (regularly $49.99).n nEw: Monitor and manage your cloudserver through 1&1 mobile apps for Android and iPhone ® .®www.1and1.com* Offer valid for a limited time only. First year $34.99/ month only applies to base configuration. Base configuration includes 1 processor core, 1 GB RAM, 100 GB Storage. Other terms andconditions may apply. Visit www.1and1.com for full promotional offer details. Program and pricing specifications and availability subject to change without notice. 1&1 and the 1&1 logoare trademarks of 1&1 Internet, all other trademarks are the property of their respective owners. © <strong>2012</strong> 1&1 Internet. All rights reserved.


COLUMNSAT THE FORGEPL/RREUVEN M.LERNERPerform powerful statistical analysis by embeddingthe R language in PostgreSQL.I took two introductory statisticsclasses in graduate school and foundthat I really liked the subject. It wasn’talways intuitive, but it always wasinteresting, and it really helped meto put research, polling and manynewspaper stories in a new light. I don’tdo statistical analysis every day, butit’s a powerful tool for organizing andworking with large sets of data, and forfinding correlations among seeminglydisparate pieces of information.For the courses I took, my universitytold me to buy SPSS, a commercialprogram that helps you performstatistical calculations. Being an opensourcekind of guy, I discovered R—aprogramming language aimed athelping people solve problems involvingcalculations and statistics. R is a fullfledgedlanguage, and it theoretically canbe used in a wide variety of situations.But, it was designed primarily for use inmathematics and statistical work, andthat’s where it really shines.I managed to get through the classjust fine using R instead of SPSS. Thequality of R’s documentation and theintuitive feel of the language, especiallyfor someone experienced with Ruby andPython, meant that when my instructorsdemonstrated how to do something inSPSS, I managed to find the appropriateparallel in R, and even get a result beforethey had finished their explanation.I have continued to use R during thepast few years, both as I’ve progressedwith my dissertation research and evenon some client projects. I’ve used R toanalyze data from text files (typically inCSV format), and I’ve used R to analyzedata from databases, using the clientpackages available for various databases.Perhaps the most intriguing place I’verecently seen R, and where I’ve startedto experiment with it in my own work,is inside PostgreSQL. PostgreSQL, longmy favorite relational database, has formany years allowed for the creation ofuser-defined functions, similar to “storedprocedures” in other databases. Whereasmost databases provide a single languagein which people can write their functions,PostgreSQL makes it possible to connect32 / SEPTEMBER <strong>2012</strong> / WWW.LINUXJOURNAL.COM


COLUMNSAT THE FORGEIf you ever have used R, the possibility of using sucha powerful statistics package inside your databaseshould seem like a natural and powerful combination.nearly any language to the database. Bydefault, PostgreSQL lets you write serversidefunctions in Pl/PgSQL, and there longhas been support for Pl/Perl and Pl/Python.Since 2003, developer Joe Conwayhas maintained PL/R, allowing you towrite server-side functions in PostgreSQL,using R. If you ever have used R, thepossibility of using such a powerfulstatistics package inside your databaseshould seem like a natural and powerfulcombination. Rather than having to readthe data into R outside PostgreSQL, yousuddenly can have R work directly on theresults of queries, without needing to usea separate client application or process.In this article, I introduce the basicsof PL/R. This combination isn’t foreveryone, but with the growing (andwelcome) popularity of PostgreSQLamong Web developers, and withthe increasing need for analysis ofinformation gathered from Web users,it seems to me that PL/R could be animportant tool for many developers.Introduction to RThe home page for R is http://r-project.org.From that site, you can download versionsof R for a variety of operating systems,including <strong>Linux</strong>. (I was able to installR on my server running Ubuntu withapt-get install r-base-core,which installed a large number ofdependent packages.) New versionsof R come out every few months andnormally are installed in two versions:the R language and environment and theruntime necessary to execute programswritten in R, known as “Rscript”. To usethe language interactively, just type R atthe shell prompt.R is an interpreted, dynamiclanguage. It has some object-orientedfeatures as well. At the core of R is thevector data type, which can containany number of elements of the sametype (known as “mode” within R). Evenitems that are seemingly scalar valuesactually are vectors of length 1. Thus,you don’t really have integers in R,but rather one-element vectors of typeinteger. You can create multi-elementvectors with the c() function, handing itthe values you would like it to contain:> c(1,5,9,3)[1] 1 5 9 3WWW.LINUXJOURNAL.COM / SEPTEMBER <strong>2012</strong> / 33


COLUMNSAT THE FORGEThe beauty of a vector is that mathematicaloperators are applied to all of its elements.This returns a vector, but now thevalue is lost. If you want to capture it,you must do so in a variable, using theassignment operator x y y[1] 8.6 43.0 77.4 25.8If you’re wondering what the [1]> x x[1] "1" "2" "abc" "3"notice how all the values in this vectorhave been turned into strings, in orderto ensure that the vector’s mode is oftype “character”.34 / SEPTEMBER <strong>2012</strong> / WWW.LINUXJOURNAL.COM


COLUMNSAT THE FORGER allows you to create multidimensionalvectors, known as matrices. To create amatrix, just invoke the matrix() function,giving it a vector as a first parameterand either the nrow parameter or thencol parameter:> scores height d dnames scores height1 tom 90 1802 dick 60 160> m m[,1] [,2] [,3][1,] 1 3 5[2,] 2 4 6If you want to grab the first column—avector, of course—you can do so:> m[,1][1] 1 2You also can grab the second row:> m[2,][1] 2 4 6Similar to a matrix, but containingvectors of different types, is a “dataframe”. When you create a dataframe, you assign a name (given asthe parameter name) to a vector. Thevectors then are displayed in parallel,such that index 2 in each vector can beread across, much like a spreadsheet ordatabase table. For example:> names


COLUMNSAT THE FORGEinvolves understanding what sorts ofsocial networks were created amongusers of the software I created; using aCRAN project called statnet, such analysisbecomes relatively easy to do.Installing PL/RInstalling PL/R is possibly the hardestpart of working with PL/R, although ithas gotten significantly easier since thecreation of the “extension” system inPostgreSQL. First, make sure you haveinstalled the latest versions of both Rand PostgreSQL. Earlier versions willwork, but particularly in the case ofPostgreSQL, a modern version will bebetter, thanks to the extension system.I assume in this article that you areusing PostgreSQL 9.1.Now, you need to set the R_HOMEenvironment variable. This variable willtell the PL/R compilation and extensionmechanism where to find R’s headerand library files. On my Ubuntu server,after installing R via apt-get, I setR_HOME to /usr/share/R:export R_HOME=/usr/share/ROnce you’ve set that up, you candownload the PL/R source code. At thetime of this writing, the latest version is8.3.0 and is available from the PL/R homepage. Then, as the instructions indicate,go into the plr directory that results fromopening the .tar.gz, and type:USE_PGXS=1 makeUSE_PGXS=1 make installNote that this doesn’t install PL/Rinto any of your PostgreSQL databases.Rather, it makes the PL/R extensionavailable, such that you then can createthe PL/R extension inside any databasethat would like to benefit from it.After installing the extension, I wentinto my personal PostgreSQL databaseSystem on ModuleNew - SoM-3517ŸTI ARM Cortex-A8 600 MHZ Fanless ProcessorŸUp to 512 MB of DDR2 SDRAMŸUp to 1GB of NAND FlashŸUp to 2GB of eMMC FlashŸ2 High Speed USB 1.1/2.0 Host portsŸ1 High Speed USB 2.0 OTG portŸ4 Serial Ports, 2 I2C and 2 SPI portsŸProcessor Bus ExpansionŸ10/100 BaseT Fast EthernetŸCAN 2.0 B ControllerŸNeon Vector Floating Point UnitŸ24-bit DSTN/TFT LCD InterfaceŸ2D/3D Accelerated Video w/ Resistive TouchŸSmall, 200 pin SODIMM form factor (2.66 x 2.375”)2.6 KERNELThe SoM-3517 uses the same small SODIMM form-factor utilized by otherEMAC SoM modules and is the ideal processor engine for your next design. All ofthe ARM processor core is included on this tiny board including: Flash, Memory,Serial Ports, Ethernet, SPI, I2C, I2S Audio, CAN 2.0B, PWMs, Timer/Counters,A/D, <strong>Digital</strong> I/O lines, Video, Clock/Calendar, and more. The SoM-3517Madditionally provides a math coprocessor, and 2D/3D accelerated video withimage scaling/rotation. Like other modules in EMAC's SoM product line, theSoM-3517 is designed to plug into a custom or off-the-shelf Carrier boardcontaining all the connectors and any additional I/O components that may berequired. The SoM approach provides the flexibility of a fully customized productat a greatly reduced cost. Contact EMAC for pricing & further information.http://www.emacinc.com/som/som3517.htmSince 1985OVER27YEARS OFSINGLE BOARDSOLUTIONSEQUIPMENT MONITOR AND CONTROLPhone: ( 618) 529-4525 · Fax: (618) 457-0110 · Web: www.emacinc.comWWW.LINUXJOURNAL.COM / SEPTEMBER <strong>2012</strong> / 37


COLUMNSWORK THE SHELLDAVE TAYLORBash NotationalShortcuts:Efficiency overClarityAre shell scripts inevitably antiquated? Is Dave writing Bourneshell scripts for UNIX, not even writing about <strong>Linux</strong>? Read onto find out about his latest letter from a reader and subsequentexplanation of his philosophy of writing scripts for publication.I get letters. Well, I don’t get verymany letters, truth be told, but I dooccasionally get interesting dispatchesfrom the field, and a recent one took meto task for writing about UNIX, not <strong>Linux</strong>,and for focusing on the Bourne shell, notBash. Which is odd.When you’re on the command lineor writing a shell script, things arepretty darn similar across <strong>Linux</strong> andUNIX due to the POSIX standard thatdefines syntax, notational conventionsand so on. And in terms of the wealthof commands available? My experienceis that if you rely on “nonstandard”<strong>Linux</strong> commands like some of the moresophisticatedGNU utilities, you mightfind yourself in a right pickle whenonly the more lobotomized versions areavailable on a job site or with particularhardware that, yes, might be running aflavor of UNIX. It happens.Same with Bash versus Bourne shell.Although because I do write aboutshell functions and various other moreadvancedfeatures, and because I never40 / SEPTEMBER <strong>2012</strong> / WWW.LINUXJOURNAL.COM


COLUMNSWORK THE SHELLWhen a script or program looks like yourcat ran across the keyboard, it might be veryefficient, but it’s sure hard to debug later,even if it’s your own code.test the scripts in this column againstBourne Shell (not being Jason, afterall), and well, just because I’m notusing your favorite Bash features andshortcuts, that doesn’t mean I’m usingthat “other” shell, does it?The most valuable part in the letterwas to remind me that there are someslick notational conventions that areadded to modern Bash shells thatcan clean up some of our conditionalstatements and structures. It was agood reminder—old dog, new tricks,and all that. Let’s have a look.Shortening Conditional TestsOne of the first programming languagesI learned was APL. You probablyhaven’t even heard of it, but it wasa remarkably powerful languagecharacterized by lots of specialnotations that gave you the ability toproduce sophisticated results in justa line or two. The problem was, noone could debug it, and the commonbelief was that it was faster to rewritea program than to figure out whatanother programmer was thinking.This recurred the first time I lookedat Perl, and I even said so to Larry Wallwhen we bumped into each other yearsago. When a script or program lookslike your cat ran across the keyboard,it might be very efficient, but it’s surehard to debug later, even if it’s yourown code.And onward to <strong>Linux</strong>. When workingon shell scripts, you’re used toseeing single brackets for conditionalexpressions, like this:if [ -n $value ] ; thenWhat I haven’t explained is that everytime you write a conditional in this form,it actually invokes a subshell process tosolve the equation. Write it with doublebrackets, however:if [[ -n $value ]] ; thenand you’ll force the test to remainwithin the shell itself, which will makeyour scripts faster and more efficient.WWW.LINUXJOURNAL.COM / SEPTEMBER <strong>2012</strong> / 41


COLUMNSWORK THE SHELLThere’s also some benefit in termsof strict quoting of arguments inexpressions too, because they don’thave to be handed to a subshell, youcan often get away with sloppierquoting using the [[ ]] notation.The question is, how much faster isit, and is it worth making your scriptsjust a bit more obfuscated, particularlyfor us old dogs who are used to the[ ] notation? On the vast majority ofsystems, in the vast majority of cases,I don’t think it speeds things up muchat all. By their very nature, shell scriptsaren’t written to be maximally efficient.If you need lightning performance,there are better—albeit morecomplicated—languages you can use,like C++ or even Perl. Just keep yourcat away from the keyboard.The same goes for another notationalconvention that I eschew in the interestof writing maximally clear and readablescript code. It turns out that a conditionalstatement like:if [ -n $value ] ; thenecho value $value is non-zerofialso can be written more succinctly as:[ -n $value ] && echo value $value is non-zeroprevious command had a ’true’ exitstatus, do the next one” and || meansthe opposite, as in:[ -n $value ] || echo value $value has a length of zeroMore efficient? Certainly if we use[[ ]] instead of the single bracketswe have now, but is it worth theobfuscation? Perhaps in code that you’redelivering to a client or that you arewriting as a fast throwaway script for aspecific task, but the code I publish hereneeds to be easily understood. Then weweave in efficiency.To get a sense of how long I’vebeen chewing on how to write legible,easily understood code, I’ll just saythat when I first started coding inFortran-77, I loved that you could havespaces in variable and function names,letting me write code that was evenmore like an algorithm instead of acomplicated program.Variable Expansion TricksSpeaking of tricks and cats runningacross keyboards, I’ve also avoidedsome of the really complicated ${}notational options in the interestof having my scripts be as widelyportable as possible. For example, Itend to write:In this situation, && means “if thelength=$(echo $word | wc -c) ; length=$(( $length - 1 ))42 / SEPTEMBER <strong>2012</strong> / WWW.LINUXJOURNAL.COM


COLUMNSWORK THE SHELLIndeed, across all of these shortcuts and moderntweaks to the Bash shell, which are better?It’s clunky and admittedly inefficient.A smarter way to do it is:Or, a slight variation that taps intothe modern


COLUMNSHACK AND /Troubleshootingwith TelnetKYLE RANKINDust off that telnet command and communicate with a serverwith raw plain-text commands—it’s good for the soul.Poor telnet, it used to be the coolkid on the block. It was the programall sysadmins turned to when theyneeded to connect to a remote server.Telnet just wasn’t that good at keepinga secret—all communication went overplain text—so administrators startedswitching to SSH for encrypted remoteshell sessions. Of course, along withthe switch came a huge stigma againstadministrators who still used telnet.Eventually, telnet became an outcast—the program you used if you were anout-of-touch old-timer who didn’t careabout security.I for one think telnet isn’t all bad.Sure, it can’t keep a secret, but it stillcan do a lot of useful things around theserver room. Really, telnet just providesyou a convenient way to connect to anetwork port and send commands. Telnetcan work well to diagnose problemswith one of the many services out therethat still accept plain-text commandsin their protocol. In fact, it’s one of mygo-to command-line programs whenI’m troubleshooting. In this column, I’mgoing to give telnet a second chance anddescribe how to use it to perform somecommon troubleshooting tasks.Test Remote PortsThere are many different ways to testwhether a network port is listening ona system, including GUI port scanners,Nmap and nc. Although all of thosecan work well, and even I find myselfusing Nmap more often than not, not allmachines end up having Nmap installed.Just about every system includes telnetthough, including a lot of embeddedsystems with BusyBox environments. So ifI wanted to test whether the SMTP port(port 25) was listening on a server with44 / SEPTEMBER <strong>2012</strong> / WWW.LINUXJOURNAL.COM


COLUMNSHACK AND /with the actual HTML content:HTTP/1.1 200 OKDate: Tue, 10 Jul <strong>2012</strong> 04:54:04 GMTServer: Apache/2.2.14 (Ubuntu)Last-Modified: Mon, 24 May 2010 21:33:10 GMTETag: "38111c-b1-4875dc9938880"Accept-Ranges: bytesContent-Length: 177Vary: Accept-EncodingContent-Type: text/htmlX-Pad: avoid browser bugIt works!much simpler to use a command-line toollike curl, or I guess if you have to, even aregular GUI Web browser.Send an E-mailAlthough I just use telnet for basic Webserver troubleshooting, telnet endsup being my preferred tool for e-mailtroubleshooting, mostly because it’s sosimple to send a complete e-mail withonly a few telnet commands.The first step is to initiate a telnetconnection with the mail server you wantto test on port 25:This is the default web page for this server.The web server software is running but no contenthas been added, yet.As you can see from my output, this isjust the default Apache Web server page,but in this case, the HTML output is onlyone part of the equation. Equally useful inthis output are all of the headers you getback from the HTTP/1.1 200 OK replycode to the modification dates on the Webpage, to the Apache server version. Afteryou are done sending commands, just pressCtrl-] and Enter to get back to a telnetprompt, then type quit to exit telnet.I usually just use telnet to do somebasic HTTP troubleshooting, because onceyou get into the realm of authentication,following redirects and other morecomplicatedparts of the protocol, it’s$ telnet mail.example.net 25Trying 192.168.5.5...Connected to mail.example.net.Escape character is '^]'.220 mail.example.net ESMTP PostfixUnlike the blank prompt you may getwhen you connect to an HTTP server,with SMTP, you should get an immediatereply back. In this case, the reply is tellingme I’m connecting to a Postfix server.Once I get that 220 prompt, I can starttyping SMTP commands, starting with theHELO command that lets me tell the mailserver what server is connecting to it:HELO lappy486.example.net250 mail.example.netThe nice thing about the interactive SMTP46 / SEPTEMBER <strong>2012</strong> / WWW.LINUXJOURNAL.COM


The Most ConvenientWay to Learn Drupal!Have hundreds of hours of Drupaltraining right at your fingertips with theDrupalize.Me app. Learn while you’re onthe bus, in line at the bank, on the couch,or anywhere! New videos are beingadded every week to help you stay up todate on the latest Drupal knowledge.Learn about our latest video releasesand offers first by following us onFacebook and Twitter (@drupalizeme)!Go to http://drupalize.me andget Drupalized today!


COLUMNSHACK AND /connection here is that if I do somehowmake a typo in a command or make amistake, it should let me know; otherwise, Ishould get a 250 reply. After HELO, you usethe MAIL FROM: command to list whate-mail address the e-mail should appear tobe from. I say “appear to be from”, becauseyou can put just about any e-mail addressyou want here, which is a good reason notto blindly trust FROM addresses:MAIL FROM: 250 OkIn the past, I used to type in the e-mailaddress directly without surrounding it with. My personal Postfix servers are fine withthis, but other mail servers are more strictand will reply with a syntax error if youdon’t surround the e-mail address with .Since this FROM address was accepted, youcan follow up with RCPT TO: and specifywho the e-mail is addressed to:RCPT TO: 250 OkThe fact that the mail server respondedwith 250 should mean that it acceptedthe TO address you specified here. Finally,you can type DATA and type the rest ofyour e-mail, including any extra headersyou want to add, like Subject, then finishup with a single period on its own line:DATA354 End data with .Subject: Give Telnet a Chance 1Hi,All we are saying is give telnet a chance..250 Ok: queued as 52A1EE3D117When I’m testing e-mails with telnet, Iusually put a number in the subject lineso I can continually increment it with eachtest. This way, if some e-mail messagesdon’t get delivered, I can tell which oneswent through and which ones didn’t.Once you are done with the DATAsection and the e-mail is queued, you cantype quit to exit:quit<strong>221</strong> ByeConnection closed by foreign host.Now that you have some ways totroubleshoot with telnet, hopefully youwon’t relegate telnet to the junk drawer ofyour <strong>Linux</strong> systems. Sure, you may not wantto use it for remote shells, but now that justabout everyone uses SSH anyway, maybeyou can break out telnet on your terminalfor all of your other plain-text networkneeds without your friends scolding you.■Kyle Rankin is a Sr. Systems Administrator in the San FranciscoBay Area and the author of a number of books, including TheOfficial Ubuntu Server Book, Knoppix Hacks and Ubuntu Hacks. Heis currently the president of the North Bay <strong>Linux</strong> Users’ Group.48 / SEPTEMBER <strong>2012</strong> / WWW.LINUXJOURNAL.COM


<strong>2012</strong>9th AnnualHigh Performance ComputingFor Wall Street<strong>September</strong> 19, <strong>2012</strong> (Weds) Roosevelt Hotel, NYCMadison Ave and 45th St, next to Grand Central StationHigh Performance Computing, Cloud,Big Data, Low Latency, Network Systems,Data Centers, Optimization, <strong>Linux</strong>, Speedand Cost Savings. All-in-One.Join the new speakers announced and their programs covering HPC, Big Data,Cloud, Data Centers, Networks, Switches, Optimization, <strong>Linux</strong>, Speed and CostSavings. All-in-one in New York City.Wall Street and the global financial markets will be coming to theRoosevelt for the largest meeting of HPC in New York.Come to this convenient one-day meeting place. Network with your friends.See and hear the latest systems to reduce cost, increase speed and productivity.Transformation is what Wall Street IT is all about. Wall Street is constantlymoving towards zero latency, zero net gain, and faster moving parts with less staff.Save $100. Advance registration $295. $395 onsite. Conference includesgeneral sessions, drill down sessions, the exhibits, handouts, an industryluncheon, special sponsor functions.Don't have time for the Conference? Register for the freeShow from 8 am-4 pm, but you must go online.Exhibit and Sponsor information from Flagg Management:www.flaggmgmt.com/hpcPlatinum SponsorJan Mark HolzerSr Consulting EngineerRed HatCiscoKeynoteSpeaker 9amPaul PerezChief Technology OfficerData Center GroupCiscoBob GainesSenior Sales DirectorDataDirect NetworksTom Steinert-ThrelkeldEditor-in-Chief, SecuritiesTechnology MonitorJeffrey M. BirnbaumFounder, CEO60East TechnologiesDino Vitale (invited)Director, Morgan StanleyCross Technology Svcs.Joseph CurleyDir. TechnicalComputing Mktg, IntelPartial list of speakers 7/27/12Antonio Hallak, HeadGLL Electronic TradingEngineering, CreditSuisse Securities (USA)Dave WeberIBM Global Prog Exec,Wall St Ctr for ExcellenceNan BodenCEOMyricomGold SponsorsNick Werstiuk, IBM Corp.Product MgmtPlatform ComputingRaymond RussellCTO, Co-FounderCorvilThomas IsakovichCEONimbus DataGeoffrey NoerSr. Director Product MktgPanasasPat GreeneSolution ArchitectHewlett PackardNikita IvanovCEOGridGain SystemsVikram MehtaVP System NetworkingIBM CorporationEmile Werr, VP & Headof Enterprise ArchitectureNYSE EuoronextShow & Conference:Flagg Management Inc353 Lexington AvenueNew York 10016(212) 286 0333fax: (212) 286 0086flaggmgmt@msn.comShow Hrs: Wed, Sep 19 8:00-4:00Conference Hrs: 8:30-4:50Nick WerstiukProduct MgmtPlatform ComputingAnshul SadanaSVP of CustomerEngineeringArista NetworkJason StoweCEOCycle ComputingAlex Tabb, PartnerCrisis & Continuity SvcsTabb Groupwww.flaggmgmt.com/hpc


COLUMNSTHE OPEN-SOURCE CLASSROOMA Domain byAny Other Name...SHAWN POWERSDon’t let DNS get you into a BIND; read on to sort out port 53.In this article, I cover DNS, arguablythe most “Rube Goldberg” of allservices. (Well, except for Sendmail, butthat’s really just one application, notan entire service.) DNS (Domain NameServices) quite simply maps domainnames to IP addresses. For some reason,it’s easier for humans to rememberwords than strings of numbers, sorather than remembering 12.34.56.78,we remember www.linuxjournal.com.Using DNS instead of rememberingIP addresses not only helps prove<strong>Linux</strong> users aren’t really cyborgs, italso allows some pretty cool magic inthe server department. Instead of oneserver per Web site, a single server witha single IP address can host multipleWeb sites. Unfortunately, the way DNSworks on a global scale means it’s notwithout its faults and frustrations. G.I.Joe always said, “knowing is half thebattle”, so in this article, I walk youthrough being a knowledgeable DNSuser, without ever delving into thecomplexities of the underlying system.The Un-DNSFor most <strong>Linux</strong> distributions, you configure“how” the computer looks up URLs bysetting the options in /etc/nsswitch.conf.If you look at your nsswitch.conf file,you’ll probably find the line:hosts: files dnsThis line tells the computer that beforeit asks its DNS server for the IP address,it should look into its /etc/hosts file for adomain mapping. By default, there probablyis a line defining the localhost addressand possibly an entry defining whateverhostname and IP you set for the computer.This file has the following format:# IP Address Domain Name127.0.0.1 localhost192.168.1.1 router192.168.1.10 homeserver192.168.1.20 xbmc50 / SEPTEMBER <strong>2012</strong> / WWW.LINUXJOURNAL.COM


COLUMNSTHE OPEN-SOURCE CLASSROOMUsing DNS instead of remembering IP addressesnot only helps prove <strong>Linux</strong> users aren’t reallycyborgs, it also allows some pretty cool magicin the server department.Once entered into the file, you canuse the names defined in place ofan IP address. This is truly domainname resolution in its simplest form.If you need only to map an addressfor your local computer, this is theideal way to configure your computer.Keep in mind that the order specifiedin nsswitch.conf is the order yourcomputer will search, so if you put anentry like this:Then, when the user tries to accessFacebook, it will fail. Note that this isnot a foolproof way to block Internetsites, but it works in most situations. Thismethod often is used to block ads onWeb pages. It’s possible to find a list ofad servers and then put the list into your/etc/hosts file. Again, it’s not foolproof,but the logic is sound. The hosts file isalso useful for other purposes too, whichI’ll come back to later.192.168.1.20 www.google.comit won’t ever look up the proper addressfor Google. It will query the server at192.168.1.20 as if it were www.google.com.This is a feature rather than a bug.Although it certainly allows for someeasy pranking (you didn’t hear thatfrom me), it also can be used to blockspecific sites. If you wanted to blockFacebook on your home computer, forexample, you could add:127.0.0.1 www.facebook.comDNSMasq—the Super Simple ServerIf you’re using an off-the-shelf routerfor your home network, chancesare it’s running DNSMasq as a DNSserver. DNSMasq is a DNS forwarderthat queries a remote DNS serverand returns the value to the clientrequesting the information. It has thehandy feature of querying the router’s/etc/hosts file first, and most routershave a way to add DNS entries. It’snot always simple, like the case ofDD-WRT. In order to add an addressto the DNSMasq server on DD-WRT,you need to add lines to the DNSMasqWWW.LINUXJOURNAL.COM / SEPTEMBER <strong>2012</strong> / 51


COLUMNSTHE OPEN-SOURCE CLASSROOMconfig section like this:address=/homeserver/192.168.1.10address=/xbmc/192.168.1.20See Figure 1 for a DD-WRTscreenshot. By adding addresses toyour router’s DNSMasq server, youeffectively can make an /etc/hosts filefor every computer on your network.DNSMasq also is tied into the DHCPserver, allowing for automatic mappingof hostnames to DHCP assignments,but that’s a bit outside the scope ofthis column.Getting into a BINDWhen it comes to DNS on the greaterInternet, BIND is the de facto standardserver. Unfortunately, BIND also iswhere the vast complexities of theDomain Naming System come into play.Don’t get me wrong, the complexitiesaren’t frivolous, just frustrating attimes. If you are managing a DNS serverfor a business, chances are you need towork with BIND. Because BIND supportsevery facet of the DNS concept, I thinkit’s important for a little terminologylesson before we dig into configuration.See the sidebar for some DNS terms youshould be familiar with before delvinginto BIND configuration.First off, if you’re going to configureBIND, I recommend using a tool likeWebmin for your first time. There aresome quirks when you edit the BINDconfiguration file that aren’t apparentat first. For example, when you edit azone file (usually stored in /var/named),you need to increment the serialnumber at the top, or other serverswon’t see your information as themost recent.Assuming your zone files arecreated, it’s fairly easy to see how toadd or modify records. The only thingI’ll specifically mention here aboutthe zone file is the TTL setting. Thissetting tells clients how many secondsFigure 1. DD-WRT allows you to add DNS entries, but it’s not terribly user-friendly.52 / SEPTEMBER <strong>2012</strong> / WWW.LINUXJOURNAL.COM


COLUMNSTHE OPEN-SOURCE CLASSROOMCommon DNS Termsn A Record (Address Record): this type ofrecord directly maps a name to an IP address.Originally, no two A Records were supposedto point to the same IP address. (This is nolonger practical, but is considered “bestpractice” where appropriate.)n Authoritative: a server is consideredauthoritative when it is hosting the domainin question itself rather than queryinganother server for the information. A serveris considered authoritative by domain; it’snot a boolean server setting like with DHCP.The same server can be authoritative for onedomain, and not for another.n BIND (Berkeley Internet Name Domain):the most common DNS server on the Internet.n Caching (or Namecaching): locallystored copy of name resolution from anauthoritative DNS server. The cachingduration is based on the TTL settings fromthe authoritative server (see TTL below).n CNAME (Canonical Name Record): thiscreates an alias to another DNS entry thatinherits the properties of the original.n Forward Zone: a “zone” is used to definethe section of DNS space where a server isresponsible for mapping names to IP addresses.n Reverse Zone: a DNS server also can supplyreverse lookups, mapping names to queriedIP addresses. This often is used for securityto verify DNS information.n FQDN (Fully Qualified Domain Name):this is the entire DNS name, including aperiod at the end.n MX Record (Mail Exchange Record):this specifies a mail route for a particulardomain. Multiple MX Records are possible(and recommended!) with priority levels.n NS Record: declares what server serves a givenzone. This is where the server would declareitself authoritative for a particular zone.n PTR Record (Pointer Record): a PTR recordoften is called the reverse record, and itassociates an IP address with a domain name.n Propagation: the period of time betweenwhen a DNS change is made on theauthoritative server and the time all serverson the Internet have current information.This propagation time can be several hoursor several days depending on the TTLsettings for a particular record.n Root Server: there currently are 13 rootservers on the Internet, which host thetop-level domains. Through very complexrouting and redundancy, these servers areall over the globe and are placed with faulttolerance in mind.n SOA Record (Start of Authority Record):the first record in a zone file, containinginformation about the zone itself, includingwhether or not the server is authoritative.n SRV Record (Service Record): providesinformation about what services areavailable for a domain.n Top-Level Domain: any zone hosted bythe 13 root servers. These are domains likecom, edu, org, gov and country codes likeus, ca and uk.n TTL (Time To Live): this is a number setby the authoritative server for a domainthat tells DNS servers how long to cacheinformation before querying again.WWW.LINUXJOURNAL.COM / SEPTEMBER <strong>2012</strong> / 53


COLUMNSTHE OPEN-SOURCE CLASSROOM;; global options: +cmd;; Got answer:;; ->>HEADER


COLUMNSTHE OPEN-SOURCE CLASSROOMto map internal domain names to privateIPs. This is also useful if you want certaindomains (like intranet.example.com) toexist only inside your company and noteven resolve from the Internet.It’s important to note that this is ahack of the protocol and can have itsfailings too. In fact, some routers willdetect split DNS as a DNS-spoofingattack (which technically it is) and notallow you to use those false addresses.Virtual DomainsThis isn’t a hack at all, but rather afeature of most Web servers. Because thenumber of Web sites far surpasses thenumber of available IP addresses, Webservers now allow separate Web sitesusing the same IP address. For example,let’s say three friends share a server. TheDNS entries for their blogs might be:12.34.56.78 shawnblog.example.com12.34.56.78 julieblog.example.com12.34.56.78 frankblog.example.comYou’ll notice the three different domainsshare the same IP address. If you try toaccess http://12.34.56.78, the Web serverwon’t know whose blog you’re trying toaccess. By configuring virtual domains,however, the Web server running at12.34.56.78 can differentiate betweenthe blogs by which address you arequerying. So http://shawnblog.example.comwill get one Web site, andhttp://julieblog.example.com will getan entirely different one.This ability for DNS entries to sharea common IP address and Web serversto serve pages based on which domainname was requested has allowed forthe modern Internet to work. Withoutthat feature, shared hosting wouldn’tbe possible.Virtual Hosting for OneWhile Internet Web hosting relieson virtual hosts for most sites, aWeb developer or sysadmin oftencan become frustrated waiting forpropagation time when a DNS changeis made. Let’s say you’ve created afancy new Web site on a new Webserver, and you want to make sureit’s working once the DNS changepropagates through the Internet. SinceWeb servers reply based only on thedomain request they receive, until DNSpropagates, it’s impossible to makesure the new Web site is working.Thankfully, the Web server itselfdoesn’t do DNS lookups; it knows onlythe domain names it’s supposed torespond for. If you change your local/etc/hosts file with the new DNSinformation before you make the changeon the Internet, you can test your newserver using your local DNS information.In fact, without the ability to make thislocal bogus DNS change, testing yournew server would be close to impossible!56 / SEPTEMBER <strong>2012</strong> / WWW.LINUXJOURNAL.COM


NEW PRODUCTSThe <strong>Linux</strong> Professional Institute’s<strong>Linux</strong> Essentials ProgramWith youth unemployment around the world holding at crisis levels, the new <strong>Linux</strong>Essentials Program from the <strong>Linux</strong> Professional Institute (LPI) couldn’t come at a moreauspicious time. The new certification program, consisting of an exam and Certificateof Achievement, introduces new users and youth to <strong>Linux</strong> and open-source software.The program’s main topics include the <strong>Linux</strong> community, careers in open source,popular operating systems, important applications, licensing issues and the basics ofthe command line, files and scripts. Other program elements include regional linksto employment and apprenticeship programs; support for skills competitions, suchas Worldskills International; and support for teacher collaboration and sharing oflearning exercises. A “low-stakes” exam is available on-line either through the LPI orInternet-based testing via partners. <strong>Linux</strong> Essentials currently is available at select LPIaffiliate locations and IT events in Europe, the Middle East and Africa.http://www.lpi.org/linuxessentialsSara Baase’s A Gift of Fire,4th ed. (Prentice Hall)During its relatively brief history, our dynamic <strong>Linux</strong> community hashad an outsized interest in and influence on the public dialogueconcerning the role of technology in society. An outlet for us <strong>Linux</strong>ersto scratch our inner philosophical itch is to chew on the ideas foundin the new 4th edition of Sara Baase’s book A Gift of Fire: Social,Legal, and Ethical <strong>Issue</strong>s for Computing Technology. As indicated by the title, Baase’s workexplores the social, legal, philosophical, ethical, political, constitutional and economicimplications of computing and the controversies they raise. With a computer scientist’sperspective, and with historical context for many issues, Baase covers the issues we faceboth as members of a technological society and as professionals in computer-relatedfields. Baase’s primary goal is to encourage current and future computer professionalsto understand the implications of what they create and how it fits into society at large.http://www.informit.com58 / SEPTEMBER <strong>2012</strong> / WWW.LINUXJOURNAL.COM


NEW PRODUCTSBrian W. Fitzpatrick and BenCollins-Sussman’s Team Geek(O’Reilly Media)People are rational and predictable. [Editor’s note: Let’s try thatagain.] Sometimes people can be irrational and unpredictable. Asa trained software engineer, you’re probably a whiz with computerlanguages, compilers, debuggers and algorithms. But how much real training did you getin dealing with the human side of software development? If your answer is a predictable“not much”, crack open Brian W. Fitzpatrick and Ben Collins-Sussman’s new book TeamGeek: A Software Developer’s Guide to Working Well with Others. Authors Fitzpatrickand Collins-Sussman, producers of the popular video series, “Working with PoisonousPeople”, cover the basic patterns and anti-patterns for working with other people, teamsand users while trying to develop software. Readers learn how to deal with imperfectpeople and discover why playing well with others is at least as important as having greattechnical skills. By internalizing the techniques in this book, publisher O’Reilly says thatreaders will get more software written, be more influential and happier in their careers.http://www.oreilly.comTalentSoftEnterprises frequently experience a gulf between managerial needs and the abilityof the human resources department to deliver appropriate talent to address thoseneeds. “Problem solved”, says TalentSoft, thanks to the new TS Spring’12 release of its SaaSbasedIntegrated Talent and Competencies Management application, which now incorporatesthe best social networks practices into its collaborative talent management solution. Employeesgain control over their careers; managers benefit from greater autonomy, and HR managersincrease their productivity by focusing on high value-added tasks. TS Spring’12 adds two newcore features: TS SocialConnect and TS TalentOffice. TS SocialConnect is a solution that helpsemployers leverage more than 300 social networks toward strengthening brands and attractingthe best profiles. TS TalentOffice allows HR departments to draw upon their existing resourcesto generate customized spreadsheet-based reports and word-processing documents.http://www.talentsoft.comWWW.LINUXJOURNAL.COM / SEPTEMBER <strong>2012</strong> / 59


NEW PRODUCTSLogic Supply’s LGX CT100Open ChassisLogic Supply designed the new LGX CT100 Open Chassis to solve thespace and installation challenges involved with securing Mini-ITX(or 3.5") mainboards and other system components within larger enclosures, such as cabinetsand kiosks. The CT100 is a “case option” designed to be an open mounting plate solutionfitting into an existing electrical cabinet, kiosk or piece of manufacturing equipment. The result,says Logic Supply, is a compact, enclosure-free home for all the IT equipment with the benefitof convenient accessibility to those who need to maintain the IT over time. Absence of physicalenclosure means that many different system configurations are available and the full rangeof Mini-ITX and 3.5" motherboards and power-supply options are supported. Logic Supplyalso designed the CT100 with bench-top configuration testing in mind: it holds all parts safelyduring system debugging and prototyping. A range of mounting provisions are available, withonly a DIN rail or screw studs required for attachment of the plate to the enclosure.http://www.logicsupply.comBelongs Inc.’s Belon.gs Global Lost& Found ServiceLosing stuff has long been accepted as a frustrating yet quintessentialpart of the universal human condition. A team of resourceful Finns—and who loves resourceful Finns more than we do?—is launchingthe Belon.gs Global Lost & Found Web and mobile service to helpunfortunate folks worldwide recover lost important belongings.To utilize the service, customers register at Belon.gs and attach QR code tag stickers totheir valuables. If an item should go missing, the finder can scan the tag’s QR code with asmartphone or access the Web address on the tag. The owner is automatically notified andanonymous chat is established between the two parties to arrange the return of the lostitem. To promote the returning of valuables, Belon.gs supports setting rewards for founditems through PayPal, and the Belongs technology will streamline the transfer of the rewardfrom owner to finder. The aforementioned Finns envision a better world with Belong.gs—aworld without the unnecessary grief that comes from losing your valuables.http://www.belong.gs60 / SEPTEMBER <strong>2012</strong> / WWW.LINUXJOURNAL.COM


NEW PRODUCTSCryptzone’s AppGate MOVEJames Bond would effortlessly foil many a cyber threat if Q would slip him anAppGate MOVE (My Own Virtual Environment) from Cryptzone, a USB Flashdrive that provides a portable way to access information and applications securely from virtuallyany computer. By working independently of the host device’s operating system, the bootableAppGate MOVE allows secure remote working and eliminates risk from malware infection.Cryptzone says that the trend for increased telecommuting calls for a low-cost solution thatallows for trusted access to corporate information from an untrusted computer at home or ina public space. Working in combination with an AppGate Security Server, this drive containsa full operating system, the AppGate client, a Web browser, a Microsoft-compatible OfficeSuite, e-mail client, a firewall and other applications required to complete daily tasks. There isno need for an expensive, dedicated corporate laptop. AppGate MOVE allows users to worksecurely because the configuration of the PC is irrelevant and untouched. Because the local PChard drive is not used, no residue or evidence is left when the session to the AppGate server isclosed. The AppGateUSB Factory allows production of unlimited copies of AppGate MOVE.http://www.cryptzone.comCrossriderMultiple Web browsers are convenient for users but can be a nightmare for developers, who historicallyhave had to create extensions according to each browser’s unique requirements. A new company,Crossrider, with its eponymous, cloud-based cross-browser extension development platform, seeks to makelife more pleasant for extension developers. Crossrider lets developers create cross-browser extensionsquickly with a single JavaScript code and publish to potentially millions of end users immediately. All majorbrowsers are supported, including Chrome, Firefox, Internet Explorer and Safari. The platform also providesthe tools needed to build and manage apps, including JQuery support, a powerful API and app-boostingCrossrider plugins, which allow developers to create custom code to extend the Crossrider API and enablecode sharing within the Crossrider developer community. Crossrider also features a cloud-based IDE thatallows developers to create extensions in real time without downloading a development package. The IDEis equipped with IntelliSense to enable autocompletion for all Crossrider API methods. Tools for monetizingand tracking extensions also are included in the platform.http://crossrider.comPlease send information about releases of <strong>Linux</strong>-related products to newproducts@linuxjournal.com orNew Products c/o <strong>Linux</strong> <strong>Journal</strong>, PO Box 980985, Houston, TX 77098. Submissions are edited for length and content.WWW.LINUXJOURNAL.COM / SEPTEMBER <strong>2012</strong> / 61


REVIEWHARDWAREZaTab: ZaReason’sOpen TabletOpen, rooted, warranty included—we take ZaReason’s newopen tablet, the ZaTab, for a spin. KEVIN BUSHQuite a few options exist asfar as Android tablets go. Someof them are great choices forpersonal entertainment and mediaconsumption. Google’s new Nexus 7is a powerful little beast designedto serve up media from Google Play.Amazon’s Kindle Fire is a great devicefor tapping Amazon’s extensivecontent offerings. Undoubtedly, thesetablets were designed to direct moreof your money to the tablet-maker’son-line content marketplaces. Theglaring lack of SD card expansionon these devices confirms this. TheZaReason team designed a tabletthat can be what the user wants itto be—one that supports users’ owncontent, that is not necessarily tiedto a particular content store andthat can be used as far more than asimple consumption device. Have theysucceeded in creating the world’s firstopen tablet? Let’s find out.STATS:n CyanogenMod 9 Android 4.04.n Allwinner A10 SoC.n 9.7" IPS 1024x768 display.n Five-point capacitive touchscreen.n 16GB internal storage + microSD foradditional storage.n 1GB of RAM.n Wi-Fi (802.11 b/g/n).n Front-facing and back cameras.n Sturdy metal back.n High-capacity 8000 mAh battery.n Ultra-light (630 grams).PORTS:n Headphone.n MicroSD card slot.n Micro-HDMI video out.n 2x micro-USB ports.62 / SEPTEMBER <strong>2012</strong> / WWW.LINUXJOURNAL.COM


REVIEWThe ZaTab’s Generic OEM Retail BoxAs you read over the stats, a fewthings should catch your attention.First, the ZaTab comes loaded withCyanogenMod 9, based on Android4.04 Ice Cream Sandwich, and is rootedout of the box. I feel like I need to saythat again—it is rooted out of the box!You can open a terminal and exploreyour device with root permissions in amatter of seconds. There’s no need torun an exploit to get root access, noneed to flash another ROM, no voidedwarranties. Second, there is 16GB ofinternal Flash storage for apps andmedia, and a microSD slot that canaccommodate an additional 32GB ofstorage. So, there’s ample storage foryour content, stored locally, on yourdevice—no need to rely on “the cloud”or streaming media services.Opening the BoxThe ZaTab arrived packed well inside acorrugated shipping box, with bubblewrap surrounding the retail box. Theretail box is generic OEM fare. I wouldWWW.LINUXJOURNAL.COM / SEPTEMBER <strong>2012</strong> / 63


REVIEWThe Included Accessories: Micro-USB-to-USB Cable, Micro-USB-to-Female USBAdapter, A/C Adapter and Generic User’s Guidelove to see ZaReason produce a brandedbox for the tablet, but that is anotherexpense and surely would raise the price.Snuggled in the box under the tablet,you will find a micro-USB-to-USB cable,a micro-USB-to-female-USB adapter forconnecting USB-based accessories, anA/C adapter and a small generic Androidmanual. The tablet feels sturdy butnot too heavy—definitely not cheap.Unlike most Android tablets out there,the casing is not plastic. The back/sides consist of a solid piece of mattealuminum, with a large ZaReason logosilk-screened on the back of the unit.The port and button labels also are silkscreenedon the back just below theirrespective buttons/ports. Along the topedge, you will find the power button, 5vDC power input, micro-HDMI out, twomicro-USB ports, an 1/8" headphone jackand three small vents to keep things cool.Along the right edge, you will find a backbutton, which takes you to the previousscreen in the Android interface, and thevolume up/down buttons. On the back ofthe ZaTab is a paper-clip-style recessedphysical reset button, the main camera64 / SEPTEMBER <strong>2012</strong> / WWW.LINUXJOURNAL.COM


REVIEWThe Clean Aluminum Casingand a small grill protecting the speaker.The front of the ZaTab is mostly screenwith a 1/2" black bezel, with a frontfacingcamera in the top-right corner.Android SetupIf you have used any Android devicein the past, the initial setup on firstboot will be familiar. Input your Googlecredentials, connect to a network, andyou’re rolling. You have the option todownload and install previous Androidapps you have used on any othersynced devices you may have, and yourbookmarks as well if you are a GoogleChrome user. The device ships with aminimal set of Android apps: ApolloMedia Player, Android Web Browser,Calculator, Calendar, Email, Camera,Gallery, Clock, DSPManager, MovieStudio, People (Address Book), ROMManager, Superuser, Terminal Emulatorand the Android Settings app. You won’tfind any preloaded crapware, no nearlyuseless game demos and no irremovablecommercial apps. The Google PlayStore installs upon syncing your Googleaccount, so you have access to theWWW.LINUXJOURNAL.COM / SEPTEMBER <strong>2012</strong> / 65


REVIEWThe ZaTab—Ready to Come Out and Playlargest selection of Android apps fromthe start.The AppsMost of the apps I installed workflawlessly. I’ve had a blast streaming TEDTalks on the ZaTab with TED’s officialAndroid app. The video is high-quality andplays flawlessly on the ZaTab. Google’sGmail app is perfect for the tablet withsplit views for folders and messages. Thegeneric e-mail app works in much the66 / SEPTEMBER <strong>2012</strong> / WWW.LINUXJOURNAL.COM


REVIEWThe Android ICS Home Screen on the ZaTabsame way with support for Exchange,IMAP and POP. The Plume Twitter clientis a pleasure to use on the big screen.Amazon’s Kindle app looks great as wellwith easily configurable font sizes andtext colors from which to choose. <strong>Linux</strong><strong>Journal</strong>’s own applooks good on theZaTab, with textmoderenderingsharp text. I wasable to connectto my employer’sCisco VPN usingCisco’s Anyconnectfor rooted Androiddevices. Earl, fromZaReason, was kindenough to provide atun.ko tun modulefor the ZaTabwhen asked in the#zareason IRC chatroom on Freenode.This was necessaryfor the Anyconnectclient as it uses atun kernel moduleto facilitate theVPN connection.Earl tells me thatthis module will bepreloaded on theZaTab upon officialrelease, and it maybe shipping onZaTabs as you read this.There were a few apps that just wouldnot play nice with the ZaTab. Netflix, forexample: the app’s interface worked fine,but the app would stall when trying tostream video. Twitter’s homegrown clientWWW.LINUXJOURNAL.COM / SEPTEMBER <strong>2012</strong> / 67


REVIEWwas not available in the store. It must lookfor certain “approved” device profiles andthe ZaTab may not be one of them.The Hardware in UseThe 9.7" 1024x768 in-plane-switchingcapacitive touchscreen is bright withbrilliant color and has an insane viewingangle. You can tilt this thing nearly 90degrees in any direction and maintainview-ability. I find the screen size idealfor a personal touchscreen device. Text issharp, of reasonable size, and movies area joy to watch.Both cameras are unimpressive. Photostaken with the main, rear-facing cameraare grainy and quite dark indoors becausethere is no flash. The front-facing camerais adequate for low-resolution video chats,but it is also quite grainy.Battery life on the other hand isfantastic. You can use the ZaTab heavilyall day long without worrying aboutpower. For example, the day after theZaTab arrived, after a full charge, I spentlots of time downloading and installingapps, watching TED videos, listeningto streaming music via Google Music,reading via the Kindle app and exploringthe unit via the terminal emulator. After15 hours of mostly continuous use, I had40% charge remaining.The InterfaceThe ZaTab comfortably runs AndroidICS. The animated UI transitions andelements are smooth, and there isplenty of processing power for mostapps despite the tablet being a singlecoreunit. Switching apps using theRecent Applications menu makesmultitasking simple. Notificationsare unobtrusive, and apps that arenotifying can be opened directly fromthe notification widget. Plenty ofinformative widgets are available ifyou like your home screen to be moredashboard than application launcher.ConclusionThe ZaTab is the most open tablet outthere, and it should be on your shoppinglist if you’re looking for a tablet designedwith end-user freedom in mind. This isthe ideal device for Android developersor <strong>Linux</strong> developers looking to shoehorna traditional <strong>Linux</strong> distribution onto atablet. There is a good chance you willsee a full <strong>Linux</strong> distro running on theZaTab in the future. ZaTabs are in thehands of KDE and Edubuntu developers,and surely on the wish lists of many otherfree software developers out there. Itruns most Android apps flawlessly—oh,and did I say it was rooted out of thebox? You don’t have to be a hacker toenjoy this tablet either, with plenty ofstorage and access to Google’s Play Storeand Amazon’s Kindle books, it makesa great media device. As I’m wrapping68 / SEPTEMBER <strong>2012</strong> / WWW.LINUXJOURNAL.COM


REVIEWup this review in early July, the ZaTabhas yet to see official release. Earl atZaReason tells me there is still one minorsoftware bug to squash before the ZaTabis officially launched—debugging theHDMI output driver to be specific. Forthe most up-to-date information onwhen the ZaTab will be shipping, topre-order one, or to order a developerunit sans OS, visit the ZaReason Shop:http://zareason.com/shop/zatab.html.■ZaTabPROS:n Brilliant screen.n Rooted out of the box!n No crapware!n Ice Cream Sandwich.n Great battery life.n Solid build quality.n Ample and expandable storage.n Totally hackable.CONS:n A few apps don’t play nice.n Single-core processor.n Grainy cameras.Kevin Bush is a <strong>Linux</strong> systems admin, dad and book-loverwho spends far too much time tinkering with gadgetry.<strong>Linux</strong> JournaLon youre-ReaderCustomizedKindle and Nookeditionsnow availablee-ReadereditionsFREEfor SubscribersLEARN MORE


LOGITECHSQUEEZEBOXPLATFORM:Livin’ in the Land of (Open-Source) Hi-FiEver wished you could have a house full of music, but afraidto commit to a proprietary platform? The Logitech Squeezeboxis an open platform for streaming music all throughout yourhouse and beyond. And, it runs <strong>Linux</strong> too. CRAIG MALONEY70 / SEPTEMBER <strong>2012</strong> / WWW.LINUXJOURNAL.COM


There’s no shortage of optionsfor playing music under <strong>Linux</strong>.Whether it’s local media players,cloud-based music services or streamingmusic, <strong>Linux</strong> users are spoiled for choice.But the number of choices diminishesrapidly when you add features likemultiroom playback, or add multiplatformsupport for Windows, Macintosh andsmartphones like Android and iPhone.Platforms like Apple’s iTunes supportmultiple devices via Air Play, but <strong>Linux</strong>machines can’t support Air Play withoutmajor effort and hacked-up solutions.Logitech’s Squeezebox not only comprisesa reasonably priced hardware platform, italso supports several operating systemsfor both playback and server-side usage.The newer Squeezebox devices (such asthe Squeezebox Radio and SqueezeboxFigure 1. Unboxing the Squeezebox TouchWWW.LINUXJOURNAL.COM / SEPTEMBER <strong>2012</strong> / 71


FEATURE Logitech Squeezebox PlatformTouch) run on embedded <strong>Linux</strong>platforms. The Squeezebox serverand devices support most major,non-DRM-encumbered formats (includingMP3, FLAC and OGG) and supportmany on-line streaming services,such as Spotify, Pandora, Last.fm andSiriusXM. Logitech also supports anactive Squeezebox hacker community andmakes the source of both the player andthe server freely available.Logitech’s Squeezebox platform is theperfect solution for my listening needs.I use the Squeezebox every chance Ican, streaming music from my homemachine to my workstation at work viaan SSH tunnel. Add a long history ofquality hardware devices and an openplatform, and you have a compellingreason for every <strong>Linux</strong> user to considerusing the Squeezebox platform. Bythe end of this article, you’ll wonderwhy you haven’t set up a Squeezeboxplatform of your own, and once youhave, you’ll wonder why you didn’t doit sooner. That’s okay, though; there’snever been a better time to start.Brief HistoryThe Logitech Squeezebox player has along history of development. It startedback in 2000 with the formation of SlimDevices. Slim Devices released its firstmusic player, the SLiMP3, in 2001. It wasa wired-only device, capable of playingMP3-only streams. It relied heavily on theSlim Server to perform transcoding dutiesfor other formats. Later, Slim Devicesreleased wireless versions of the SLiMP3with enhanced displays and support forother formats, such as OGG, WAV, AACand WMA. The first of these models,the Squeezebox1 (or SB1) supportsonly WEP over 802.11b, so it’s moreuseful on today’s networks via a wiredconnection. The Squeezebox2 (SB2) addsboth WPA encryption, 802.11g wirelesscommunication and native FLAC support.If I were looking for an older Squeezeboxunit, the SB2 has the base feature setI would want for any Squeezebox unit.The SB3 (initially named the Squeezebox,later renamed the Squeezebox Classic)is essentially the SB2 with a differentcase design. Every one of these devicesstill is supported by the Slim Server (nowLogitech Media Server), so if you find onein the wild, be sure to pick it up!In 2006, Logitech acquired SlimDevices and continues supporting theSqueezebox line with frequent softwarereleases, and with newer hardware torefresh the Squeezebox line. Logitechreleased the Squeezebox Boom, thefirst all-in-one Squeezebox device thatincluded stereo speakers, and usedthe same interface as the SqueezeboxClassic. Logitech also released the72 / SEPTEMBER <strong>2012</strong> / WWW.LINUXJOURNAL.COM


Squeezebox Duet, which bundledthe Squeezebox Receiver (a headlessdevice capable of playing Squeezeboxstreams) together with the SqueezeboxController (a remote-control devicecapable of controlling any Squeezeboxor Transporter device). Both the Boomand Duet have since been discontinued,but the Squeezebox Controller is notableas it was the first device to ship with thenew <strong>Linux</strong>-based SqueezeOS operatingsystem and the Lua-based SqueezePlayinterface. Logitech released other <strong>Linux</strong>basedhardware devices: the SqueezeboxRadio and the Squeezebox Touch(which I discuss later in this article).Logitech also sells the Transporter,which is geared toward the audiophilemarket. The Transporter uses twofluorescent displays (similar to thoseused in the Squeezebox Classic), andincludes upgraded, audiophile-qualityhardware (see the Logitech Transportersidebar). At the time of this writing,the Transporter, Squeezebox Radio andSqueezebox Touch are the only hardwareplayers sold by Logitech.Okay, enough history. Let’s getsomething set up so you can startplaying music!Getting StartedYou’ll need both a Logitech Media Serverand one or more Squeezebox clients tomake use of the Squeezebox platform.Fortunately, you won’t need to makea trip to the store, as both the serverand clients are freely available on-line.The server software is available fromhttp://www.mysqeueezebox.com/download in prepackaged RPM or .debformats, or as a tarball of Perl sourcecode. The server software does notrequire a mysqueezebox.com account,but I recommend signing up for one,as some proprietary music services willnot work without a mysqueezebox.comaccount. mysqueezebox.com also will beable to act as a Squeezebox server shouldyou be unable (or unwilling) to connectto a local server.Follow the installation instructionsfor your platform to install the LogitechSqueezebox server. Once you haveit installed, navigate to your server’saddress, port 9000 (for this article, I’lluse http://localhost:9000 as the serverURL). Enter your mysqueezebox.comcredentials (if you have them), and clickNext to continue (or Skip). Next, selectwhere your music is located on the serverand where to store playlists. Once thoseare selected, your server is active.ServerLet me talk a bit about the Media Server.The Media Server is the brains of theSqueezebox platform. The server acts asWWW.LINUXJOURNAL.COM / SEPTEMBER <strong>2012</strong> / 73


FEATURE Logitech Squeezebox PlatformFigure 2. Playing Music via the Squeezebox Server’s Web Interfacethe repository for files and playlists, aswell as a Web-based controller for all ofthe connected Squeezebox devices. Mostfunctions and options available on theSqueezebox players can be performedusing the Squeezebox server. The serverhas a bunch of settings for settingvarious functions of the connectedSqueezebox devices. One of those that Iuse determines the quality of output tothe Squeezebox devices. I have a workSqueezebox client that I don’t want todeliver full-sized FLAC files to, so I tellthe Media Server to transcode those filesto 160Kbps MP3 files before sendingthem to my client. There are way toomany settings to cover in this article,but suffice it to say that there are abunch of ways to configure the serverand clients. The Media Server also isextensible using a variety of plugins andapplications, which can customize theLogitech Media Server to fit your musiclistening needs.74 / SEPTEMBER <strong>2012</strong> / WWW.LINUXJOURNAL.COM


Figure 3. Harmoniously Synchronized (Left–Right: Squeezebox Classic, SqueezeboxTouch, Squeezebox Radio, Squeeze Commander/Squeeze Player on Android,Squeezeslave on ASUS EEE 701, SoftSqueeze)SynchronicityBecause the Squeezebox keeps a running tab on each of the players currently playing, it makes itvery easy to see what a particular player is playing. But, what’s even cooler is syncing several playerstogether. Navigate to the player drop-down list to select the player you want to start with. Next, select theplayer drop-down list, and select Synchronize.... The server will show a list of current players. Selectthe player you want to sync with, and get ready to hear music in both rooms at the same time. (If younotice they’re not perfectly in sync, don’t worry; there are plenty of options on the server to take care ofmost synchronizing issues.) Let the Squeezebox pipe music throughout your house at your next party!WWW.LINUXJOURNAL.COM / SEPTEMBER <strong>2012</strong> / 75


compared with the remote that shipswith the Squeezebox Touch (it forgoesthe numeric input) but the Squeezeboxremotes are interchangeable.All of the Squeezebox devices I’ve triedhave great sound. The Squeezebox Touchhas the advantage of more standardconnections (especially if you currentlyhave digital inputs on your receiver) anda very user-friendly interface. I find theSqueezebox Radio is great for portableapplications (especially with the optionalbattery), while the Squeezebox Touch fitsperfectly into our home audio system.Software PlayersOne of the benefits of the LogitechSqueezebox platform’s openness isthe number of software player optionsavailable. One of those is Logitech’s ownSqueezePlay software. The SqueezePlaysoftware is the same interface as theSqueezebox Touch or Radio. It is availablefor Windows, Macintosh and <strong>Linux</strong>.Unfortunately, I had little success gettingit to work under my Ubuntu machines, butit worked well under the Windows systemI tested. What works well on my <strong>Linux</strong>machine is a terminal-based program calledSqueezeslave. Squeezeslave is a C-basedprogram that emulates the interface ofthe Squeezebox Classic devices faithfully(it even requires you to use the numericLogitechTransporterI haven’t covered the SqueezeboxTransporter, but suffice it to say that if youhave the budget for a higher-end digitalplayer, this would be the one to look at. Itboasts audiophile components, but usesthe older-style Squeezebox client software(similar to the Squeezebox Classic). It hastwo individually addressable fluorescentdisplays, and it adds two XLR connectors,infrared in/out jacks, as well as the normaldigital and analog connectors. If youmeasure your listening environment with anoscilloscope or are looking for a Squeezeboxfor a custom installation, definitely check outthe Squeezebox Transporter.The Spirit of RadioThe Logitech Media Server ships with abunch of Internet streaming and radioservices ready for configuration. I was ableto set up most of the local radio stationsby just entering my zip code. The LogitechMedia Server uses a service called TuneIn(formerly RadioTime) to determine whatlocal radio stations are available. Not onlywas I able to select most area stations, Ialso was able to find the streaming NOAAWeather Radio station, as well as police andfire stations. Additionally, I found low-powerradio stations that have on-line streaming,so I can listen to college radio stations thatwould have required a special antenna toreceive. And, that’s without scratching thesurface of the rest of the world’s Internetavailableradio stations. It’s like having thebest of radio right at home.WWW.LINUXJOURNAL.COM / SEPTEMBER <strong>2012</strong> / 77


FEATURE Logitech Squeezebox Platformkeys to enter search text, as if you wereusing a remote). Squeezeslave boastsexcellent sound quality, and it can be runas a dæmon so you won’t have to dedicatea terminal to use it.Another excellent player is theJava-based Soft Squeeze. It is a moregraphically faithful version of theSqueezebox Classic devices, with a varietyof skins (including some that look likethe Squeezebox Transporter, Boom andClassic). Both of these applications fitnicely with my listening habits, becauseI can use the same server for both homeand work. I’ve set up an SSH tunnelat work to ports 9000 and 3483 (thestream and control ports, respectively)and have access to both my large libraryof songs, my list of radio streams viathe Squeezebox server and one of theaforementioned clients (Squeezeslave,primarily). So, if the mood strikes me tolisten to Kendra Springer at work and allI have on my phone is Death Metal, I canhook up to my Squeezebox server at homeand listen to all the Kendra Springer Iwant. (Hey, sometimes it happens!)In addition, several applications areavailable for Android, iPhone and Nokiadevices. Logitech’s own SqueezeboxController (available for both Androidand iPhone) acts as a controller for anySqueezebox device hooked to a server.The menus and interface are similar tothe Squeezebox Touch interface, and itworks as you might expect. The third-partyapplications are really where the power ofthe Squeezebox platform is realized. iPeng(available on the Apple iPhone) acts as aSqueezebox controller application, butfor a few dollars more, you can unlock areceiver application that turns your iPhoneinto a portable Squeezebox receiver. Thisallows you to control and listen to yourSqueezebox music as far as your networkwill let you. Android users have the optionof purchasing a separate application to actas a Squeezebox receiver: Squeeze Player(not to be confused with the SqueezePlayinterface). Squeeze Player acts only as aSqueezebox Receiver, but when pairedwith the Logitech Squeezebox controllerapplication, it becomes a very capableremote player. Android users have theoption of using a very cool third-partycontroller application: Squeeze Commander.Squeeze Commander has all of thefunctionality of the excellent LogitechSqueezebox application, but also includesa bunch of features. Most notably is theability to download music files available tothe Squeezebox directly onto the AndroidDevice. I find this extremely handy, as Ican download my music without needingto have the phone hooked directly tothe computer. Nokia users have the78 / SEPTEMBER <strong>2012</strong> / WWW.LINUXJOURNAL.COM


option of using Squeezester controller,though I’m not aware of any receiverapplications for those devices. There arealso similar Squeezebox receiver andcontroller projects for XMBC in variousstages of development. Check on-line tosee if there’s Squeezebox support for yourplatform. You may be pleasantly surprised.(And if there isn’t, you’ll have all of thetools and documentation to create one.)Applications and Plugins<strong>Linux</strong> users are usually left to their ownhackish solutions whenever it comesFigure 4. You can install applications for the Squeezebox server via mysqueezebox.com.WWW.LINUXJOURNAL.COM / SEPTEMBER <strong>2012</strong> / 79


FEATURE Logitech Squeezebox Platformto streaming services like Pandora andSpotify, or for streaming Sirius XM satelliteradio. With the Logitech Squeezeboxplayer, support for these services (as wellas many other Internet-radio services likeSpotify and Soma.fm) are installable viaapplications or plugins. Application installsare handled from your My Squeezeboxaccount. Select the application you wantto install, click install, and your MediaServer will install the application.The Squeezebox supports manydifferent music services, as well asFacebook and Flickr. Yes, you read thatright: Flickr. Because the SqueezeboxRadio and Squeezebox Touch sport colorLCD screens, you can have them performa slideshow of Flickr images on thedevice. There also are hundreds of pluginsavailable for the Squeezebox, many ofwhich were written by third-party authors.These cover myriad uses, like addingUPnP/DLNA capabilities to the server,switching playlists and positions from oneplayer to another, and many more. Thereis an active plugin community available,and extensive documentation for creatingplugins inside the Help menu on the server(Help→Technical Information→LogitechMedia Server Plugins).Peeking Under the CoversLogitech and Slim Devices went theextra mile to make the Squeezeboxplatform controllable and extensible. TheSqueezebox server ships with a telnetaddressablecommand-line interface.Telnet to port 9090 of your server,and you can control every aspect ofyour Squeezebox server and connecteddevices. You can learn more about thecommands via the help documentation(Help→Technical Information→CommandLine Interface).Better still, all of the SqueezeOS-basedplayers (Squeezebox Radio, Touchand Duet) have an SSH server built in(which is turned off by default, but itcan be enabled simply by navigating toHome→Settings→Advanced→RemoteLogin→Enable SSH). Once enabled,ssh to it with the default credentials(root/1234). Once inside, the bestMessage Of The Day (MOTD) I ever haveseen is displayed:This network device is forauthorized use only. Unauthorizedor improper use of this systemmay result in you hearing very badmusic. If you do not consent tothese terms, LOG OFF IMMEDIATELY.Ha, only joking. Now that youhave logged in feel free to changeyour root password using the80 / SEPTEMBER <strong>2012</strong> / WWW.LINUXJOURNAL.COM


’passwd’ command. You cansafely modify any of the files onthis system. A factory reset (pressand hold add on power on) willremove all your modifications andrevert to the installed firmware.Once you’ve logged in, you haveaccess to all of the internals of theSqueezebox device. This is one of themost forward-thinking moves I’ve seenfrom any hardware manufacturer. Itcame in handy for diagnosing sometrouble I had with alarms on theSqueezebox Radio. (When was the lasttime you ran tail on your alarm clock?)Logitech even releases the source codefor SqueezeOS and includes instructionson how to build and flash the firmware(handy for those of you who never runstock-anything on your hardware).If you really want to dig in to thecapabilities of the Logitech platform,the server ships with some of the mostcomprehensive documentation I haveever seen for a hardware product.Logitech ships the Media Server withgorgeous and thorough documentation.Hidden under the normally uselessmoniker of “Help”, Logitech provides acomprehensive pile of documentationabout the internals of the SqueezeboxProtocol, how to create skins for theserver, how to create plugins for theMedia Server, the display API and somuch more. There is also documentationfor xPL, which is an automation protocolI learned about while skimming thedocumentation. The server can supportxPL calls via enabling a plugin. With somehardware hacking, it’s entirely possibleto set up near-field communications witha device that notifies your Media Serverto play “The Imperial March” from StarWars on all of your Squeezebox deviceswhenever you come home. (Note: theauthor takes no responsibility for theother residents’ reactions if you do this.)I hope this taste of the SqueezeboxPlatform inspires you at least todownload the server and one of thesoftware clients. I know it has openedup a world of possibilities for my musiclistening. Few of the solutions I’vetried boast the interconnectivity of theSqueezebox platform. None of themcome close to the openness and controlof the Squeezebox. Using your phoneor Web browser to control every musicplayer in your house is a liberatingexperience. Being able to listen to thesame collection of music and radiostreams remotely from my home machineis like a dream come true for me. Havingpermission to play, tinker and expand theplatform (with excellent documentationWWW.LINUXJOURNAL.COM / SEPTEMBER <strong>2012</strong> / 81


FEATURE Logitech Squeezebox Platformand a full open-source stack) is unheardof in the higher-end audio space.May your exploration of the LogitechSqueezebox Platform make your listeningexperience more enjoyable.AcknowledgementsSpecial thanks to Logitech Corporationfor its assistance with this article.■Craig Maloney is the host of Open Metalcast (a Creative CommonsMetal Podcast at http://openmetalcast.com) and the co-host ofLococast.net. He’s also the contact for the Ubuntu Michigan Loco,and board member for the Michigan UNIX Users Group. When he’snot listening to music on his Squeezebox, he’s enjoying time withhis lovely wife JoDee, developing stuff only a compiler could love,and playing various tabletop and computer games. He can bereached at his site: http://decafbad.net.ResourcesLogitech Squeezebox: http://mysqueezebox.comSqueezebox Radio: http://wiki.slimdevices.com/index.php/Squeezebox_RadioSqueezebox Touch: http://wiki.slimdevices.com/index.php/Squeezebox_TouchiPhone Applications:n Logitech Squeezebox Controller:http://itunes.apple.com/us/app/logitech-squeezebox-controller/id431302899?mt=8n iPeng: http://penguinlovesmusic.deAndroid Applications:n Logitech Squeezebox Controller:https://play.google.com/store/apps/details?id=com.logitech.squeezeboxremoten Squeeze Commander:https://play.google.com/store/apps/details?id=de.cedata.android.squeezecommandern Squeeze Player:https://play.google.com/store/apps/details?id=de.bluegaspode.squeezeplayerNokia Squeezester: http://talk.maemo.org/showthread.php?t=78966SqueezeOS Documentation:n Squeezebox Protocol: http://wiki.slimdevices.com/index.php/SlimProto_TCP_protocoln SqueezeOS Documentation: http://wiki.slimdevices.com/index.php/SqueezeOSn SqueezeOS Architecture Diagram: http://wiki.slimdevices.com/index.php/SqueezeOS_Architecture82 / SEPTEMBER <strong>2012</strong> / WWW.LINUXJOURNAL.COM


ARDUINOTEACHESOLD CODERNEW TRICKSUsing <strong>Linux</strong> open-source hardware design toolsto create an Arduino-inspired hardware project.EDWARD COMER84 / SEPTEMBER <strong>2012</strong> / WWW.LINUXJOURNAL.COM


FEATURE Arduino Teaches Old Coder New Tricksultrasonic sensors and LCD displays, anddug in. I now had a purpose for usingthe Arduino and a reason to dust off mysoldering iron. I used a breadboard fortesting, as shown in Figure 1.It didn’t take very long to removethe mental cobwebs and get into theelegant simplicity of the Arduino Project.Years ago, when I built microprocessorprojects, the underlying system codealways was the problem. Before I actuallycould write my application, I had todevelop or adapt systems-level codeto interface the application-level codewith the underlying hardware. It wasalways a major pain and, quite frankly,drudgery. The Arduino Project does awaywith worrying about most of the lowlevelsystems code, leaving you with thenow much-simplified task of creatingyour application. Using the Arduino IDEand included or contributed librariesenables you to interface to a plethoraof hardware easily. Anyone who hasdeveloped in the C and C++ languageswill find the Arduino platform easy tomaster quickly. Although Arduino isactually based upon the Wiring Project,compatibility with C, C++ and <strong>Linux</strong>are very high.After implementing and testing codefor the various peripherals that I hadaccumulated and generally mastering theArduino platform, I said to myself, “nowwhat?” So, I abandoned the nice ArduinoIDE and switched over to developing codeusing <strong>Linux</strong> tools, such as Make. I alsowanted to get closer to the hardware, soI abandoned the Arduino boards and didmy implementations on the underlyingICs used by all Arduino boards, the Atmel8-bit series of microcontrollers. Usingthe Arduino libraries with the Atmelmicrocontrollers is a joy to behold. I amso thrilled that the drudgery of systemscode can be mostly ignored as it is mainlyhandled by the hardware abstractionfeatures of Arduino’s built-in libraries. Itis important to note that the Atmel ICsare microcontrollers, not microprocessors.In other words, they are almost completecomputers equipped with RAM, EPROMand Flash memory, multidirectional I/O,serial ports (in some cases) and interfacecircuitry (such as pull-up resistors and soon). Just adding a power source will yielda computer in a chip.The hardware’s interfaces of the Atmelmicrocontroller are abstracted by Arduinoin a uniform way—at least, uniform forthose Atmel micrcontrollers implementedby the Arduino group. Arduino librariesuse internal code, generically calledthe “core”, to define the available I/Opins on a given Atmel microcontroller,assigned by pin number. For example,86 / SEPTEMBER <strong>2012</strong> / WWW.LINUXJOURNAL.COM


the Atmel ATMega168 physical pin 4 isdefined as Arduino I/O pin 2, yet withthe Atmal ATMega32u4 microcontroller,the same Arduino pin 2 is matched tophysical pin 19. Thus, the Arduino syntaxof “pinMode(2, OUTPUT)” defines, insoftware, an abstracted hardware pin asa digital output. Because the Arduinomodule pins are labeled with Arduinopin numbers, the abstraction becomesphysical, at least on the module level.Nonetheless, it is this abstraction aswell as robust libraries that enable theArduino to be so easy to work with. Onecaveat alluded to above is that Atmelmicrocontrollers not implemented inArduino modules don’t have uniformcore definitions—for example, theAtmel Attiny series. You still can usethe Arduino libraries and tools, butthe cores must be obtained elsewhere.For the Atmel ATtiny85 and ATtiny84microcontrollers, I use the core from thecode.google project named arduino-tiny.However, there are other, competingcores around for these chips, and theyare not necessarily compatible.Burning your program into an Arduinomodule is extremely easy to accomplish.The USB connection not only can powerthe module as well as serve as the serialcommunications interface, but theArduino IDE also uses it to install yourprogram into the Flash memory. It is morecomplex with the Atmel ATtiny series,because they have no USB port or evena hardware serial port, for that matter.For the ATtiny series, you must use anexternal programmer. Many people usean Arduino board as the programmeronce they have loaded the ArduinoISPsoftware, or sketch, as programs arenamed in the Arduino world. In my case,I chose to use a dedicated programmercalled a USBasp. It is readily availableon eBay, or you even can make yourown with plans from its creator, ThomasFischl. I purchased mine on eBay becauseit was cheaper than the parts cost tomake my own. The USBasp uses theopen-source AVRDUDE software.The ProjectNow that I had invested a lot of timeinto learning the Arduino system andthe Atmel microcontrollers, I wantedto take the next logical step: movea design from the breadboard to aprinted circuit board. Some interestingprojects exist in this area, such asFritzing, which is designed to facilitatedoing exactly that. It’s a clever projectand you should check it out, but I tooka different path—using the gEDA opensource<strong>Linux</strong> software suite for printedcircuit development.WWW.LINUXJOURNAL.COM / SEPTEMBER <strong>2012</strong> / 87


FEATURE Arduino Teaches Old Coder New TricksI looked at my inventory of parts andstarted thinking of what I could createthat wasn’t already readily available.I settled upon the LCD display. Thedisplays being used in Arduino projectswere interfaced with a lot of I/O pinsand code space, neither of which isin great supply on the Atmel chips. Ifelt that if I could create a same-sizedaughter board that I could attachonto the back of the display and putthe smarts into the board that wouldcommunicate with the LCD display viaan ASCII serial interface, I would havesomething useful that didn’t exist in themarketplace in an affordable form. Thisis commonly called a serial LCD.Being somewhat of an old-timer, Ispent a lot of time using and codingfor the DEC-VT100 display terminalsupon which the ECMA-48/ANSI X3.64standards are based. I felt that if Icoded the daughter board to turn anLCD display into a tiny, affordableDEC-VT100, I would have somethingreasonably unique and useful. SerialdrivenLCD displays do exist, but theytypically have proprietary protocols,and some are rather expensive. As faras I have been able to determine, thereexists no open-source (software andhardware) serial LCD display with VT100protocol. I found my project!Gathering the PartsI selected parts for the VT100-LCDproject, such that the parts would beas affordable as possible. In fact, Ipurchased all the parts from two sources,eBay and Digi-Key, based on cost. Table 1shows the required materials to build onevt100lcd. Costs are shown on a per-itembasis; however, I purchased most of theseitems in quantities of five or more.Schematic DesignTo design the circuitry for the VT100-LCD,I chose gschem of the gEDA Project athttp://geda-project.org. This suiteincludes not only the schematic designprogram but also a PCB layout program,as well as various helper programs.A number of schematic/PCB designsoftware programs exist, but I’m focusingon the open-source software of thegEDA Project by geda-project.org here.Other open-source projects that run on<strong>Linux</strong>, include KiCad, as well as severalcommercial products, the most popularof which is Eagle PCB by CadSoft, whichruns pretty well under WINE.gschem is fairly straightforward, andmany functions are intuitive, but a few,useful but arcane commands necessitateprinting out a cheat sheet (hey, I’mgetting older and I can’t memorize all ofthose keystrokes). Yes, although gschem88 / SEPTEMBER <strong>2012</strong> / WWW.LINUXJOURNAL.COM


also displays important instructions aspart of its command-line text output. Tomake the process a little easier, I use afile named “project” in the project folderfor the current design. Figure 4 showsmy project folder for the vt100lcd84project, the “project” file and thecommand line with the gsch2pcbcommand just before execution.It is worth noting that the gEDA suiteincludes circuit simulation capability(SPICE), enabling virtual design testing.I did not use SPICE with my VT100-LCDproject, but see the Resources for thisarticle if you are interested.Software DesignNow that I had the circuitry designed forthe project, it was time for the software.I wrote the software as a simple statemachine that parses each characterreceived on a character-by-characterbasis, meaning that there is no buffer.Characters are handled differentlyFigure 3. Symbol Example 1WWW.LINUXJOURNAL.COM / SEPTEMBER <strong>2012</strong> / 91


FEATURE Arduino Teaches Old Coder New TricksFigure 4. Example of gsch2pcb Project Filebased upon the current state of themachine. If the state is NOTSPECIAL, thecharacter simply is passed to the LCDscreen for display. However, if the stateis GOTESCAPE, GOTBRACKET or INNUM,the character is processed further. Forexample, if the state is GOTBRACKET,both an escape and left-bracket characterhave been received previously, and thecurrent character must be parsed inthat context. For illustration, the VT100sequence for Screen-Clear is \033[2J, andif the current character being parsed wasthe 2, the state would be GOTBRACKET,and the next state would be INNUM(number collection).This method of parsing has theadvantage of simplicity, which is suitablefor the limited-capacity microcontrollersbut with the disadvantage of not beingable to scroll the screen due to theabsence of a buffer holding a copy of whatis on the screen. See Resources for a copyof the software source. I used Arduinolibraries to build the code. Althoughthe source can be compiled using the92 / SEPTEMBER <strong>2012</strong> / WWW.LINUXJOURNAL.COM


Supported VT100 CommandsReturnCursor to leftmost of current lineLinefeed Cursor downEsc cResets LCDEsc DCursor downEsc MCursor upEsc EMove cursor to start of next lineEsc [ ACursor up one line (arrow key)Esc [ BCursor down one line (arrow key)Esc [ CCursor right one column (arrow key)Esc [ DCursor left one column (arrow key)Esc [ H Cursor to HOME 1;1Esc [ sSave cursor positionEsc [ uRestore to saved cursor positionEsc [ m All attributes offEsc [ Pn A Cursor up Pn linesEsc [ Pn F Cursor up to column 1 of Pn linesEsc [ Pn B Cursor down Pn linesEsc [ Pn E Cursor down column 1 of Pn linesEsc [ Pn C Cursor right Pn charactersEsc [ Pn D Cursor left Pn charactersEsc [ Pn G Cursor to column Pn of current lineEsc [ 2 J Erase Screen and home cursorEsc [ P1;PcH Direct cursor addressing, where P1 is line#Esc [ P1;Pcf Same as aboveEsc [ = Pn h Set (LCD lines) - Pn 2 = 16X2 - 4 = 16X4Esc [ 0 m All attributes off (underscore cursor off)Esc [ 4 m Underscore onEsc [ 0 c Report terminal typeEsc [ 5 n Reports max qty lcd lines (1s based)Esc [ 6 n Reports cursor position (1s based)Esc [ 0 q Turn LCD’s LED 1 offEsc [ 1 q Turn LCD’s LED 1 ondrudgery of low-levelcode and the bootloaderis hidden away within theArduino libraries, whichfreed me to focus solelyon my project. Even main()is hidden away such thatArduino code contains tworequired routines: setup()and loop(). Main actuallydoes exist deep in theArduino directory structurein ~/arduino/arduino-1.0/hardware/arduino/cores/arduino/main.cpp and isautomatically linked in atcompile time.PCB LayoutWhen the .pcb file isopened with gEDA’sPCB program and thecommands invoked arelisted in the gsch2pcbcommand-line text output,you are presented with ajumble of components.I first dispersed thecomponents manuallywith an approximateArduino IDE, I used <strong>Linux</strong> make. Using placement and then activated thethe Arduino libraries makes the project “rats-nest” display. The “rats-nest” isextremely easy to build. Most of the the connections that must be convertedWWW.LINUXJOURNAL.COM / SEPTEMBER <strong>2012</strong> / 93


Figure 6. Final Layout of vt1001cd84 Projectthe copper laminated board that areexposed to the etchant will be dissolvedaway, leaving the areas under theacid-resistant pattern intact.Years ago, I occasionally used tomake Printed Circuit Boards usinga photographic method that is lesscommon in the DIY community today.The acid-resistant pattern was laidout by hand onto translucent or cleardrafting paper using fine black tape forcircuit paths and dry transfer patternsfor components. This pattern is typicallya positive, similar to Figure 7, so anegative must be made photographicallyfor the process to work. The end resultis that the negative’s acetate sheet isclear where copper should remain afteretching. This photographic work formerlywas done in a darkroom, but today,creating the negative can be done usinga computer printing to a transparencysheet. I don’t discuss the process here,but an example is shown in Figure 8.Next, the prepared negative patternwould be affixed on a copper laminatedboard that has a light-sensitive diazo-typeemulsion as a top layer. Exposing theprepared PCB to ultra-violet light wouldalter the properties of the exposed(clear) areas that received the ultra-violetlight. Washing the exposed board in achemical developer dissolved the exposedportions of the emulsion, leaving intactthe emulsion that was under the blackportions of pattern on prepared negativeWWW.LINUXJOURNAL.COM / SEPTEMBER <strong>2012</strong> / 95


FEATURE Arduino Teaches Old Coder New TricksFigure 7. Layout PositiveFigure 8. Layout Negativesheet. Many commercial systems still doa modernized variation of this process asdo some serious DIYers.The casual DIY community has,thankfully, adopted a new and mucheasier method of PCB layout for mediumdensitylayouts. High-density layouts stillshould use the photographic process. The96 / SEPTEMBER <strong>2012</strong> / WWW.LINUXJOURNAL.COM


Figure 9. gEDA PCB Layout in Progressnew DIY PCB layout process is commonlycalled the toner transfer method,because a laser printer is involved.Thankfully, the old paste-up tape anddry-transfer component patterns are athing of the past. Computer softwareis now available for the DIY communitythat takes software-designed schematicsas input and produces a representativePCB layout (Figure 7 was produced bysuch software).As I mentioned earlier, a number ofPCB design software programs exist,but I’m focusing on the open-sourcePCB program of the gEDA project bygeda-project.org here. An exampleof an in-progress gEDA PCB layout isshown in Figure 9, and its final outputis a positive similar to Figure 7.The positive of Figure 7 needs to beprinted in reverse onto a paper that easilywill release the toner when heated. Laserprinter toner is a finely ground polymerplastic that is fused to the paper by heat.The trick of the “toner method” is to getthe toner to transfer from the paper toWWW.LINUXJOURNAL.COM / SEPTEMBER <strong>2012</strong> / 97


FEATURE Arduino Teaches Old Coder New Tricksthe copper-laminated board once it isre-heated. A big part of the secret hereis the type of paper you use.Several paper solutions for the “tonermethod” exist, and some are better thanothers. Regardless of the type of paperused, the process is to place the reverseimage positive laser print with the tonertouching the metal surface of a cleancopper-laminated board and then applyheat and pressure to loosen the tonerfrom the paper, permitting it to transferto and adhere to the copper-laminatedboard. Most DIYers use a commonclothes iron as the heat source, althougha laminating machine designed foridentification cards is successfully usedwith one commercial product that I’lltalk about later.The cheapest and simplest methodis simply to use ordinary copier paper.Once heated under pressure, the tonerends up adhering to both the paperand the copper-laminated board.The paper/copper-laminated boardis then soaked under water, and thewaterlogged paper is rubbed off withyour fingers. This method leaves alot of paper residue embedded in thetoner’s surface, this is undesirable forreasons explained later.Many other paper types are used byvarious DIYers. One of the most popularis to use a high-quality magazine pagethat has a smooth, glossy appearance. Thegloss is caused by a white clay (kaolin)coating. Because the kaolin fills in manyof the pores of the paper, the toner is lessfirmly bonded to the paper. Second, thekaolin dissolves in water, thus freeing thetoner more readily than plain paper. Thismethod is superior to using plain paper,but it still leaves too much paper residueembedded in the toner’s surface.Another popular method is to printonto the glossy side of photo paper orbacking paper for labels. This method issuperior to either plain paper or highqualitymagazine paper, because there isno paper residue embedded in the toner’ssurface. However, a significant problemwith this method is actually getting thetoner to stick to the paper evenly. Quiteoften, PCB traces simply fall off the slicksurface while the paper works its waythrough the printer. Obviously, there is alot of variability among laser printers andglossy paper types. I don’t like variability;I like dependable repeatability.This leads me to the paper and methodI use that has dependable, predictableresults. The paper is colloquially knownas dextrin-coated paper. Some DIYersactually make their own by makingdextrin and coat paper with it. Dextrinis simply cooked cornstarch, and the98 / SEPTEMBER <strong>2012</strong> / WWW.LINUXJOURNAL.COM


FEATURE Arduino Teaches Old Coder New TricksHow do I make my own single-sidedPCBs? It’s fairly simple:1. Print a reverse image positive of thePCB pattern onto the shiny side ofPulsar dextrin transfer paper.2. Place the transfer paper’s toner sideagainst a copper-laminated board thathas been cleaned with steel wool.8. Peel off the Green Toner Foil.9. Etch the board as described below.I make only single-sided boards. Ifyou’d like to make a double-sided board,watch the video at http://youtu.be/XX7IekbCNIY. This DIYer uses HP’s glossybrochure paper and seems to get prettygood results.3. Place a sheet of ordinary paperabove the transfer paper to helpprevent slippage.4. For two minutes, apply, with a few ofpounds of pressure, a common clothesiron set to the highest “cotton” setting.5. Immerse into water, the ironedtogetherpaper/copper-laminatedboard. After a couple minutes, thepaper probably will float off. If itdoesn’t, lift it off.6. Dry the board, and with the toner sideup, lay the dull side of the Green TonerFoil against the toner and anotherpiece of ordinary paper above that.7. Using the same clothes iron set slightlycooler (to “wool”), iron for one minutewith a few pounds of pressure.Etching the PCBHaving read much of what is readilyavailable on the Web concerning DIYPCB etching, when the need arose, Idecided to etch a single-sided boardtwo different ways: first with thevinegar and salt method and secondwith the sponge and ferric chloridemethod. Some DIYers are using muriaticacid, but I have not tried that.The vinegar and salt method works,albeit slowly. Etching my small boardtook two hours. The formula I usedwas equal parts vinegar and hydrogenperoxide and a few tablespoons oftable salt. Keep adding salt until the“fizzing” continues all by itself. Theliquid starts out clear but then turns anattractive shade of blue (Figure 10).The sponge and ferric chloridemethod works extremely well,etching the same board in a couple100 / SEPTEMBER <strong>2012</strong> / WWW.LINUXJOURNAL.COM


Figure 10. Vinegar and Salt Etchantof minutes. In the past, I used ferricchloride to etch boards by placingthem into a bath of ferric chloride.Even with agitation, etching aboard could take ten minutes orso. The sponge and ferric chloridemethod accelerates the etching bycontinuously rubbing the surface witha sponge soaked in ferric chloride.The rubbing removes the oxidelayer that continuously builds up,permitting the ferric chloride to getto the raw metal and thus accelerateetching. Instead of a tub of etchant,a couple tablespoons is all you need,which will make a bottle of ferricchloride last for a very, very long time.The technique is simple. Don plasticWWW.LINUXJOURNAL.COM / SEPTEMBER <strong>2012</strong> / 101


FEATURE Arduino Teaches Old Coder New TricksFigure 11. Final Etched ATtiny 84 Boardgloves, pour a couple tablespoons offerric chloride into a small container,soak a small piece of soft sponge inthe ferric chloride, then continuouslyand lightly rub the saturated spongeon the PCB. In a couple minutes, theboard will be finished with little messand little ferric chloride to dispose of.102 / SEPTEMBER <strong>2012</strong> / WWW.LINUXJOURNAL.COM


Figure 12. Commercially Made ATtiny85 BoardMy final product (after threeversions), a single-sided ATtiny84version of the project, is shown inFigure 11. Given that the boardwas single-sided, nine jumpers wererequired, which are the wires youcan see on the component side ofthe board.WWW.LINUXJOURNAL.COM / SEPTEMBER <strong>2012</strong> / 103


FEATURE Arduino Teaches Old Coder New TricksFigure 13. Commercially Made ATtiny84 BoardCommercially Made PCBsIn addition to making my ownPCBs, I also had commercial boardsmade by a panel aggregator. Apanel aggregator is a service thataggregates boards from manysources, filling up a cost-efficient-sizeprinted circuit board panel and then104 / SEPTEMBER <strong>2012</strong> / WWW.LINUXJOURNAL.COM


eaking up the completed panelfor delivery. Several such companiessupport the hobbyist community.Figure 12 shows my Attiny85design mounted to a 16x2 LCD.Figure 13 shows my Attiny84design mounted to a 16x4 LCD.■Edward Comer is retired from the telecommunications industry,having worked for the real AT&T, BellSouth and Numerex Corpduring a 30-year career. Ed got his first UNIX login in 1975, whileworking for AT&T, on an assembly language version of UNIXrunning on a DEC PDP-11/34. From that point forward, Edremained immersed in UNIX and later, <strong>Linux</strong>, while navigatingthrough stints in software development, data-center management,telephone system management and product development R&D.ResourcesSource Code and Hardware Files for the vt100lcd (interested readers can pull down thefiles and create their own micro-terminal): http://code.google.comThe Arduino Project: http://arduino.ccThe Wiring Project: http://wiring.org.coThe code.google arduino-tiny Project: http://code.google.com/p/arduino-tinyThomas Fischl’s USBasp Web Site: http://www.fischl.de/usbaspAVRDUDE Device Programming Software: http://www.nongnu.org/avrdudeThe Fritzing Project: http://fritzing.orgThe gEDA PCB Development Project: http://www.geda-project.orgSymbol Creation: http://embeddedtoolbox.com/mksymFootprint Creation by Stefan Salewski: http://www.ssalewski.de/SFG.html.en“Circuit Design on Your <strong>Linux</strong> Box Using gEDA” by Stuart Brorson, <strong>Linux</strong> <strong>Journal</strong>November 2005: http://www.linuxjournal.com/article/8438Using gEDA, by Iznogood: http://www.linuxfocus.org/English/December2004/article355.shtmlGetting Started with PCB: http://www.delorie.com/pcb/docs/gs/gs.htmlgsch2pcb Tutorial: http://geda.seul.org/wiki/geda:gsch2pcb_tutorialgschem → gsch2pcb → PCB: http://tinyurl.com/gsched2pcbCircuit Simulation using gEDA and SPICE—HOWTO by Stuart Brorson:http://www.brorson.com/gEDA/SPICE/intro.htmlWWW.LINUXJOURNAL.COM / SEPTEMBER <strong>2012</strong> / 105


The RadicalFuture ofNVMSo, storing data persistently takes abouta million times longer than writing to mainmemory. What happens when main memoryis inherently persistent?Something wonderful.RICHARD CAMPBELL106 / SEPTEMBER <strong>2012</strong> / WWW.LINUXJOURNAL.COM


Although 20 years of opensourcesoftware hasrevolutionized the waywe use computers, thehardware itself has had practically nodeep architectural changes. Servers,desktops and blades are still CPU, RAM,hard disks and NICs, and monitors andkeyboards. Not that that’s a problem—we’ve all enjoyed more than a thousandtimes better performance and capacity,lower energy use and lower prices inthat time frame.But the next orders of magnitudebetter performance will be arriving notin the next 20 years, but in the nextcouple years. And the hardware changeswill not merely make our machineryfaster but will usher in radically differentapproaches to our programmingparadigms, our device interactionand the operating system itself.After 50-some years, what hasbeen considered a fundamentalarchitectural barrier, RAM volatility,is about to disappear.Right now, in every PC, mainframe,tablet and smartphone, the handfulof gigabytes of SRAM and DRAMand DDRAM/2/3 are all electricallydynamic. Turn off the power, andall the program text segments, allthe computed data structures, allthe transient user content, all theoperating system state is lost. Any datato be referenced in the future requirespersistence to “hard disk”.But the difference between RAMand disks is vast. Writes to RAM takenanoseconds; writes to disk takemilliseconds—a million times slower.Disk access patterns are serial, anddisk writes are most efficient only withsizable buffers, rather than RAM’srandom-access patterns. And, disksare notoriously less reliable.The difference is so vast that wearchitect our software systems around it.We put filesystems on disks and transientdata in memory. Our programmingparadigm is such that runningapplications and system state is transient,and there’s no language designed to dealwith persistence intrinsically.So, we have architected several waysto get around this: caches, buffers,flushing I/O patterns, APIs and so on, allmanifestly alerting us that persistenceis costly and dangerous. For reliability,writes to disk must have a variety ofexception handlers. We write extracode to compress writes; we don’t writecomplex data structures to disk; rather,we write transaction logs and so on. Intraditional UNIX/<strong>Linux</strong>, we don’t evenwrite general data to disk when we wantWWW.LINUXJOURNAL.COM / SEPTEMBER <strong>2012</strong> / 107


FEATURE The Radical Future of NVMto—it gets written back every 30 secondsor so when the OS feels like it. We writeonly file metadata to disk synchronously.In terms of architectural fundamentals,think about the difference betweenopen()/write()/close() andall the inherent buffering and explicitexception handling, and a statement likeint x = 10;. We base our languageand API designs on this dichotomy—RAMtheir own acronyms based on theirparticular technology. Some use theacronym NVRAM, but I don’t need tobelabor the random-access aspect, do I?Presumably, generations to come will justcall it “memory”—after all, memory bydefinition is something that is persistent.Now, global companies like IBM,Toshiba, HP and Samsung, and startupslike Everspin, Crocus and Hynix, are allNow, global companies like IBM, Toshiba,HP and Samsung, and startups likeEverspin, Crocus and Hynix, are all buildingand shipping NVM products, primarilyused by embedded systems markets.is fast, reliable but transient; disk writesare slow, error-prone, but persistent.The Next RevolutionFor the past decade, several technologieshave been in development that providethe read and write latency and reliabilityof RAM with the transaction-levelpersistence of disks.Here, I’ll call this technology NVMfor non-volatile memory. RAM, ofcourse, means random access memory,which doesn’t even mention its lackof persistence. Newer products usebuilding and shipping NVM products,primarily used by embedded systemsmarkets. Industries, such as automotive,aerospace and others require veryreliable persistence in small formfactors. And cameras, phones, RAIDcontrollers, network routers and othertech manufacturers are using NVMunder the covers.NVM technologies include:n Magneto-Resistive RAM: stores bits asmagnetic moments in ferromagneticareas built in to transistor arrays. Rather108 / SEPTEMBER <strong>2012</strong> / WWW.LINUXJOURNAL.COM


than a hard drive, this is a randomaccessread/write magnetic media.n Spin-Transfer Torque RAM: stores bitsas spin-aligned electrons rather thanmagnetically aligned atoms. Rightnow, this technology leads in theshortest write latencies.n Phase-Change RAM: stores bits bychanging the crystalline structure of agermanium/antimony/tellurium alloy.Fortunately, that alloy crystal can beembedded in a small transistor and canchange phase in 10s of nanoseconds.n Programmable Metallization RAM:stores bits by switching the ionizationof atoms in an electrolyte betweentwo nano-electrodes.n Resistive RAM (memristors): stores bitsby changing the conductive propertiesof a dielectric cell.These new chips are all nano-fast forwrites and reads without any buffers andcan store data without any active powersupply. But how does that persistencecompare to disk drive reliability? Infact, storage to NVM chips is almost asreliable as disk storage now, and it willbecome more reliable in ways that disksare unlikely to achieve. Current disksoffer an endurance of about 10 15 read/write cycles; current SRAM/DRAM canhandle 10 16 cycles—without persistence.Right now, NVM technologies offer about10 14 –10 15 , but should be able to hit10 16 –10 17 cycles and more. That’s severaldecades of storage stability, matchingand exceeding hard drives.And NVMs should just get better overtime. If you’ve ever seen the “Shoutingin the Datacenter” video, you know justhow error-prone multiplatter spinningdiskswith tiny armatures franticallyswinging back and forth are. Storing datain magnetic-moments or electron spinsinside solid-state cells will be dramaticallymore reliable.Flash in the PanBut isn’t Flash SSD a pretty goodanswer, available now? Yes, but thisis a temporary technology, bringingsome benefits now, but slated for quickobsolescence. Flash is better than a diskdrive, but production Flash NAND gatesare slow. Fast writes are possible onlywith a large RAM write cache stuck intothe Flash memory cards. Worse, thegates are good for only 10 5 –10 6 cycles—each electronic write damages the cell,so large Flash devices need additionalcircuitry for leveling writes acrossWWW.LINUXJOURNAL.COM / SEPTEMBER <strong>2012</strong> / 109


FEATURE The Radical Future of NVMless-used cell areas.Because of these properties and oddbuffering policies, many application usecases simply don’t get any performancebenefit from writing to Flash. Flashmanufacturers know this—in fact,Flash is marketed as an SSD (a solidstate“drive”) telling you that it is notcompeting with RAM.But this is not a bash-Flash article;I’d be just as happy with Flash-basedgigabytes of persistence, as long as itis RAM-fast and reliable. Whether thefuture is Flash or MR-RAM, STT-RAM,PC-RAM, PM-RAM, R-RAM or any ofthe other possibilities—Nanotube-RAM, SONOS, Racetrack memory andso on—the key feature is memory thatis uniformly ultra-low-latency reads andwrites, random-access, high-bandwidth,long-term persistent and capable oflarge-scale, cheap production.(As an aside, battery-backed RAMcould be just as good as NVM, if batteriesdidn’t corrode, fail, require recharging orcatch fire. Battery technology is so poorNew: Intel Xeon E5 Based ClustersBenchmark Your Code on Our Xeon E5 BasedTesla Cluster with:AMBER, NAMD, GROMACS, LAMMPS, or Your Custom CUDA CodesUpgrade to New Kepler GPUs Now!Microway MD SimCluster with8 Tesla M2090 GPUs8 Intel Xeon E5 CPUs and InfiniBand2X Improvement over Xeon 5600 SeriesGSA ScheduleContract Number:GS-35F-0431N


today that it is simply another point offailure, not a truly safe alternative forlong-term storage.)Although current shipping quantities ofNVM are merely (!) millions of units withcapacities of just megabytes, all of thesemanufacturers are committed to continuingscale-up to GB. Some of these larger unitswill start shipping in 2014/2015.This is a big industry with many creativeand agile startups pushing the envelopeand the leading IT manufacturers shippingtheir own products. The productiontechnologies are variants of existingfabrication processes. But let’s move pastarguing the pros and cons of the differentimplementation technologies. I’ve no ideawhich technology or which company willwin out. But the breadth and commitmentof the industry is such that the NVMfuture will arrive sooner than later. Mymotivation here is to talk about some ofthe implications of this hardware futureand to help the software community thinkabout what we’d like to do with it.As mentioned, current uses of thisHarness Microway’s Proven GPU ExpertiseThousands of GPU cluster nodes installed.Thousands of WhisperStations delivered.Award Winning BioStack – LSAward Winning WhisperStation Tesla – PSC with 3D‘11AWARDBESTBest NewTechnologyns/Day (Higher is Better)CPU + GPUCPU Only1.070.332.020.653.541.301 Node2 Nodes 4 NodesNAMD F1-ATP Performance GainConfigure Your WhisperStation or Cluster Today!www.microway.com/tesla or 508-746-7341


FEATURE The Radical Future of NVMare mainly in the industrial sector, butit will soon be more and more visiblein existing appliances, such as networkrouters and other communicationsequipment. And, we’ll quickly see betterhybrid-drives and RAID devices. Hybriddrivesand RAIDs, which currently useFlash or battery-backed RAM to providea persistent cache for a traditional harddrive, will be available with the muchlower latencies and higher reliabilities8GB (and more) main-memory NVMcoupled with a modern CPU?Next StepsThe interesting changes will come withGB-sized NVM add-in cards. You canimagine a new BIOS recognizing thatcard and making it available as a distinctstorage device to the <strong>Linux</strong> kernel. Withthat, it should be pretty trivial to port ourstandard filesystems, like ext2/3/4, xfs orHappily, all of this means the practical eliminationof filesystem maintenance, such as defraggingor optimizing file placement or lengthy boot-timerepair of metadata corruption.of NVM. The benefit here is that oursoftware architectures will be using thesedevices with little or no changes. Thatwill help drive the market for more suchdevices, which in turn will make themanufacturing processes scale up moreand more. But this is just more of thefaster and better world that we expectfrom technology.Our challenge is to think about <strong>Linux</strong>systems in general and a near-futureworld of NVM computer architecturewhere persistent data writes are RAMfast.What will we do when we can havebtrfs. And they’ll work fine and providedramatic performance advantages.But NVM is different from disks. Withreal random access, the algorithms forrotating disk-drive data placement areoutdated. With RAM-like write latencies,we can eliminate most of the bufferingand waits for error reports. And we canoptimize file access made available viamemory mapping to virtually eliminateany API or OS buffering.This new “NVMfs” should likely stillhave a transaction journal for metadata,not to queue up writes that haven’t112 / SEPTEMBER <strong>2012</strong> / WWW.LINUXJOURNAL.COM


een written to disk, but to queue upCPU transactions and cache writes thatmay get interrupted. There’s still a needto take care of this, but the RAM-speedof write latencies means that the kernelcan do much more “filesystem” activitydirectly and not have to wait for interruptcallbacks. Happily, all of this meansthe practical elimination of filesystemmaintenance, such as defragging oroptimizing file placement or lengthyboot-time repair of metadata corruption.With this, many I/O-intensiveapplications and databases like MySQLwill see magnitudes of performanceimprovement. For messaging systemslike ActiveMQ, no longer will therebe a trade-off between unreliable andguaranteed messaging. An applicationusing NVM-optimized SQLite will beawesome. And distributed memorycaches like Memcached won’t have toskimp on persistence features.Meanwhile, encryption andcompression still can be an importantfeature of an NVMfs. Unfortunately, forhard drives, compress/encryption comeswith little cost because of the mismatchbetween fast CPU/RAM speed and slowdisk write latencies. With an NVMfs, theperformance difference between filedata stored plain versus encrypted willbe obvious, though still faster than thosestored on hard disks.In the end, NVM-based filesystemsprobably will mean that all notebooks,desktop PCs and commodity servers willbe totally solid-state systems by the endof the decade. We then can optimizeour OSes to write-back memory pagesto networked disk storage, not forpersistence, but for distributed accessand disaster recovery. Hard drives, whichstill will have an orders of magnitudeadvantage in total storage capacity foryears to come, will be relegated to thedata center and cloud where they can becared for properly.Radical ChangesBut if we can store filesystem datain NVM, we can store applicationdata there too. One simple modelcould be for applications to ask tomap in NVM memory, as is done nowwith mmap’d files. Of course, NVMmemory regions need no backing diskstore—they are inherently resilient.Many performant applications ignorepersistence functionality, not evenusing a transaction log. NVM meansthat all sorts of applications can havepersistent semantics, being able touse complex data structures in theirprogrammatic idioms, without even afoo.save() required.WWW.LINUXJOURNAL.COM / SEPTEMBER <strong>2012</strong> / 113


FEATURE The Radical Future of NVMHow should these NVM areas benamed? How should they be secured?Whereas current programmingparadigms assume that variables aretransient ipso facto, future languages orextensions may allow different semanticsfor different data. Rather than namingdata regions and using some sort ofbrk() or mmap() call, certain languagekeywords or data-naming rules wouldenable automatic re-mapping to persistedNVM data. (Ironically, the “volatile”keyword in C/C++ may be required fortransient data!)For decades, virtual machine-basedlanguages, such as Smalltalk and variousLisps, have had to have cumbersome“save world” commands to write outall the in-memory data structures andclass or function definitions to disk. In anNVM world, we don’t need a separatecommand for this—all VM use of NVM ispersistent. A virtual machine world will beboth dynamic, fast and long-lived. ModernVM languages like Java and also dynamicscripting languages like Ruby/Python/Tcl could enable an application or systemto store all of its active data structuresin NVM with no need for laboriousserialization on and off slow disks.Perhaps functional languages, suchas Erlang and Haskell, with theirimmutable value design, could take thebest advantage of NVM. Their clean,mathematical philosophy has never muchliked the “side effect” of storage. Nowthey may be able to support persistenceas a virtually free feature.NVM on ACIDOf course, with automatic and pervasivepersistence, comes the problem oftransactional support. Although thedata may be persistent, there is noguarantee that what data you’re readingwas all written out as a single, correcttransaction. Take setting some array, mapor string to some value. If some numberof (persistent) stores or cache writes areinterrupted, the array/map/string maybe only half set correctly. Naïvely gettingreconnected to that data segment won’ttell you what portion of the data iscorrect. To help with this, applicationscould ask the kernel to set restore pointsfor their data. A more-sophisticatedsolution would be for VMs to providesoftware transaction semantics or forNVM hardware transactional memory toensure atomicity and consistency.As far as ACID (atomicity, consistency,isolation and durability) goes, NVM couldeliminate worrying about “D”. But willthis NVM data be truly resilient? Won’tbullet-proof resilience as needed forfinancial transactions still exact enormouspenalties? Probably not. If NVM itselfisn’t good enough, redundant boards114 / SEPTEMBER <strong>2012</strong> / WWW.LINUXJOURNAL.COM


FEATURE The Radical Future of NVMshould provide the needed availability.Better yet, HA systems with primaryand secondary NVM still will workthousands of times faster than currentHA disk-based systems.RAM-fast data persistence could enablethe kernel to remember the state ofattached hardware to a far greater ability(or, to be fair, the devices may have theirown NVM to help out).<strong>Linux</strong>Now that you’re getting used to the ideaof “RAM” being “NV”, let’s go all the waydown the stack to the operating systemitself. What advantage could the <strong>Linux</strong>kernel take of NVM? It’s not just that a<strong>Linux</strong> NVM system could boot in fractionsof a second, but that having some (ormost?) kernel state persisted at practicallyno extra cost in time opens up manyinteresting possibilities. The bootloaderstill can execute hardware power-onself-tests, but there’s very little extra workrequired to get the kernel running whenmuch of the kernel state and instructionspace is magically still available.During a transition period, when DRAMand NVM coexist in a system, the kernelprocess table could be modified to notewhich processes are running wholly in NVM.On reboot, the kernel process table (also inNVM) could ignore DRAM-based processes,while letting NVM processes get going assoon as system devices are initialized. And,as mentioned, the kernel could help withapplication data restore points.An NVM kernel also may help withmanaging devices. The ability ofThe FutureNVM is coming. Without much work,it will provide an enormous benefit toapplications and use cases where storageperformance is a limiting factor. I’ve triedto outline some of the more revolutionaryways that we can take advantage ofthe technology. As RAM volatility hasbeen a fundamental assumption of ourcomputing architecture, it is hard tofigure out what an NVM future couldlook like. What may have been the designprinciples, kernel semantics and languagedesign in an alternate computing worldwhere NVM was invented in, say, the1960s? More radical notions could workin theory, but there may be no easymigration path from where we are today.It will be up to the global community tofigure out answers with open source and<strong>Linux</strong> driving the way.■Richard Campbell is a trading systems architect living in NewJersey and the author of Managing AFS: The Andrew File System.His first computer had a 12KHz Z-80 CPU with 256 bytes of ROM,10KB of RAM, and used 1100 baud cassette tapes for storage.Send comments to nvm@netrc.com. See http://www.netrc.com/nvmfor links and more information.116 / SEPTEMBER <strong>2012</strong> / WWW.LINUXJOURNAL.COM


EOFDOC SEARLSMaking theCase to MugglesExplaining <strong>Linux</strong> isn’t enough.Most people experience <strong>Linux</strong>the way they experiencea light switch or a waterfaucet. When they use it, they expect itto work and give them what they want.And if it doesn’t work, they expect anexpert to come and make it work. In theirexperience, <strong>Linux</strong> is the business end ofinfrastructure: the road, not the rubberthat meets it.But the difference between <strong>Linux</strong> andwater, electricity or a road is that mostpeople know what those other thingsare—and they don’t know what <strong>Linux</strong>is, even when they’ve heard of it. That’swhy we need metaphors like the above ifwe’re going to explain <strong>Linux</strong> to them.But do we really need to explain <strong>Linux</strong>to people who don’t know or care muchabout it? And if so, why?For most of <strong>Linux</strong>’s history, those of usclose to the topic believed <strong>Linux</strong> matteredenough to deserve understanding byothers, especially since we were certainthat <strong>Linux</strong> would some day achieve whatwe liked to call World Domination. <strong>Linux</strong>has crossed that threshold, but not by thecrowning victory we had hoped for fromthe start: running on many millions ofpersonal computing and communicationdevices and getting full credit for that,by name. Today, the only form of <strong>Linux</strong>doing that is Android, which is “<strong>Linux</strong>based”,rather than <strong>Linux</strong> itself.Today, as I write this, news comesthat $100 million has been investedin GitHub, the “social coding” sitethat currently hosts millions of coderepositories for millions of people, allusing the Git distributed revision controlsystem created by Linus Torvalds. Thereare excited stories about GitHub in theWall Street <strong>Journal</strong>, Forbes, Reuters,TechCrunch, the San Francisco Chronicle,the Washington Post, Red Herring,GigaOM and dozens of other mainstream118 / SEPTEMBER <strong>2012</strong> / WWW.LINUXJOURNAL.COM


EOFpubs that don’t mention Linus at all. Iwas about to stop looking when I finallyfound one: Rafe Needleman, writing inCNET (http://news.cnet.com/8301-1023_3-57468899-93/github-raises-$100-million-from-andreessenhorowitz),credits Linus right up front.Still, nobody mentions Junio Hamano,who has been maintaining Git since Linushanded that duty to him July 2005. Atthe time of this writing, Junio’s entry inWikipedia is a three-line stub.How many $billions have been madebecause of Linus’ founding work? Howmany more will be made thanks to Linus’and Junio’s work on Git?A better question: would <strong>Linux</strong> and Githave succeeded so spectacularly if Linushad tried to own either of them? No. AsHarry Truman said, “It is amazing whatyou can accomplish if you do not carewho gets the credit.”<strong>Linux</strong>, Git and countless other codebases are working as infrastructuralbuilding materials today because theircreators made them free in the firstplace. That’s what matters—not whogets the credit. The real problem we havetoday is that freedoms embodied in codeare barely understood or credited at all.The same goes for free hardware. And,for lack of that understanding, we arelosing those freedoms today.Eben Moglen made this fact clearin a speech titled “Innovation underAusterity”, which he gave at theFreedom to Connect conference inSilver Spring, Maryland, in May ofthis year. I joined Eben on stage fora conversation after that speech, andopened by saying it was not only oneof the best speeches I’d ever heard, butone of the most important. See the video(http://boingboing.net/<strong>2012</strong>/05/27/innovation-under-austerity-eb.html)in an excellent posting in BoingBong byCory Doctorow. The Software FreedomLaw Center has a full transcript aswell (http://softwarefreedom.org/events/<strong>2012</strong>/freedom-to-connect_moglen-keynote-<strong>2012</strong>.html). Here’s acompressed excerpt:For the policy makers, in otherwords, an overwhelming problemis now at hand: how do we haveinnovation and economic growthunder austerity? They do notknow the answer to this question,and it is becoming so urgent thatit is beginning to deteriorate theirpolitical control.Nobody will ever try to create acommercial encyclopedia again.Disintermediation, the movementof power out of the middle ofWWW.LINUXJOURNAL.COM / SEPTEMBER <strong>2012</strong> / 119


EOFthe Net is a crucial fact about21st century political economy.It proves itself all the time.Somebody’s going to win a NobelPrize in Economics for describing,in formal terms, the nature ofdisintermediation.The greatest technologicalinnovation of the late 20thcentury is the thing we nowcall the World Wide Web, aninvention less than 8,000 daysold. That invention is alreadytransforming human society morerapidly than anything since theadoption of writing.What do we know about howto achieve innovation underausterity? We created the Cloud.We created the idea that wecould share operating systems andall the rest of the commoditizablestack on top of them. We didthis using the curiosity of youngpeople, not venture capital.Venture capital came towards usnot because innovation needed tohappen, but because innovationhad already happened.That curiosity of young peoplecould be harnessed because all ofthe computing devices in ordinaryday-to-day use were hackable,and so young people couldactually hack on what everybodyused. That made it possible forinnovation to occur where it canoccur without friction, which isat the bottom of the pyramid ofcapital. Hundreds of thousands ofyoung people around the worldhacking on laptops, hacking onservers, hacking on generalpurposehardware availableto allow them to scratch theirindividual itches—technical,career, and just plain ludic itches(“I wanna do this; it would beneat”)—which is the primarysource of the innovation whichdrove all of the world’s greateconomic expansion in the pastten years. The way innovationreally happens is that you provideyoung people with opportunitiesto create on an infrastructurewhich allows them to hack thereal world and share the results.That’s the upside. The downside is this:All of that innovation comes fromthe simple process of letting thekids play and getting out of theway. Which, as you are aware,120 / SEPTEMBER <strong>2012</strong> / WWW.LINUXJOURNAL.COM


EOFwe are working as hard as wecan to prevent, now, completely.Increasingly, around the world,the actual computing artifactsof daily life for individual humanbeings are being locked so youcan’t hack them. The individualcomputing laboratory in every12-year-old’s pocket is beinglocked down. If you preventpeople from hacking on whatthey own themselves, you willdestroy the engine of innovationfrom which everybody is profiting.The goal of the network operatorsis to attach every young humanbeing to a proprietary networkplatform with closed terminalequipment that she can’tlearn from, can’t study, can’tunderstand, can’t whet her teethon, can’t do anything with exceptsend text messages that costa million times more than theyought to.This paragraph replaces a longdigressive harangue I spent two dayswriting. I visited patents and copyrights,ACTA and SOPA (both of which <strong>Linux</strong><strong>Journal</strong> readers by now know a greatdeal), and a new issue: the Trans-PacificPartnership Agreement (TPP,https://www.eff.org/issues/tpp), bywhich the US is quietly working to muscleNew Zealand (http://internetnz.net.nz/our-work/Openness/Trans-Pacific-Parternship-TPP-agreement) andother countries into matching the US’sHollywood-driven and freedom-hostileintellectual property laws. So I urge youto pay attention to that one, while herewe look instead at the freedom foundin general-purpose computing. This isperhaps the most important issue, andalso the hardest one to explain.General-purpose computing was bornout of IBM’s original PC, which arrived in1982. That machine itself was not freeand open, but its BIOS could be reverseengineered,which Phoenix Technologiesdid in 1993, making possible themanufacture of “IBM-compatible” PCs,better known at the time as clones, byanybody. Succeeding generations of PCsmostly ran Microsoft’s operating systems.But they didn’t need to. That was whatmade <strong>Linux</strong> and countless other operatingsystems possible. General-purposecomputers don’t depend on any onecompany’s controlling technology.General-purpose communicationsare the same. We aren’t locked in toanybody or anything. This is the miracleof the Internet. We don’t need a phonecompany to make the connection forus. We don’t need a license to use it.We have a choice of many services andWWW.LINUXJOURNAL.COM / SEPTEMBER <strong>2012</strong> / 121


EOFpaths. We have open protocols for filetransfer, for e-mail and for much else.For specialized communications, such asthat provided by Skype, there are manychoices, and opportunities for manymore. But none excludes any other.The latest threat to general-purposecomputing is UEFI, the Unified ExtensibleFirmware Interface. Intended as asecurity measure, it adds a layer ofcomplication to running an operatingsystem other than preinstalled Windowson otherwise generic PC hardware. Tomake installs easy, Fedora has electedto pay what Cory Doctorow calls“blood money” to make booting anon-hassle (http://boingboing.net/<strong>2012</strong>/07/06/zareason-a-computercompany-w.html#more-169692).(Go to Implementing UEFI SecureBoot in Fedora for the details athttp://mjg59.dreamwidth.org/12368.html.It won’t give you warm fuzzies.) Thedirection this development points istoward less general purposefulness.And this isn’t good.One of the best characterizationsof the Internet I’ve ever heard was“a way, not a place”, which was thetitle and key point of a speech PhilWindley gave at a conference earlierthis year. (He makes the same pointin this post: http://www.windley.com/archives/<strong>2012</strong>/03/ways_not_places.shtml.)A protocol is a way. And thus, so is theInternet. We may talk about spaces,domains, locations, sites and addresses,all of which frame the Net as real estate.But TCP/IP is a way, not a place. All itdoes is make a best effort to connect anytwo end points by any means possible. Itspurpose could not be more general.Back in 1997, a hacker (presumably)with the (very pre-Twitter) handle@Man put up a page titled “Attention,Fat Corporate Bastards!” It lasted until2010, but can still be found in theInternet Archive (http://web.archive.org/web/19970607134127/http://www.ecst.csuchico.edu/~atman/attentionfat-bastards.html).After yelling aboutfreedom for most of the page, he treatsthe reader to a passage that rings as truetoday as it did 14 years ago:You almost certainly think ofthe Internet as an audience ofsome type—perhaps somewhatcaptive. If you actually hadeven the faintest glimmering ofwhat reality on the net is like,you’d realize that the real unitof currency isn’t dollars, data,or digicash. It’s reputation andrespect. Think about how thatimpacts your corporate strategy.Think about how you’d feel if aguy sat down at your lunch table122 / SEPTEMBER <strong>2012</strong> / WWW.LINUXJOURNAL.COM

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!