nfs4 and all_squash

all_squash does not work when directory/share is on the same filesystem. Example:

/etc/exports:

/media/mount 192.168.0.0/24(rw,async,no_subtree_check,fsid=0)
/media/mount/folder 192.168.0.0/24(all_squash,anonuid=1000,anongid=100,rw,async,no_subtree_check)

We have to mount folder with a bind to get this working. Move folder to new location, here I’m hiding it:

mv /media/mount/folder /media/mount/.folder
mkdir /media/mount/folder

/etc/fstab:

/dev/sdb1 /media/mount ext4 defaults 0 0
/media/mount/.folder /media/mount/folder none bind 0 0

Mount and reload nfs exports:

mount /media/mount/folder
exportfs -r

Reference: http://www.spinics.net/lists/linux-nfs/msg16593.html

nVidia HDMI audio

Check which hardware devices are avaiable:

sudo aplay -L

Check which device monitor is connected to:

speaker-test -c 2 -r 48000 -D hw:1,3
speaker-test -c 2 -r 48000 -D hw:1,7
speaker-test -c 2 -r 48000 -D hw:1,8
speaker-test -c 2 -r 48000 -D hw:1,9

Pulseaudio automatically loads first hardware device(0,3 or 1,3). Manually load another in /etc/pulse/default.pa:

load-module module-alsa-sink device=hw:1,7

Source: ftp://download.nvidia.com/XFree86/gpu-hdmi-audio-document/gpu-hdmi-audio.html

mount by network location

/etc/fstab:

host.lan:/ /media/mount nfs4 _netdev,noauto,users,async 0 0

/usr/local/bin/network-mount:

#!/bin/bash
stasjon=/media/mount
ping=`/usr/bin/fping -q host.lan`
if [ $? = 0 ]; then
  mountpoint $stasjon > /dev/null
  if [ $? != 0 ]
    then mount $stasjon
  fi
  else
  mountpoint $stasjon > /dev/null
  if [ $? = 0 ]
    then umount -l $stasjon
  fi
fi

chmod +x /usr/local/bin/network-mount
crontab -e

* * * * * /usr/local/bin/network-mount

PDF toolkit – split/merge PDFs

I had some schoolwork scanned to a PDF-document, with odd pages in one document and even pages in another. The pages was also in wrong order. I was looking for an easy way to rearrange the pages in a single document. No fancy interface reacquired, a understandable command line would do. PDF toolkit is this.

Install

apt-get install pdftk

Merge

pdftk A=file1.pdf B=file2.pdf cat A1 B2 A2 B1 output output.pdf

This will make an PDF document “output.pdf” with four pages. Page 1 in output.pdf being the first page from file1.pdf, page 2 being the second page from file2.pdf and so on.