18 February 2013

340. Issues when compiling Nwchem 6.1.1 -- missing *.fh in src/include

The problem:
If you modify the nwchem sources, build, do a make realclean and then pack them up to export your patched sources to other nodes you might find that compiling doesn't work that well, yielding errors such as (I'll list them all to help google):

make[1]: *** No rule to make target `/opt/nwchem/nwchem-6.1.1-src_mod/src/include/stdio.fh', needed by `/opt/nwchem/nwchem-6.1.1-src_mod/lib/LINUX64/libnwcutil.a(basis.o)'.  Stop.
make: *** [libraries] Error 1

and

make[1]: *** No rule to make target `/opt/nwchem/nwchem-6.1.1-src_mod/src/include/nwc_const.fh', needed by `/opt/nwchem/nwchem-6.1.1-src_mod/lib/LINUX64/libnwcutil.a(basis.o)'.  Stop.
make: *** [libraries] Error 1
nwchem.F:3:0: fatal error: errquit.fh: No such file or directory
compilation terminated.
stubs.F:15:0: fatal error: errquit.fh: No such file or directory

and

make[1]: *** No rule to make target `/opt/nwchem/nwchem-6.1.1-src_mod/src/include/errquit.fh', needed by `/opt/nwchem/nwchem-6.1.1-src_mod/lib/LINUX64/libnwcutil.a(basis.o)'.  Stop.
make: *** [libraries] Error 1

and

make[1]: *** No rule to make target `/opt/nwchem/nwchem-6.1.1-src_mod/src/include/util.fh', needed by `/opt/nwchem/nwchem-6.1.1-src_mod/lib/LINUX64/libnwcutil.a(bas_input.o)'.  Stop.

and

/opt/nwchem/nwchem-6.1.1-src_mod/src/include/util.fh:1:0: fatal error: printlevels.fh: No such file or directory
compilation terminated.
make[1]: *** [/opt/nwchem/nwchem-6.1.1-src_mod/lib/LINUX64/libnwcutil.a(bas_input.o)] Error 1
make[1]: *** Waiting for unfinished jobs....

and

basisP.F: In function 'nbf_from_ucont':
basisP.F:427:0: warning: '__result_nbf_from_ucont' may be used uninitialized in this function [-Wmaybe-uninitialized]
make[2]: warning: -jN forced in submake: disabling jobserver mode.
make[1]: warning: -jN forced in submake: disabling jobserver mode.
make[1]: *** No rule to make target `/opt/nwchem/nwchem-6.1.1-src_mod/src/include/msgids.fh', needed by `/opt/nwchem/nwchem-6.1.1-src_mod/lib/LINUX64/libnwcutil.a(geom.o)'.  Stop.

and

make[1]: *** No rule to make target `/opt/nwchem/nwchem-6.1.1-src_mod/src/include/bitops.fh', needed by `/opt/nwchem/nwchem-6.1.1-src_mod/lib/LINUX64/libnwcutil.a(pstat_alloc.o)'.  Stop.

and

In file included from pstat_alloc.F:12:0:
/opt/nwchem/nwchem-6.1.1-src_mod/src/include/bitops.fh:11:0: fatal error: bitops_decls.fh: No such file or directory
compilation terminated.
make[1]: *** [/opt/nwchem/nwchem-6.1.1-src_mod/lib/LINUX64/libnwcutil.a(pstat_alloc.o)] Error 1

and

In file included from pstat_alloc.F:12:0:
/opt/nwchem/nwchem-6.1.1-src_mod/src/include/bitops.fh:12:0: fatal error: bitops_funcs.fh: No such file or directory
compilation terminated.
make[1]: *** [/opt/nwchem/nwchem-6.1.1-src_mod/lib/LINUX64/libnwcutil.a(pstat_alloc.o)] Error 1

and

make[2]: warning: -jN forced in submake: disabling jobserver mode.
make[2]: *** No rule to make target `/opt/nwchem/nwchem-6.1.1-src_mod/src/include/itri.fh', needed by `/opt/nwchem/nwchem-6.1.1-src_mod/lib/LINUX64/libnwcutil.a(sym_sh_pair.o)'.  Stop.
make[2]: *** Waiting for unfinished jobs....

and

make[2]: *** No rule to make target `/opt/nwchem/nwchem-6.1.1-src_mod/src/include/bgj.fh', needed by `/opt/nwchem/nwchem-6.1.1-src_mod/lib/LINUX64/libnwints.a(exactd_mem.o)'.  Stop.

and

make[1]: *** No rule to make target `/opt/nwchem/nwchem-6.1.1-src_mod/src/include/numerical_constants.fh', needed by `/opt/nwchem/nwchem-6.1.1-src_mod/lib/LINUX64/librimp2.a(rimp2_v_e2.o)'.  Stop.

and

make[2]: *** No rule to make target `/opt/nwchem/nwchem-6.1.1-src_mod/src/include/util_sgroup.fh', needed by `/opt/nwchem/nwchem-6.1.1-src_mod/lib/LINUX64/libdntmc.a(gibbs.o)'.  Stop.

and

nwchem.F:11:0: fatal error: bgj_common.fh: No such file or directory

Solution:
This has been mentioned before on the nwchem forum, but not in explicit enough detail.
The solution is to copy a series of files from src/util and to remove make realclean from your build instructions (or at least do the copying after the make realclean step).

Copy these files
cp src/util/stdio.fh src/include/
cp src/util/nwc_const.fh src/include/
cp src/util/errquit.fh src/include/
cp src/util/util.fh src/include/
cp src/util/printlevels.fh src/include/
cp src/util/msgids.fh src/include/
cp src/util/bitops.fh src/include/
cp src/util/bitops_decls.fh src/include/
cp src/util/bitops_funcs.fh src/include/
cp src/util/itri.fh src/include/
cp src/util/bgj.fh src/include/
cp src/util/numerical_constants.fh src/include/
cp src/util/util_sgroup.fh src/include/
cp src/util/bgj_common.fh src/include/

Then build, using e.g.
export LARGE_FILES=TRUE
export TCGRSH=/usr/bin/ssh
export NWCHEM_TOP=`pwd`
export NWCHEM_TARGET=LINUX64
export NWCHEM_MODULES="all python"
export PYTHONVERSION=2.7
export PYTHONHOME=/usr
export BLASOPT="-L/opt/openblas/lib -lopenblas"
export USE_MPI=y
export USE_MPIF=y
export USE_MPIF4=y
export MPI_LOC=/usr/lib/openmpi/lib
export MPI_INCLUDE=/usr/lib/openmpi/include
export LIBRARY_PATH=$LIBRARY_PATH:/usr/lib/openmpi/lib:/opt/openblas/lib
export LIBMPI="-lmpi -lopen-rte -lopen-pal -ldl -lmpi_f77 -lpthread"
cd $NWCHEM_TOP/src
make nwchem_config
make FC=gfortran 1>make.log 2>make.err
export FC=gfortran
cd ../contrib
./getmem.nwchem

15 February 2013

339. Compiling ncdu on ROCKS 5.4.3/Centos 5.6

du is nice, but ncdu gives a better overview. Nothing odd about building it though:

mkdir ~/tmp
cd ~/tmp
wget http://dev.yorhel.nl/download/ncdu-1.9.tar.gz
tar xvf ncdu-1.9.tar.gz
cd ncdu-1.9/
sudo mkdir /share/apps/tools/ncdu -p
sudo chown $USER /share/apps/tools/ncdu
./configure --prefix=/share/apps/tools/ncdu
make
make install
echo 'export PATH=$PATH:/share/apps/tools/ncdu/bin' >> ~/.bashrc
source ~/.bashrc

Start by running
ncdu

13 February 2013

338. Annotating PDFs in linux -- revisited. Still no obvious solution

Update 28/02/2014: I've had a look at I, Librarian and Master PDF Editor here: http://verahill.blogspot.com.au/2014/02/558-more-options-for-pdf-annotation.html

There are a a few main reasons why even platform agnostic people have trouble moving to linux. One of them is poor compatibility of open solutions with MS Office (incompatibility between MS Equations and libre/openoffice is my main gripe, and some may find the lack of native EndNote an issue), and one quite particular to academics is the lack of proper pdf annotation (traditionally you edit your galley proofs by making annotations on the pdf -- my latest paper from Wiley came back with a doc file though, which was a bit surprising, but promising)

I've gotten by in the past by using 'pdf x-change viewer', which is a windows program, under wine. However, there are a lot of things I don't like about that solution, and the search for a native solution has continued to the point where I'm willing to throw money at it.

