Mounting NFS share with autofs

      No Comments on Mounting NFS share with autofs

Statically mounting remote filesystems via /etc/fstab can be quite impractical on mobile devices such as notebooks that are frequently used in different network environments where the share is not always available. To take care of this, there’s a great tool called autofs that let’s you mount remote filesystems on demand.

Let’s assume, there’s an NFS server running in our network that exports a certain directory:

$ showmount -e Server
Export list for Server:
/data Client

To install and enable the autofs daemon, run:

# yum install autofs
[...]
# systemctl enable autofs.service
# systemctl start autofs.service

As soon as you try to access the remote filesystem, it should get automagically mounted:

# ls -lh /net/Server/data/
[...]

Note that the subdirectory for the host isn’t created until you access it. You can also use so-called direct maps, that can’t be changed on the fly but require a HUP signal to refresh.

To use a direct map, edit /etc/auto.master and include the following line:

[...]
/- /etc/auto.data
[...]

Add /etc/auto.data with the following content:

/data   -soft,rw,exec,intr      Server:/data

The options should be quite self-explanatory. For a more comprehensive list, have a look at the autofs manpage.

Resources:
http://marcofalchi.blogspot.de/2013/05/fedora-19-autofs-nfs-share-from-centos.html

Resolve local hostname with nss-myhostname

      No Comments on Resolve local hostname with nss-myhostname

Many applications rely on a fully qualified domain name and won’t work properly or even fail to start without one. For example, even if your hostname is correctly set up, apache won’t start with the default configuration on Fedora 19 if your DNS server cannot resolve the hostname:

AH00557: httpd: apr_sockaddr_info_get() failed for HostName
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message

But fortunately there’s a plugin to the GNU Name Service Switch (NSS) of glibc called nss-myhostname that ensures, that the local hostname is always resolvable.

Since Fedora 19, nss-myhostname is no longer a separate package but part of the systemd package. To enable the plugin, open /etc/nsswitch.conf with you favourite editor and add myhostname to the line starting with hosts:

[...]
hosts:     files dns myhostname
[...]

Setting the hostname in Fedora 18

      No Comments on Setting the hostname in Fedora 18

Staring with Fedora 18, the hostname is longer set it /etc/sysconfig/network but in /etc/hostname. To manipulate the hostname there’s a small tool named hostnamectl which is part of Fedora’s systemd package.

The following table (taken from the Fedora 18 Release Notes) shows a few basic hostnamectl commands to set or change a host’s name:

CommandFunction
hostnamectl set-hostname fedorasystem --prettySet pretty hostname.
hostnamectl set-hostname fedorasystem.example.org --staticSet static hostname.
hostnamectl set-hostname fedora-dhcp-client.example.org --transientSet transient hostname.
hostnamectl set-hostname fedorasystem.example.orgWithout arguments, hostnamectl will apply to all hostname types.
hostnamectl statusShow current hostname settings

See also hostnamectl manpage.

Flashing Gen7 bootloader with avrdude

      No Comments on Flashing Gen7 bootloader with avrdude

The Arudino IDE Support package also contains different bootloaders for quite a few variations of the Generation 7 Electronics RepRap controller board.

The Arudino IDE Support wiki page at the RepRap wiki also contains a paragraph on how to flash the bootloader onto the Gen7 board with avrdude. It suggest to write the fuses first, the flash the hex file onto the microcontroller and lock the bootloader afterwards. While there’s nothing wrong with that, it can be done in a single command:

$ avrdude -pm1284p -cstk500 -P/dev/ttyUSB0 \
-U lock:w:0x3F:m \
-U flash:w:bootloader-1284P-20MHz.hex \
-U lfuse:w:0xf7:m \
-U hfuse:w:0xdc:m \
-U efuse:w:0xfc:m \
-U lock:w:0x0F:m

Of course, the parameters regarding the processor and the programmer port may be different.

The actual bootloader hex files can be found in the Gen7 Arudino IDE Support package. Probably the easiest way to get it is to clone Traumflug‘s Gen7 git repository