Why the exercise is unfair
The problem is that our definition of what 'works' and what doesn't is based on what we expect it to look like -- and that's based on our experience. I have colleagues that consider libreoffice 'crap' because it behaves or looks different from MS Office. While I agree that it's not viable as a replacement to office when collaborating with Office users who refuse to use libreoffice, it works fine if libreoffice is all you use. Anyway, it's unfair. Same goes for pdf annotation -- we expect it to look and function like adobe acrobat, simply because that's what we're used to. Any deviation is akin to a bug.

So keep that in mind when I write off some of the alternatives that actually do work -- just not in the way I expect them to.

I've found a lot of people (online) swearing by e.g.  Xournal, so even if it doesn't work for me, you may decide differently.

Commercial software in academia

I don't normally like buying software which is critical to my work. There are many reasons for it, and cost is only a minor one (although I don't like spending tax payer money on overpriced software).

Instead, if the software is critical to the science that I'm doing, I prefer to write my own algorithms in octave or python, and if it's a bit more peripheral I'm still wary of becoming reliant on a piece of software that may one day disappear -- either because I'm forced to upgrade through planned obsolescence, or because the company goes bankrupt/discontinues the software without releasing it as open source.

I cannot recommend Mendeley. And that's for two reasons:
1. it installs a list file in /etc/apt/sources.list.d/ without asking. That's the way malware (and google...) behaves!
2. There's plenty of mention about how it's 'free', but the free version is very restrictive, and if you create a private group you're stuck with a nagging message saying that you "must" upgrade if you want to add more users/groups. A simple one-time message would suffice.

Maybe I'm overreacting, but I don't appreciate this behaviour at all. Beyond that the annotation function works fine, so you decide for yourself.

Anyway, here's a short list of programs I've considered:
(and FOSS= Free and Open Source Software)



Evince
Evince is FOSS and now (since when?) supports adding annotations. It's not working very well (sometimes doesn't save annotation, slow), and you can't delete annotations, so be careful what you're saving.
Evince


pdfedit
pdfedit is another standard linux package. It does highlighting well, but annotates by adding text on top of the document -- not as a sticky note. FOSS.
pdfedit


flpsed
Does annotation, but as text superimposed on the pdf document, not as a collapsible sticky note. FOSS..

Qoppa PDF Studio
This is java based, and runs on Linux. I must already now say that there's one aspect of it that I really don't like: it's available in a Standard and a Professional version. That's the kind of artificial crippling of software that Microsoft likes to engage in, but I though we were beyond that on Linux...the price, $89, is too steep for something that I'd only use for annotations. Note also that the trial version puts a big nasty watermark over everything -- but you can hardly fault them for that, since it's not free. Closed source. Commercial.
Other than that it works, although it's not as pretty as mendeley.

Qoppa PDF studio


Xournal
Xournal can export annotated PDFs, but it doesn't do annotation in the same way as the other programs i.e. using sticky notes. Instead you can simply add text on top of the pdf, and it doesn't really do it for me. FOSS..
Xournal -- the annotations are not easy to spot


Whyteboard
It draws on top of PDF using imagemagick. FOSS.

Mendeley
While it's meant mainly for reference management, this does proper PDF annotation as well, and is platform agnostic. However, it is closed source, requires you to log in (even if you're using the desktop client) every time you use it, and needs you to explicitly keep documents (at least their titles etc.) out of the shared web catalogue. Other than that the pdf annotation works beautifully. I get really annoyed by the requirement to log in even when working offline though. It's free in the sense of gratis though -- but only up to 100 Mb of shared document space, you can only have one private group, and it can only have two members (+you). If you want more you need to pay (see e.g. here).
In practical terms, it seems to use GMT to time stamp annotationsand I haven't found an obvious way
of changing that (without going online). Also, it installs a file into /etc/apt/sources.list.d/ without asking.
Mendeley


Misc
Other 'solutions' that pop up is Okular which work in a roundabout way -- i.e the annotations aren't stored as part of the pdf. Again, it looks pretty, but the annotations are not exported with the pdf.
UPDATE: Note that this doesn't seem to be an issue anymore -- see comments below and this post: https://groakat.wordpress.com/2013/08/27/annotating-pdf-with-okular/ -- note that the new version is NOT in either wheezy or jessie i.e. they won't work.

okular


I tried FoxIt reader as well which claims to do annotation but doesn't on Linux -- and the windows version is not functional under linux/wine.

PDF X-change viewer/wine pops up so often as a suggested solution that it's beginning to look like spam. It does work though:
PDF Xchange viewer


An online only option is http://www.pdfescape.com -- but the paranoid part of me doesn't like the idea of uploading documents that are meant to be private.

12 February 2013

337. Modifying Nwchem 6.1.1 to work with GabEdit

Karol Strutynski left the following comment on a post about NWChem and Gabedit:

Hello,
I have one important comment:
The vectors coefficients in the nwchem output are incomplete!
The default behaviour of nwchem is to print 10 first coefficients with value bigger than 0.15. For systems with many atoms it is not enough, usually its not even close.

This behaviour is hard-coded in the nwchem source.
To change this you must search each instance of movecs_print_anal in the source code and replace 0.15d0 for smaller value in appropriate calls.
Furthermore you must change one loop in the src/ddscf/movecs_pr_anal.F file and around 200 line there will be loop:
do klo = 0, min(n-1,9), 2
You must increase the range of this loop, for something more reasonable like:
do klo = 0, min(n-1,199), 2

After recompiling the nwchem will print more coefficients and the gabedit will produce more reliable orbitals.

Best regards,
Karol Strutynski

So let's modify NWChem. I'll be modifying the 27th of June release of NWChem 6.1.1, which you'll obtain as Nwchem-6.1.1-src.2012-06-27.tar.gz from http://www.nwchem-sw.org/index.php/Download.