$ git clone https://github.com/Traumflug/Generation_7_Electronics.git

The hex files can be found in: Generation_7_Electronics/arduino support/Gen7 Arduino IDE Support/Gen7/bootloaders/Gen7/

Make sure to choose the right one for your microcontroller and clock speed. The fuses for the different microcontrollers are listed in Generation_7_Electronics/arduino support/Gen7 Arduino IDE Support/Gen7/boards.txt

Search contents of multiple pdf files

      No Comments on Search contents of multiple pdf files

pdftotext is a handy little tool to convert pdf files to plain text. It’s part of Fedora’s poppler-utils package and can be installed with yum:

# yum install poppler-utils

You can use pdftotext and the GNU findutils to search for a specific string in multiple pdf documents:

$ find /path -name '*.pdf' -ls -exec pdftotext {} - \; | grep -i "string"

See also pdftotext manpage, find manpage, grep manpage

Viewing package changelogs with yum

      No Comments on Viewing package changelogs with yum

To quickly review the latest changes to an rpm package, there’s a handy plugin for yum called yum-changelog. It’s part of the Fedora repository and can be installed by invoking

# yum install yum-plugin-changelog

The usage is quite self-explanatory, but here a a few useful examples anyway:

To list the whole changelog history of a package, run

# yum changelog all <packagename>

To list the changelog of a specific time period, e.g. this year:

# yum changelog 2013-01 <packagename>

To list the changelog of packages about to be updated:

# yum update <packagename> --changelog

Updating STK500 firmware

      No Comments on Updating STK500 firmware

Unfortunately, Atmel does not ship a hex file for their STK500 development system that could be used to update the firmware using 3rd party tools like avrdude. Instead, an encrypted ebn-file comes with the latest Atmel Studio. The tools that is used to flash the firmware onto the ATmega8535 is a bit dull, though.

Preparing serial connection

First, hook up the DB9 port on your STK500 that is marked as RS232 CTRL to your PC. Since the flash tool AvrProg.exe only searches for devices on COM1, make sure that you connected it to COM1 or if you use a USB-to-Serial converter, change its address to COM1 (Device Manager → Right-click on the COM port you wish to reassign → Properties → Port Settings → Advanced → COM Port Number → COM1). The port settings should read as 9600 8N1.

Preparing the STK500

Now, power off the STK500 and make sure, the push button labeled PROGRAM is pressed while turning on the power again. The LED labeled STATUS shouldn’t be lit permanently (like it would in normal operation mode).

Flashing the firmware

Startup Atmel’s flash tool AvrProg.exe that is installed along with Atmel Studio. The default installation location is %ProgramFiles%\Atmel\AVR Tools\AvrProg\AvrProg.exe.
%ProgramFiles% is localized and depends on your architecture. It’s most likely going to be C:\Program Files or C:\Program Files (x86).

Load the firmware file using the 'Browse' button and flash it.

Load the firmware file using the ‘Browse’ button and flash it.

Next, load the STK500.ebn firmware file by pushing the Browse button. The default location is %ProgramFiles%\Atmel\AVR Studio 6.0\tools\STK500\STK500.ebn. After hitting Flash → Program, a progress bar should appear and shortly after the status indicator should tell you that the devices has been successfully programmed.

Device was successfully programmed.

Device was successfully programmed.

If you restart the STK500 by turning off the power and turning it back on again, the firmware should be up and running. You can double-check with avrdude, for example.

$ avrdude -p atmega32 -c stk500v2 -P /dev/ttyUSB0 -n -v
[...]
         Programmer Type : STK500V2
         Description     : Atmel STK500 Version 2.x firmware
         Programmer Model: STK500
         Hardware Version: 2
         Firmware Version Master : 2.10
         Topcard         : Unknown
         Vtarget         : 5.1 V
         SCK period      : 10.9 us
         Varef           : 5.0 V
         Oscillator      : 3.686 MHz