Change the number in red to something smaller (I tried 0.01d0) in the following files:
 /src/ddscf/uhf.F
 146  9611    continue
 147          call movecs_print_anal(basis, ilo, ihi, 0.15d0, g_movecs,
 148      $        'UHF Final Alpha Molecular Orbital Analysis',
 149      $        .true., dbl_mb(k_eval), oadapt, int_mb(k_irs),
 150      $        .true., dbl_mb(k_occ))
 151          call movecs_print_anal(basis, ilo, ihi, 0.15d0, g_movecs(2),
 152      $        'UHF Final Beta Molecular Orbital Analysis',
 153      $        .true., dbl_mb(k_eval+nbf), oadapt, int_mb(k_irs+nmo),
 154      $        .true., dbl_mb(k_occ+nbf)

/src/ddscf/scf_vec_guess.F
506          if (scftype.eq.'RHF' .or. scftype.eq.'ROHF') then
507             call movecs_print_anal(basis, 1,
508      &           nprint, 0.15d0, g_movecs,
509      &           'ROHF Initial Molecular Orbital Analysis',
510      &           .true., dbl_mb(k_eval), oadapt, int_mb(k_irs),
511      &           .true., dbl_mb(k_occ))
512          else
513             nprint = min(nalpha+20,nmo)
514             call movecs_print_anal(basis, max(1,nbeta-20),
515      &           nprint, 0.15d0, g_movecs,
516      &           'UHF Initial Alpha Molecular Orbital Analysis',
517      &           .true., dbl_mb(k_eval), oadapt, int_mb(k_irs),
518      &           .true., dbl_mb(k_occ))
519             call movecs_print_anal(basis, max(1,nbeta-20),
520      &           nprint, 0.15d0, g_movecs(2),
521      &           'UHF Initial Beta Molecular Orbital Analysis',
522      &           .true., dbl_mb(k_eval+nbf), oadapt, int_mb(k_irs+nmo),
523      &           .true., dbl_mb(k_occ+nbf))

/src/ddscf/rohf.F
155          endif
156          call movecs_print_anal(basis, ilo, ihi, 0.15d0, g_movecs,
157      $        'ROHF Final Molecular Orbital Analysis',
158      $        .true., dbl_mb(k_eval), oadapt, int_mb(k_irs),
159      $        .true., dbl_mb(k_occ))

/src/mcscf/mcscf.F
680       if (util_print('final vectors analysis', print_default))
681      $     call movecs_print_anal(basis,
682      $     max(1,nclosed-10), min(nbf,nclosed+nact+10),
683      $     0.15d0, g_movecs, 'Analysis of MCSCF natural orbitals',
684      $     .true., dbl_mb(k_evals), .true., int_mb(k_sym),
685      $     .true., dbl_mb(k_occ))
686 c

/src/nwdft/scf_dft_cg/dft_cg_solve.F
166           call movecs_fix_phase(g_movecs(ispin))
167           call movecs_print_anal(basis, ilo, ihi, 0.15d0,
168      &         g_movecs(ispin),blob,
169      &         .true., dbl_mb(k_eval+(ispin-1)*nbf),
170      &         oadapt, int_mb(k_irs+(ispin-1)*nbf),
171      &         .true., dbl_mb(k_occ+(ispin-1)*nbf))
172         enddo

/src/nwdft/scf_dft/dft_scf.F
1736             call movecs_print_anal(ao_bas_han, ilo, ihi, 0.15d0,
1737      &           g_movecs(ispin),
1738      &           blob,
1739      &           .true., dbl_mb(k_eval(ispin)), oadapt,
1740      &           int_mb(k_ir+(ispin-1)*nbf_ao),
1741      &           .true., dbl_mb(k_occ+(ispin-1)*nbf_ao))

/src/nwdft/scf_dft/dft_mxspin_ovlp.F
186       call movecs_print_anal(basis,int_mb(k_non),int_mb(k_non)
187      & ,0.15d0,g_alpha,'Alpha Orbitals without Beta Partners',
188      &   .false., 0.0 ,.false., 0 , .false., 0 )
189 c
190       if (nct.GE.2) then
191       do i = 2,nct
192       ind = int_mb(k_non+i-1)
193       call movecs_print_anal(basis,ind,ind
194      & ,0.15d0,g_alpha,' ',
195      &   .false., 0.0 ,.false., 0 , .false., 0 )
196       enddo
197       endif

352 c
353        call movecs_print_anal(basis, 1, nalp, 0.15d0, g_ualpha,
354      & 'Alpha Orb. w/o Beta Partners (after maxim. alpha/beta overlap)',
355      &   .false., 0.0 ,.false., 0 , .false., 0 )
356 c
Otherwise once could presumably edit the header in ./src/ddscf/movecs_pr_anal.F directly and substitute thresh. At a minimum you should edit that file according to Karol's instructions: change the number in red below to e.g. 199.

/src/ddscf/movecs_pr_anal.F
198             do klo = 0, min(n-1,9), 2
199                khi = min(klo+1,n-1)
200                write(LuOut,2) (
201      $              int_mb(k_list+k)+1,
202      $              dbl_mb(k_vecs+int_mb(k_list+k)),
203      $              (byte_mb(k_tags+int_mb(k_list+k)*16+m),m=0,15),
204      $              k = klo,khi)
205  2             format(1x,2(i5,2x,f12.6,2x,16a1,4x))
206             enddo

Compilation
At this point you should be able to follow post 242. Briefly: Compiling NWChem 6.1.1 with Python on Debian Testing (Wheezy) and compile nwchem with python etc. Don't forget to edit /src/config/makefile.h for python support as shown in that post. Once you're done with that you can compare the GabEdit plots with and without the modification.

Alternatively, if you're simply making changes to a copy of nwchem that you've compiled before, you can speed thing up by a factor of ca 300 by following this post:
http://verahill.blogspot.com.au/2013/04/380-modifying-nwchem-code-without-full.html



The difference:
I ran a job on benzene as described in post 281. Visualising NWChem output with GabEdit. I chose to run use the ELF (electron localisation function) on output from the unmodified and modified nwchem binaries. It's a pretty big difference:

Original

Modified

08 February 2013

336. Compiling ATLAS, netblas, lapack and openblas on Arch Linux

Here's another Arch post.

I was a bit surprised to find that there's no ATLAS in the standard Arch repositories (it is in AUR though), so here's how to build some of the more common math libraries for yourself:


ATLAS

pacman -S wget base-devel gcc-fortran cpupower
sudo systemctl enable cpupower

To build ATLAS you should set the governor for your CPU to performance to get the best optimization:

cpupower frequency-set -g performance
sudo cp /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor

Basically copy the scaling_governor to all cpus (cpu0, cpu1, cpu2 ...) as shown in the last line above. When you set the governor back to e.g. ondemand, follow the same steps.

sudo mkdir /opt/ATLAS
chown ${USER} /opt/ATLAS
mkdir -p ~/tmp/atlas
cd ~/tmp/atlas
wget http://www.netlib.org/lapack/lapack-3.4.2.tgz
wget http://downloads.sourceforge.net/project/math-atlas/Stable/3.10.1/atlas3.10.1.tar.bz2
tar xvf atlas3.10.1.tar.bz2
mkdir build/
cd build/
../ATLAS/./configure --prefix=/opt/ATLAS -Fa alg '-fPIC' --with-netlib-lapack-tarfile=$HOME/tmp/atlas/lapack-3.4.2.tgz --shared
make
make install

Simple as that. You can now change the governor back
cpupower frequency-set -g ondemand
sudo cp /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor
sudo cp /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor
...


netlib BLAS and lapack
pacman -S wget base-devel gcc-fortran cmake
sudo mkdir /opt/netlib
sudo chown $USER /opt/netlib
mkdir /opt/netlib/blas/lib -p
mkdir -p ~/tmp/blas
cd ~/tmp/blas
wget http://www.netlib.org/blas/blas.tgz
tar xvf blas.tgz
cd BLAS/

Edit make.inc
OPTS = -O3 -shared -m64 -march=native -fPIC
make all
gfortran -shared -Wl,-soname,libnetblas.so -o libblas.so.1.0.1 *.o -lc
ln -s libblas.so.1.0.1 libnetblas.so
cp lib*blas* /opt/netlib/blas/lib
cd ../
wget http://www.netlib.org/lapack/lapack-3.4.2.tgz
tar xvf lapack-3.4.2.tgz
mkdir /opt/netlib/lapack
mkdir build/
cd build/
ccmake ../lapack-3.4.2/ -DCMAKE_INSTALL_PREFIX=/opt/netlib/lapack -DBUILD_SHARED_LIBS=ON -DUSE_OPTIMIZED_BLAS=ON 

Hit c twice to configure, then g to generate.
Edit CMakeCache.txt and add the following lines at the beginning:
########################
# EXTERNAL cache entries
########################
 BLAS_FOUND:STRING=TRUE
 BLAS_GENERIC_FOUND:BOOL=TRUE
 BLAS_GENERIC_blas_LIBRARY:FILEPATH=/opt/netlib/blas/lib/libnetblas.so
 BLAS_LIBRARIES:PATH=/opt/netlib/blas/lib/libnetblas.so

Do
ccmake ../lapack-3.4.2/

again, then hit c once, then g.
Next,
make
make install

Done.

Openblas
Copied from here: http://verahill.blogspot.com.au/2013/02/334-compiling-nwchem-with-openmpi-and.html

Download from http://github.com/xianyi/OpenBLAS/tarball/v0.1.1

pacman -S wget base-devel gcc-fortran
sudo mkdir /opt/openblas
sudo chown $USER /opt/openblas
tar xvf xianyi-OpenBLAS-v0.1.1-0-g5b7f443.tar.gz
cd xianyi-OpenBLAS-e6e87a2/
make all BINARY=64 CC=/usr/bin/gcc FC=/usr/bin/gfortran USE_THREAD=0 INTERFACE64=1 1> make.log 2>make.err
make PREFIX=/opt/openblas install
cp lib*.*  /opt/openblas/lib


07 February 2013

335. Compiling sinfo in Arch linux

Note: I'm not abandoning Debian. I'm just going on a roadtrip with Arch to see whether we can all happily co-exist in the same machine park.

sinfo is available in AUR, but it's broken and won't build. Luckily it's very easy to build it yourself.

(see here for debian and here for centos)

mkdir ~/tmp
cd ~/tmp
sudo pacman -S wget base-devel boost asio
wget http://www.ant.uni-bremen.de/whomes/rinas/sinfo/download/sinfo-0.0.47.tar.gz
tar xvf sinfo-0.0.47.tar.gz
cd sinfo-0.0.47/
sed -i 's/\-mt//g' sinfo/Makefile.*
sed -i 's/\-mt//g' sinfod/Makefile.*
./configure
make
sudo make install


Not sure about a suitable systemd script (I'll update somewhere down the line). To start sinfod manually do
sudo sinfod --quiet 

if you have multiple ifaces you can set the --bcastaddress.

To start sinfo itself, well, run sinfo
sinfo

Not much fun with only one node...

334. Compiling nwchem with openmpi and python on Arch linux

Here's the reason why I gave my virtual machine 30 Gb in post 333 -- to be able to evaluate whether I can figure out how to build all the software that I need on Arch.

Behold my surprise when I realised that there's no need for separate -dev packages, as is the case on Debian i.e. the headers are generally installed together with the package (so e.g. python is enough -- you don't need python-dev as well).

While debian is probably the best choice for my nodes (I want stability -- not the latest flashiest stuff), nwchem is a good test case since I've been playing with it for years, and it's not available in the pacman or AUR repos.

Your mileage with openblas will vary depending on your hardware. ACML is an alternative on e.g. FX-8150. ATLAS doesn't seem to work with NWChem when I try it, but I'm not sure what I'm doing wrong. See the original post for examples on how to link to other math libs.

I'm mainly looking at this post: http://verahill.blogspot.com.au/2012/09/briefly-compiling-nwchem-611-with.html


Dependencies:
pacman -S wget base-devel gcc-fortran tcsh openmpi

Openblas:
Download from http://github.com/xianyi/OpenBLAS/tarball/v0.1.1

sudo mkdir /opt/openblas
sudo chown $USER /opt/openblas
tar xvf xianyi-OpenBLAS-v0.1.1-0-g5b7f443.tar.gz
cd xianyi-OpenBLAS-e6e87a2/
make all BINARY=64 CC=/usr/bin/gcc FC=/usr/bin/gfortran USE_THREAD=0 INTERFACE64=1 1> make.log 2>make.err
make PREFIX=/opt/openblas install
cp lib*.*  /opt/openblas/lib

Nwchem:
sudo mkdir /opt/nwchem
sudo chown $USER /opt/nwchem
cd /opt/nwchem
wget http://www.nwchem-sw.org/images/Nwchem-6.1.1-src.2012-06-27.tar.gz
tar xvf Nwchem-6.1.1-src.2012-06-27.tar.gz
cd nwchem-6.1.1-src/

Edit nwchem-6.1.1-src/src/config/makefile.h and edit line 1957 as shown in this post.

Then continue:
export LARGE_FILES=TRUE
export TCGRSH=/usr/bin/ssh
export NWCHEM_TOP=`pwd`
export NWCHEM_TARGET=LINUX64
export NWCHEM_MODULES="all python"
export PYTHONVERSION=2.7
export PYTHONHOME=/usr
export BLASOPT="-L/opt/openblas/lib -lopenblas"
export USE_MPI=y
export USE_MPIF=y
export USE_MPIF4=y
export MPI_LOC=/usr/lib/openmpi
export MPI_INCLUDE=/usr/include
export LIBRARY_PATH=$LIBRARY_PATH:/usr/lib/openmpi:/opt/openblas/lib
export LIBMPI="-L/usr/lib/openmpi -lmpi -lopen-rte -lopen-pal -ldl -lmpi_f77 -lpthread"
cd $NWCHEM_TOP/src
make clean
make nwchem_config
make FC=gfortran 1> make.log 2>make.err
export FC=gfortran
cd ../contrib
./getmem.nwchem

Note that some of the locations are a little bit different from debian.

Edit your ~/.bashrc and add:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/openblas/lib export PATH=$PATH:/opt/nwchem/nwchem-6.1.1-src/bin/LINUX64
You can now test your new binary by running a job, e.g. co.nw:
title "co nmr" geometry c 0 0 0 o 0 0 1.13 end basis * library "6-311+g*" end dft direct grid fine mult 1 xc HFexch 0.05 slater 0.95 becke88 nonlocal 0.72 vwn_5 1 perdew91 0.81 end task dft optimize
Run:

nwchem co.nw

or

mpirun -n 2 nwchem co.nw

06 February 2013

333. Arch linux with Gnome in virtualbox

Not too different from what I've posted before (330, 331), but I'm just so excited that I can't help myself, so here we go:

I'll presume that you've got virtualbox installed.


0. Get the Arch iso:
If you're allowed to use bittorrent:

sudo apt-get install bittorrent squashfs-tools
cd ~/Downloads/
btdownloadcurses https://www.archlinux.org/iso/2013.01.04/archlinux-2013.01.04-dual.iso.torrent

If you're not allowed to use bittorrent:

cd ~/Downloads
wget http://mirror.aarnet.edu.au/pub/archlinux/iso/2013.01.04/archlinux-2013.01.04-dual.iso

Note that the links will change with time.



1. Setting up the machine
Start virtualbox and click on New. Select Type=Linux and Version=Arch Linux.

Give the machine at least 512 Mb, although even that is probably a bit on the low end for Gnome.

Create a virtual harddisk. 8 Gb is enough for testing purposes, but if you're actually planning on using the virtual machine you're better off giving it something like 15-20 Gb. VDI is fine when it comes to format, and 'Dynamically allocated' is a safe choice for a normal desktop.








There's a little bit of tinkering left to do. Click on Settings, go to Storage, and mount your iso:





2. First Boot
Click on Star which will boot off of the CD.


You can pick whatever makes you happy here. For the sake of simplicity will pick the first option -- x86_64.

You're now met with the first indication that this ain't Kansas (or Ubuntu):

Remember -- terminals/consoles should give you warm and fuzzy feeling because there is nothing which you can't accomplish in a terminal. A one-click installation option would be nice for checking things out though, but it's actually pretty easy to get started.


Preparing the harddrive
Our first step is to format the harddrive. Remember, it's an imaginary virtual harddrive -- nothing will be touched on your physical harddrive.

Do

fdisk /dev/sda

Hit n to create a new partition. p for primary, 1 to make it partition number 1, make it start at sector 2048, and make it e.g. 2 Gb by having it stop at +2G -- this will be our swap. Hit n again, p again, and make it partition number 2, and accept the default sectors that it suggests. This will be our  /(root) partition.

Hit a, then 2, to make the partition bootable.

Hit t, then 1, then 82 to make a swap disk.

Hit w to finalise the changes.

Do
mkswap /dev/sda1
mkfs.ext4 /dev/sda2

to set up the file systems.

Do
mount /dev/sda2 /mnt

to mount your new ext4 partition.

Install a basic system:
Do
pacman-key --init
pacman-key --populate archlinux

to get set up with pacman. Edit pacman.conf if you want a specific architecture (i686 or x86_64), or the current architecture will be used.

Time to install packages:
pacstrap /mnt base gnome xorg-xinit xorg-server xorg-utils xorg-server-utils virtualbox-guest-modules virtualbox-guest-utils vim mlocate wicd wicd-gtk openssh grub-bios upower

Generate a proto-fstab:
genfstab -p /mnt > /mnt/etc/fstab

Then enter a chroot:
arch-chroot /mnt

Edit /etc/fstab and add a line for swap:
/dev/sda1    none    swap    sw    0 0

Set up your locale and timezone:
ln -s /usr/share/zoneinfo/Australia/Melbourne /etc/localtime
echo 'LANG="en_US.UTF-8"'>/etc/locale
echo 'KEYMAP=us'> /etc/vconsole.conf
echo 'en_US.UTF-8 UTF-8' >> /etc/locale.gen
locale-gen
echo "spinebill" >/etc/hostname

Set up a user:
pacman -S sudo
useradd -p `openssl passwd -1 mypassword` -m verahill
echo "verahill ALL=(ALL) ALL">> /etc/sudoers

Edit /home/verahill/.xinitrc and uncomment
exec gnome-session

Set up grub and booting:
mkinitcpio -p linux
grub-mkconfig -o /boot/grub/grub.cfg
grub-install /dev/sda

You're now ready to start your Arch system. First you need to shut down your current system though:
exit
umount /mnt
shutdown -h now

Once the machine is off, go to Settings, Storage, and remove disk from virtual drive.



Booting:
Boot by clicking on Start.
You might get the odd error message while booting, but everything will be fine.

Log in as the user you created, then enabled the ssh daemon and the wicd daemon:
sudo systemctl enable sshd
sudo systemctl enable wicd

Start wicd-curses
wicd-curses

and wait 10-20 seconds for wicd to detect the network card and starting it


Quit by hitting 'Q'.

To launch gnome, type
startx
evening gnome?
It'll take a little while to start up. This is a pretty ugly Gnome though, but that's the stock background which changes during the day.
daytime gnome?



332. Gnuplot: bug(?) in current debian testing package

Update 2:
"Note that gnuplot uses both "real" and "integer" arithmetic, like FORTRAN and C. Integers are entered as "1", "-10", etc; reals as "1.0", "-10.0", "1e1", 3.5e-1, etc. The most important difference between the two forms is in division: division of integers truncates: 5/2 = 2; division of reals does not: 5.0/2.0 = 2.5. In mixed expressions, integers are "promoted" to reals before evaluation: 5/2e0 = 2.5. The result of division of a negative integer by a positive one may vary among compilers. Try a test like "print -5/2" to determine if your system chooses -2 or -3 as the answer."

http://www.physics.drexel.edu/courses/Comp_Phys/General/Graphics/gnuplot.html

I guess it's a feature. I guess I just need to remind myself of it every now and again...

Update: version 3.7.3 behaves the same way.


I use gnuplot for fitting data for scientific publications and every time I discover a bug it makes me seriously worried that I've somehow published something which will turn out to be incorrect.

It's not without reason -- Gnuplot version 4.4.0 in Debian Testing garbled small and large numbers: http://verahill.blogspot.com.au/2012/02/debian-testing-wheezy-64-bug-in-debian.html

I'm not sure whether this is a bug, but gnuplot 4.6.0 (current version in debian testing) screws up fractional powers.

gnuplot> print 9**(1/2)
1
gnuplot> print 9**(0.5)
3.0
gnuplot> print sqrt(9)
3.0

Somehow this works:
gnuplot> print 10**(2)
100
gnuplot> print 10**(2.0)
100.0
gnuplot> print 10**(6/3)
100
but not this
gnuplot> print 10**(1)
10
gnuplot> print 10**(1/2)
1
gnuplot> print 10**(1/3)
1
gnuplot> print 10**(0.3333333)
2.15443452467292
gnuplot> print 10**(1/3.0)
2.15443469003188

So the error seems to be due to the usual issue of distinguishing between integer values and real values e.g. the following example in Python 2.7:
>>> print 1/3
0
>>> print 1/3.0
0.333333333333

I still don't think this is intended behaviour in gnuplot, and it's certainly dangerous

Upstreams version 4.6.1
wget http://downloads.sourceforge.net/project/gnuplot/gnuplot/4.6.1/gnuplot-4.6.1.tar.gz
tar xvf gnuplot-4.6.1.tar.gz
cd gnuplot-4.6.1/
./configure --program-suffix=-4.6.1 --prefix=$HOME/.gnuplot-dev
make
make install
cd $HOME/.gnuplot-dev/bin
./gnuplot-4.6.1

gnuplot> print 9**(1/3)
1
gnuplot> print 10**(1/3)
1
gnuplot> print 10**(6/3)
100
gnuplot> print 10**(3/6)
1

03 February 2013

331. A full linux install on a USB stick: Arch and LXDE on a thumbdrive

Update 9 June 2013: I've updated the torrent URL for the current image. Note that you will likely have to do this every month or so. See https://www.archlinux.org/download/ for the latest image.

Original post:
Post 330 (How to install Arch linux) got me thinking: one of my most popular posts is post 70 ("Installing Debian on a USB stick -- live usb vs a true and full installation").

I'm new to Arch and LXDE and Openbox -- I normally run Debian with Gnome 3 -- so I'm probably not doing this the best way. But if you're also new to Arch and struggling with the beginner's wiki you may find some ideas here.

I admit: this post and post 330 aren't that different. Here I basically refine what I did in post 330, and adapt it for desktop use. I also don't have to worry about networking here since we're not talking about a headless box anymore, but an interactive system. There'll most likely be a third post at some point which will be a streamlined version of this post. Anyway.

Whatever I do here will obviously also apply to a desktop installation of Arch -- i.e. if you're struggling with LXDE/openbox on Arch, see here.

 Debian is fine and dandy, but the approach I describe there involves using a virtualbox to install debian on a thumbdrive.

In post 330 I learned how to use a chroot to set things up, which speeds things up significantly (you could of course just boot from a live CD etc., but that's too easy).

 Also, while I'm very happy with debian and it gives pretty small installs if done correctly, Arch might just give even leaner installs.[citation needed]

So here's how to install Arch linux and a graphical DE (LXDE -- I've never warmed to XCE for some reason).

We'll do 32 bit Arch here -- a reason to make a bootable linux drive is so that you can travel with your own safe desktop, and 32 bit linux will work on almost all hardware you're likely to encounter, while 64 bit linux is limited to more modern hardware. Note that if you really want to be secure you will need to encrypt the entire USB stick with e.g. truecrypt -- otherwise in particular your gpg/pgp keys are at risk. Ultimately, security is a matter of vigilance and risk reduction.

You do need a running linux machine  (or at least a live disk) -- I don't know how to do this from Windows.

Approach:
1. Formatting the thumbdrive
2. Chrooting the drive and installing stuff with pacstrap
3. Arch-chroot to install the boot loader, setting up internet, and installing a desktop


Formatting the thumbdrive
Plug in your drive to your running linux machine
df -h
rootfs 28G 21G 5.7G 79% / udev 10M 0 10M 0% /dev tmpfs 397M 852K 396M 1% /run /dev/disk/by-uuid/d7479df8-0d84-4236-a92c-b05327b8fa3d 28G 21G 5.7G 79% / tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 2.3G 728K 2.3G 1% /run/shm /dev/sda5 112G 82G 25G 78% /home /dev/sdb2 937M 18M 872M 2% /media/ext /dev/sdb1 1014M 4.5M 1009M 1% /media/win32
sudo umount /dev/sdb1 /dev/sdb2

Time to start fdisk. First we delete any existing partitions (and data...), then we make one partition, and then we'll make it bootable. We won't bother with a swap disk -- we don't have the space and we want to keep disk i/o to a minimum.

sudo fdisk /dev/sdb
Command (m for help): p Disk /dev/sdb: 2063 MB, 2063597056 bytes 64 heads, 62 sectors/track, 1015 cylinders, total 4030463 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x000cf539 Device Boot Start End Blocks Id System /dev/sdb1 62 2079231 1039585 e W95 FAT16 (LBA) /dev/sdb2 2079232 4027519 974144 83 Linux Command (m for help): d Partition number (1-4): 1 Command (m for help): d Selected partition 2 Command (m for help): n Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p Partition number (1-4, default 1): 1 First sector (2048-4030462, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-4030462, default 4030462): Using default value 4030462 Command (m for help): a Partition number (1-4): 1 Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
Create the filesystem:
sudo mkfs.ext4 /dev/sdb1
mke2fs 1.42.5 (29-Jul-2012) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 125952 inodes, 503551 blocks 25177 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=515899392 16 block groups 32768 blocks per group, 32768 fragments per group 7872 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912 Allocating group tables: done Writing inode tables: done Creating journal (8192 blocks): done Writing superblocks and filesystem accounting information: done
sudo fsck /dev/sdb1
fsck from util-linux 2.20.1 e2fsck 1.42.5 (29-Jul-2012) Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information /dev/sdb1: 11/125952 files (0.0% non-contiguous), 16846/503551 blocks
Make sure to verify you filesystem.


Get the arch iso and set up your chroot:
Note that you will most likely have to update the torrent URL every month or so. Obviously you'll need to change the mount command as well according to the iso name.
sudo apt-get install bittorrent squashfs-tools
cd ~/Downloads/
btdownloadcurses https://www.archlinux.org/releng/releases/2013.06.01/torrent/
sudo mount -o loop archlinux-2013.06.01-dual.iso /mnt
unsquashfs -d arch /mnt/arch/i686/root-image.fs.sfs

If you want x86_64 do unsquashfs -d arch/ /mnt/arch/x86_64/root-image.fs.sfs instead

Time to get busy:
sudo umount /mnt
sudo mount -o loop arch/root-image.fs /mnt
sudo cp /etc/resolv.conf /mnt/etc/resolv.conf
sudo mount -o bind /proc /mnt/proc
sudo mount -o bind /sys /mnt/sys
sudo mount -o bind /dev /mnt/dev
sudo mount -o bind /dev/pts /mnt/dev/pts
sudo chroot /mnt
[root@lithium /]# 

The first chroot:
mount /dev/sdb1 /mnt
mkdir /run/shm
haveged -w 1024
pacman-key --init
pacman-key --populate archlinux

If you're installing i686 (i.e. 32 bit) linux from an x86_64 (i.e. 64 bit) linux, edit /etc/pacman.conf and set Architecture:
Architecture = i686
Continue:
pacstrap /mnt base vim grub-bios openssh wicd lxde-common lxsession desktop-file-utils openbox upower
(196/196) installing openbox [#############] 100% Place menu.xml, rc.xml and autostart in ~/.config/openbox They can be found in /etc/xdg/openbox Optional dependencies for openbox pyxdg: for the xdg-autostart script
This will download a large number of packages (196 packages; ca 178 M download, ca 750 Mb installed), and will take a while. Make sure that all packages end with the architecture you want (e.g. -i686 or -x86_64) or '-any'. I've omitted base-devel above, since you might not need it.

Generate a proto-fstab:
genfstab -p /mnt >> /mnt/etc/fstab

and edit it (/mnt/etc/fstab) to read something like (the uuid will differ):
UUID=c540eff0-0e10-4e7a-9fb6-190a46f38203 / ext4 rw,relatime,data=ordered 0 1 /dev/scd0 /media/cdrom0 udf,iso9660 user,noauto 0 0 /dev/sdb1 /media/usb0 auto rw,user,noauto 0 0
The last two lines will automount CDs and usb sticks. It's not necessarily something you do want to allow -- so you may comment them out.


The second chroot:
arch-chroot /mnt

edit /etc/pacman.conf and change Architecture=auto to i686.

pacman -Syy
ln -s /usr/share/zoneinfo/Australia/Melbourne /etc/localtime
echo "kookaburra" > /etc/hostname

Edit /etc/locale.gen and uncomment the locales you want e.g.
en_GB.UTF-8 UTF-8
locale-gen
echo 'LANG="en_GB.UTF-8"'>/etc/locale
echo 'KEYMAP=us'> /etc/vconsole.conf
mkinitcpio -p linux
grub-mkconfig -o /boot/grub/grub.cfg
grub-install /dev/sdb

Don't screw up that last step! If you put the wrong device the arch install won't boot, and most likely not the system you chrooted it from either. i.e. don't accidentally type /dev/sda (or sdb is you have two disks -- it's not difficult to repair, but you'll need a live CD already prepared)

Continuing to set up LXDE/Openbox and network:

pacman -S ifplugd xorg-xinit xorg-server xorg-utils xorg-server-utils

I've only got nvidia boxes at home, but if you're travelling you're likely to run into intel and ati as well. You can probably skip the last package since we're pulling in nouveau

pacman -S xf86-video-nouveau xf86-video-ati xf86-video-intel xf86-video-nv nvidia


At this point startx would get you a black screen with a mouse cursor. Right-clicking on the background yields a menu, but you don't have anything installed.

There are a couple of services we want to run on boot:
systemctl enable wicd
systemctl enable sshd

Edit /etc/wicd/manager-settings.conf;change wired_interface to whatever you're using in udev.

The pc beep on tab is annoying me:
echo "blacklist pcspkr" > /etc/modprobe.d/nobeeep.conf


Create a user:
pacman -S sudo
useradd verahill -m
echo "verahill ALL=(ALL) ALL">> /etc/sudoers
su verahill
cd ~

mkdir ~/.config/openbox -p
cp /etc/xdg/openbox/*.xml ~/.config/openbox
cp /etc/xdg/openbox/* ~/.config/openbox
echo "exec startlxde" > ~/.xinitrc
echo "export DESKTOP_SESSION=LXDE">> ~/.bashrc
exit


Optional:
At this point we have a setup which supports both wired and wireless internet (depending on drivers) and which has a very rudimentary desktop. We're now using 1.4 Gb, out of which 231 M is the package cache.

The range of programs that you may want to install is probably fairly personal, and will also depend on the size of your USB stick. Here's a basic selection which fits me (install as root, or try sudo, although the latter option works best if you actually boot from your USB stick rather than chroot it):


pacman -S truecrypt firefox chromium thunderbird flashplugin

(when asked, ttf-bitstream-vera is fine)

Miscellaneous packages:
pacman -S conky guake leafpad gparted elinks mcabber mutt gajim screen mlocate xterm lxpanel menumaker obmenu obconf alsa-utils volwheel pulseaudio-alsa

To improve the functionality of screen and vim, see here and here. Setting up Mutt and Mcabber is described here and here. Conky is here (item 4).

To sort out sound you might need to create ~/.asoundrc and fill it with:

pcm.!default.type pulse
ctl.!default.type pulse

(Not everyone is a fan of pulseaudio though)

And see this post for a bit more on encrypting communication and files (I travel in China so these things do matter)): http://verahill.blogspot.com.au/2012/05/encrypting-your-email-chat-and-phone-in.html

Some basic science packages that let's me do basic work on the road:
pacman -S octave gnuplot maxima gummi texlive-science gimp

If you pull in all those packages you'll need a pretty big USB drive though (albeit you actually have a small build environment installed) -- it comes in at about 3.4 Gb. Skip the science stuff to save space.

Mandatory:
And I think that's that. Time to safely umount:
exit
exit
umount /mnt
exit
sudo umount /mnt/proc
sudo umount /mnt/sys
sudo umount /mnt/dev/pts
sudo umount /mnt/dev
sudo umount /mnt

To boot:
Plug in your USB stick and hit whatever key or key-combination during BIOS start up is necessary to interrupt boot and allow you to select your boot device. Sometimes it's F9, F2, F12 or del.

On boot:
Your first task  will be to get your internet up and running. Assuming that you haven't already played with /etc/udev/rules.d you need to find out what the interfaces are called. Do ifconfig -a, note the names, and then start wicd-curses. Select Preferences and enter the name of e.g. the wired interface.

Then start your desktop by running startx. There'll be plenty of menu options, but most programs will be missing, but that's what your ~/.config/openbox/menu.xml is for. And that's how far I've gotten. Time to explore.

Potential issues:
It doesn't always work on first try -- for some reason. I had to start from scratch twice before everything worked without a hitch. Often it's easier starting from scratch than trying to fix a basic installation.

You might not be able to run the systemctl commands until you've actually booted from the usb stick.

If you're on a laptop and the mouse/touchpad isn't working, install xf86-input-synaptics.

Consider installing wicd-gtk if you'll be working a desktop environment a lot.

02 February 2013

330. Installing Arch linux: installing from existing linux onto an external USB HDD

Update: You might want to look at this post instead: http://verahill.blogspot.com.au/2013/02/331-full-linux-install-on-usb-stick.html -- it covers setting up Arch with LXDE (very, very basic set-up -- more openbox than lxde) and wicd

I'll update this post once I've got a good solution to setting up network on headless boxes (i.e. a way of bringing up multiple interfaces without knowing their mac addresses)

Original post:

Note: what follows is what I've 'discovered' while learning. If you have suggestions, feel free to post comments. If you have questions, be aware that I'm only a beginning at Arch myself and will probably not have much advice to offer.

The problem: I have a headless server running 32 bit debian. I don't actually use it much, and so I figured I might as well use it to explore Gentoo or Arch. Given that it's a single core atom I didn't want to risk spending hours compiling things just to get things up and running (Feb/March are busy days at Australian Unis) and I figured that Arch, with it's version of ports, ABS, is a better choice for now.

I'm also curious about systemd, which arch uses by default. (that curiosity has currently turned to frustration)

Why Arch?
I do like my debian, but you need to challenge yourself every now and again. I can also see how a more 'sparse' distro might be a good candidate for my cluster nodes -- less overhead is a good thing. But before doing that I need a test case.

Also, even though I've been using debian I occasionally pay a visit to the Arch wiki and forum when I run into trouble with software that I've compiled myself -- Arch is a lot more bleeding edge than debian (which emphasizes stability), and the information there is often quite good.

Well then...
The easiest way (needing little preparation) by far to install arch would be to use ArchBang which is fast, pretty and functional. I don't need the graphical environment, and I want the learning experience. Otherwise I'd definitely give that a look as well: http://archbang.org/

We'll follow this guide: https://wiki.archlinux.org/index.php/Install_from_Existing_Linux

We'll use method "2: Chroot into LiveCD image".

I've ripped out the harddrive from the headless box and have attached it via USB to my main desktop, which runs Debian Testing.

I've rewritten this guide a couple of time -- not everything worked smoothly from the beginning -- so if it's unreadable and confusing, let me know. Also, due to the lack of versioning in blogspot I have had to try to recover/rewrite from memory, which annoys me.

A word of warning: at one point when working in a chroot I accidentally did grub-install /dev/sda instead of /dev/sdc. I then did update-grub in the main system and rebooted. I should've done grub-install /dev/sda again but from the host system. Anyway, you might screw things up, so a first precaution will be to burn a live CD of some linux distro that you can use to rescue your system with if you mess things up too badly. I'm a debian guy, but I found that the Ubuntu Rescue Remix (http://ubuntu-rescue-remix.org/) was a pretty good thing to have lying around.

Overview:
1. Nuke the existing file system (not necessary, but easier)
2. Get the iso and unsquash it
3. Mount the unsquashed image using chroot, and mount your hdd under it. Get packages
4. Chroot inside the chroot and install the bootloader
5. Set up network


Get started


Format/Prepare your harddrive:
In this case I'm using a 40 Gb hard drive. Since it's so small I'll just partition it to hold one / partition and one /swap partition. We'll make the swap partition 1 Gb which should be plenty, given that the box has 512 Mb RAM. Make sure that you leave enough space before you partition -- 1 Mb is overkill, but is something you can afford. In my original attempt I used palimpsest to format my drive and ended up having to shrink the partition using gparted. Better to use fdisk which may be slightly more challenging, but will give you full control.

Remove the harddrive from your target box, and attach it to your running linux desktop e.g. via USB (or by opening the case and hooking it up via sata/pata). If it automounted, do df -h so see what device it is (here /dev/sdc), otherwise just do ls /dev/sd* before and after it's attached.

df -h
Filesystem Size Used Avail Use% Mounted on /dev/sdc1 36G 15G 20G 43% /media/steelhead
Unmount it:
sudo umount /media/steelhead

We now know that our disk is /dev/sdc, so let's get cracking with fdisk
fdisk -u -l /dev/sdc
Disk /dev/sdc: 40 GB, 40007761920 bytes 255 heads, 63 sectors/track, 4864 cylinders, total 78140160 sectors Units = sectors of 1 * 512 = 512 bytes Device Boot Start End Blocks Id System /dev/sdc1 * 63 78140159 39070048 83 Linux
We want our swap to be 1 Gb. (40007761920 bytes /4864 cylinders)/(1024*1024*1024)=.00766038894653320312 Gb per cylinder or ca 130.5 cylinders per Gb. Our first partition will start at cylinder 2 and run until cylinder (4864-131=)4733.

sudo fdisk /dev/sdc
Command (m for help): d
Partition number (1-1): 1
Command (m for help): n
Partition type e extended p primary partition (1-4)
p First cylinder (default 0cyl): 2 Last cylinder or +size or +sizeMB or +sizeKB (default 4863cyl): 4733 Command (m for help): n
Partition type e extended p primary partition (1-4)
p First cylinder (default 0cyl): 4735 Last cylinder or +size or +sizeMB or +sizeKB (default 4863cyl): Command (m for help): w sudo fdisk /dev/sdc Command (m for help): p
Disk /dev/sdc: 40 GB, 40007761920 bytes 255 heads, 63 sectors/track, 4864 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sdc1 2 4734 38025792 83 Linux Warning: Partition 1 does not end on cylinder boundary. /dev/sdc2 4735 4864 1036192 83 Linux
Command (m for help): a Partition number (1-2): 1 Command (m for help): t Partition number (1-2): 2 Hex code (type L to list codes): 82 Changed type of partition 2 to 82 (Linux swap) Command (m for help): w

The cylinder boundary warning is why we started the next partition on cylinder 4735, so as to avoid overlap. 'a' makes the first partition bootable. 't' creates the swap fs.

Create the file system for partition 1:
sudo mkfs.ext4 /dev/sdc1
sudo mkswap /dev/sdc2


Get the iso:
sudo apt-get install bittorrent
cd ~/Downloads
btdownloadcurses https://www.archlinux.org/iso/2013.01.04/archlinux-2013.01.04-dual.iso.torrent

If you're company/isp/whatever has a blanket ban on P2P (e.g. bittorrent) download the file using regular http, e.g.
cd ~/Downloads
wget http://mirror.aarnet.edu.au/pub/archlinux/iso/2013.01.04/archlinux-2013.01.04-dual.iso

However you downloaded it, do:
sudo apt-get install squashfs-tools
sudo mount -o loop archlinux-2013.01.04-dual.iso /mnt
unsquashfs -d /tmp/squashfs-root /mnt/arch/i686/root-image.fs.sfs

This is for a 32 bit install. Most likely you'll want the 64 bit, so change i686 to x86_64 for that. Also note that the unsquashed image is 1.4 Gb so make sure you put it somewhere with sufficient space.

Continue:

sudo umount /mnt
sudo mount -o loop /tmp/squashfs-root/root-image.fs /mnt
sudo mount -t proc none /mnt/proc
sudo mount -t sysfs none /mnt/sys
sudo mount -o bind /dev /mnt/dev
sudo mount -o bind /dev/pts /mnt/dev/pts
sudo cp /etc/resolv.conf /mnt/etc/resolv.conf
sudo chroot /mnt
[root@beryllium /]#

You're now in the chroot.

In the chroot:
mount /dev/sdc1 /mnt
mkdir /run/shm

Since I am installing 32 bit Arch from a 64 bit host, I had to edit /etc/pacman.conf using nano and change
23 Architecture = auto
to
23 Architecture = i686

If you are installing 64 bit Arch from a 64 bit host you don't need to edit anything. Also, the only editor installed by default is nano, not vi, for some reason.

Finally, edit /etc/pacman.d/mirrors and copy/paste (ctrl+k, ctrl+u) the nearest/most logical mirror to the beginning of the file.

pacman-key --init
pacman-key --populate archlinux
pacstrap /mnt base base-devel vim grub-bios openssh
==> Creating install root at /mnt ==> Installing packages to /mnt warning: database file for 'core' does not exist warning: database file for 'extra' does not exist warning: database file for 'community' does not exist :: Synchronizing package databases... core 105.1 KiB 15.8K/s 00:07 [##################] 100% [..] Total Download Size: 163.59 MiB Total Installed Size: 603.01 MiB [..]
I got a couple of errors above re file systems (during grub init) that arch had no business looking at. I don't think it matters since the next chroot is what's important.
pacman -Syy
genfstab -p /mnt >> /mnt/etc/fstab
cat /mnt/etc/fstab
# # /etc/fstab: static file system information # #

# UUID=ae73518f-5675-486e-8cdd-6579c528ab72 LABEL=steelhead /dev/sdc1 / ext4 rw,relatime,data=ordered 0 1 # UUID=f25a484c-e8e2-4ead-808b-96dd5e915020 /dev/sda5 none swap defaults 0 0
Two problems here:
* Since this will be the only hdd on the new system the root partition is probably /dev/sda1. Change the sdc1 to sda1 above OR use UUID
* Likewise, the swap will be the current sdc2 but the future sda2. Alternatively, get the UUID via blkid.

Here's my new two-line version of fstab with uuid:
UUID=ae73518f-5675-486e-8cdd-6579c528ab72 / ext4 rw,relatime,data=ordered 0 1 UUID=a12b484c-f2d2-4edd-8d8b-76ee6f725020 none swap defaults 0 0
Continue:

arch-chroot /mnt

which gives
sh-4.2#

You're now in a chroot inside a chroot.

A chroot within a chroot:


pacman -Syy
pacman-key --init
pacman-key --populate archlinux
ln -s /usr/share/zoneinfo/Australia/Melbourne /etc/localtime
echo "kookaburra" > /etc/hostname

Kookaburra is the hostname of the new Arch box.

Edit /etc/pacman.conf and change Architecture from auto to i686 if you need to.

Edit /etc/locale.gen and uncomment the locales you want. For me
en_AU.UTF-8 UTF-8 en_GB.UTF-8 UTF-8 en_US.UTF-8 UTF-8

Continue working on boot:
locale-gen
echo 'LANG="en_AU.UTF-8"'>/etc/locale
echo 'KEYMAP=us'> /etc/vconsole.conf
mkinitcpio -p linux
==> Building image from preset: 'default' -> -k /boot/vmlinuz-linux -c /etc/mkinitcpio.conf -g /boot/initramfs-linux.img ==> Starting build: 3.7.4-1-ARCH -> Running build hook: [base] [..] ==> Creating gzip initcpio image: /boot/initramfs-linux-fallback.img ==> Image generation successful
grub-mkconfig -o /boot/grub/grub.cfg
Generating grub.cfg ... Found linux image: /boot/vmlinuz-linux Found initrd image: /boot/initramfs-linux.img done

Check /boot/grub/grub.cfg to see that it exists and that it doesn't look like it's about to blow up. Double-check the uuid vs fstab. Check the 'root'. Mine was wrong. I changed it in /boot/grub/grub.cfg by hand, which isn't recommended but we'll deal with that later. In /boot/grub/grub.cfg change hdX to whatever the correct setting is (counting starts at 0) e.g.
  
        set root='hd0,msdos1'

since /dev/sdc in the future will be the only hdd. Changing this file by hand is untenable in the long run, but our goal is to boot and then regenerate the grub.cfg at a later stage.

grub-install /dev/sdc
Installation finished. No error reported.
Then continue -- in this case we're working with a headless box so we want openssh-server and all that:

passwd
Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully
pacman -S net-tools ifplugd dialog sudo wireless_tools wpa_supplicant wpa_actiond systemctl enable sshd.service systemctl enable net-auto-wired.service systemctl enable net-auto-wireless.service cp /etc/network.d/examples/ethernet-dhcp /etc/network.d/ethli

Edit the /etc/network.d/ethli file as shown in the next section.(the ethli name holds no significance)

adduser verahill -m

Edit /etc/sudoers and add:
verahill ALL=(ALL) ALL
pacman -S pkgtools mlocate htop screen elinks

Time to exit:

sh-4.2# exit
exit
[root@beryllium /]# umount /mnt
[root@beryllium /]# exit

You're now back in your normal host filesystem, and unmount the rest:
sudo umount /mnt/proc
sudo umount /mnt/sys
sudo umount /mnt/dev/pts
sudo umount /mnt/dev
sudo umount /mnt

At this point you have a bootable system. I attached the hdd to my laptop using USB, and chose to boot from it. Went fine. However, it turns out that networking in arch and/or using systemd is very different from debian and initd.

Networking:
Networking should be one of the easiest things in the world to set up, since if you have network access everything else will eventually sort itself out. No network means no remote access via ssh if the screen/keyboard/mouse get screwed up. No network means that you can't install anything. No network means that you can't go online and look up solutions.

initd was easy -- you checked your udev rules, then edited /etc/network/interfaces and added an auto eth0 line followed by e.g. iface eth0 inet dhcp or a more extensive static definition. It was easy.
So I'm a bit frustrated that systemd seems to make the whole process of managing network interfaces so much more difficult. At least for a newcomer.

With systemd your interfaces may not have simple names like eth0 right off the bat, but may have names like enpS08 instead -- it does make things a bit more difficult and unpredictable -- remember that my goal is to get a headless box up and running and that I have no way of getting any error messages -- openssh will simply have to work from the start. I mean, there's a certain logic to systemd, but there are plenty of frustrating issues with it too if you're used to chucking start-up commands in rc.local and setting up your own network devices.

Some of this stuff you could do by hand on a running system, but that's not very helpful when you are working with a headless box where your only option is to connect via ssh (technically I could do rs-232 but I can't find a cable).

Anyway.

Create /etc/udev/10-persisten-net.rules
SUBSYSTEM=="net", ATTR{address}=="00:2e:9e:2e:bb:20", KERNEL=="eth*", NAME="ethli"
SUBSYSTEM=="net", ATTR{address}=="00:e2:bb:be:d4:c8", KERNEL=="wlan*", NAME="wlan0"
and put the mac addresses of you interfaces in it.

Edit /etc/conf.d/netcfg to use the correct WIRED_INTERFACE,
NETWORKS=(ethli ethkb5 ethkb3 wpa-wireless)
WIRED_INTERFACE="ethli"
WIRELESS_INTERFACE="wlan0"
ethkb5, ethb3 and wpa-wireless are other files that I've set up in /etc/network.d/, although at this point they are pretty darned useless -- I can define plenty of profiles, but I can only define a single WIRED_INTERFACE from what I can tell. So only one interface will be started by netcfg.

Copy /etc/network.d/example/ethernet-dhcp to /etc/network.d/ethli, and edit the interface name.
CONNECTION='ethernet'
DESCRIPTION='A basic dhcp ethernet connection using iproute'
INTERFACE='ethli'
IP='dhcp'
Do the same for any other profiles.
For wireless, all you need to do is copy  /etc/network.d/examples/wpa-wireless to /etc/network.d/ and add the password in clear text (i.e. no need to use wpa_password). Change the permissions so that it's 'safe'.

Here's my wpa-wireless
CONNECTION='wireless'
DESCRIPTION='A simple WPA encrypted wireless connection'
INTERFACE='wlan0'
SECURITY='wpa'
ESSID='verahillunwired'
KEY='sadfUsfdjdsfH87j'
IP='dhcp'

The wired network should now start on boot. To launch it manually, just do
sudo netcfg ethli

This is where I'm currently at:
* arch works fine when I boot it by attaching the hdd via usb to a laptop or desktop and booting off of it. I have working internet and the sky's the limit to what can be done

* I can't get it to boot my headless box (or at least not to get a working network connection), and because it's completely headless (it's a server with only eth ports and an RS 232 port) I have no idea why. The logging in systemd leaves a lot to be desired it seems. I'm waiting for an rs-232 cable to arrive via ebay, so we'll see.
The two possibilities that I'm entertaining right now is that either there's an issue with the network devices or...well, I don't know. I'm also getting tired of netcfg and will probably switch to wicd -- it's not quite what I want, but at least I know that it works.
But more about that some other time...

Error 1:
# pacstrap /mnt
==> Creating install root at /mnt
mount: mount point /mnt/dev/shm is a symbolic link to nowhere
==> ERROR: failed to setup API filesystems in new root

Solution:
mkdir /run/shm

On debian /dev/shm points to /run/shm via a symlink, so your chroot has a dead link.

Error 2:
error: key "E62F853100F0D0F0" could not be looked up remotely
error: psmisc: key "FCF2CB179205AC90" is unknown
error: key "FCF2CB179205AC90" could not be looked up remotely
error: reiserfsprogs: key "7F2D434B9741E8AC" is unknown
error: key "7F2D434B9741E8AC" could not be looked up remotely

Solution:
pacman-key --init
pacman-key --populate archlinux

You need to get all the gpg keys so you can check the package signatures.

Error 3:
warning: database file for 'core' does not exist
warning: database file for 'extra' does not exist
warning: database file for 'community' does not exist

Solution:
pacman -Syy

Not sure, but probably due to me interrupting pacman rather rudely with ^C at some point.

Error 4:
# arch-chroot /mnt pacman -S grub-bios
error: failed to prepare transaction (package architecture is not valid) :: package grub-bios-2.00-1-i686 does not have a valid architecture
Solution:
pacstrap /mnt grub-bios

And then skip the arch-root command

Error:
grub-install /dev/sdc
/usr/sbin/grub-bios-setup: warning: your embedding area is unusually small.  core.img won't fit in it..
/usr/sbin/grub-bios-setup: warning: Embedding is not possible.  GRUB can only be installed in this setup by using blocklists.  However, blocklists are UNRELIABLE and their use is discouraged..
/usr/sbin/grub-bios-setup: error: will not proceed with blocklists.

Solution: You partitioned your system without leaving enough space before the first partition. In my case I had 32 sectors*512 bytes.
sudo apt-get install gparted
gparted
Start gparted and shrink the partition. I put 2 Mb (probably overkill) of free space in front, and aligned to cylinder.

01 February 2013

329. ECCE, xterm and X forwarding: fixing broken "tail -f on output" in ECCE/'untrusted X11 forwarding' error


The problem
In ECCE when you highlight a running job on a remote server which you've set up with the frontendMachine option (here and here and here) which is a ROCKS 5.4.3/CentOS server and e.g. hit Alt+L or "Run Mgmt"/"Tail -f on Output file" and nothing happens, and when you set ECCE to provide verbose output (add "ECCE_RCOM_LOGMODE true" to ecce/apps/siteconfig/site_runtime) you see the following errors:

X11 connection rejected because of wrong authentication. X connection to localhost:43.0 broken (explicit kill or server shutdown).
and
OpenSSH_4.3p2, OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008 Warning: untrusted X11 forwarding setup failed: xauth key data not generated Warning: No xauth data; using fake authentication data for X11 forwarding.
Obviously there are non-ECCE related situation where you may see these errors too. Doesn't matter -- same solution.


The diagnostics
cat /etc/ssh/sshd_config |grep X11
X11Forwarding yes X11DisplayOffset 10
cat /etc/ssh/ssh_config |grep X11|grep -v ^#
ForwardX11 yes
sudo cat /etc/ssh/sshd_config |grep X11|grep -v ^#
X11Forwarding yes X11DisplayOffset 10

So, why localhost:43? And why isn't it working? From my workstation to the cluster which is connected to the net via the front node, and then from the cluster front to the cluster front's local name.

ssh -X server.external.dns
echo $DISPLAY
localhost:42.0
ssh -X server.local.dns
Warning: untrusted X11 forwarding setup failed: xauth key data not generated Warning: No xauth data; using fake authentication data for X11 forwarding.
echo $DISPLAY
localhost:44.0
yet
ssh -Y server.local.dns

works fine.

The solution:
Simpler than I thought:
I edited ~/.ssh/config on the server, and did
Host server.local.dns Hostname server.local.dns User me ForwardX11 yes ForwardX11Trusted yes

And now it works!

Presumably I could've just edited /etc/ssh_config instead, but it's a multi-user cluster and I'm happier to change things on a user-by-user basis.