Clock skew detected during make


I was trying to build source files on a remote server using make. The make command would sometimes throw up a clock skew warning like this:

make[2]: Warning: File `foobar.cpp' has modification time 36 s in the future
make[2]: warning:  Clock skew detected.  Your build may be incomplete


It turns out that these source files were actually shared from another computer to this remote server using NFS. Using the date command at the local computer and the remote server, I found that there was a difference of a few seconds between the two.

More investigation showed that only the local computer was using NTP and so its time was correct. The remote server was not using NTP and so its time was wrong.

To install and enable NTP on the remote server, I used these commands:

$ sudo apt install ntp
$ sudo service ntp reload

Note that it takes a few minutes for the synchronized correct time to show up on the computer after these commands. After the sync, I no longer get the clock skew warnings from make.

Reference: Time Synchronisation with NTP

Tried with: Ubuntu 16.04


NFS error access denied by server while mounting


I wanted to share a directory that was on my local computer to a remote computer named medusa using NFS. I did the setup of the NFS server on my local computer and NFS client on the remote computer as described here. However, when I mounted the NFS share on the remote computer, I got this error:

$ sudo mount /mnt/my_nfs_share
mount.nfs: access denied by server while mounting my-local-computer:/path/i/shared


This turned out to be tricky one! The error message is quite a bit misleading because it turned out that the problem had nothing to do with access. Turns out this remote computer medusa had two Ethernet cards and thus two IP addresses. One of the IP addresses was set to the hostname medusa, but the NFS client was using the second IP address.

The solution was to add the second IP address as an entry in the /etc/exports file:

/path/i/shared medusa(rw,sync,no_subtree_check)

The rest of the steps I repeated as described in this post. Everything worked fine and I was able to mount the NFS share on the remote computer.


Tried with: Ubuntu 14.04

How to view NFS mount options

If your NFS directory is automatically mounted at boot, then find its mount options in /etc/fstab. There might be options such as defaults which are expanded to actual options at mount. These can be found in its actual mounted entry in /etc/mtab. For example, using defaults on my machine expands to rw,vers=4,addr=nfs_server_ip,clientaddr=nfs_client_addr

If it is mounted manually at the shell, then find its mount options in /etc/mtab.

How to check filesystem of path

There are times when I find it useful to know which filesystem a directory belongs to. For example, I find that Git is very slow in directories that are in NFS mounts. So, I like to disable Git-related actions in my shell when the PWD is in a NFS mount.

An easy way to check the filesystem of a path is:

stat --dereference --file-system --format="%T" /path/to/check

Or the shorter version:

stat -L -f -c "%T" /path/to/check

On a directory in a NFS mount, this returns me nfs. On a locally mounted directory, it returns ext2/ext3. You can use this return value in your shell scripts to control what happens based on the filesystem.

If you find this type of lookup useful, you might want to create a shell alias for it.

How to share directory over SMB using Samba Server Configuration

Share a directory over SMB
Share a directory over SMB

You can share a directory on your computer using NFS, as described in this post. Another alternative is to share it over SMB using Samba, especially if you have Windows computers on your network. This can be a great way to share your family photos, music and video files to all the notebooks, phones and tablets connected on your home network.

Samba Server Configuration is a simple GUI utility that makes configuration and sharing directories over SMB extremely easy. For every directory you share using this utility, it adds the relevant section to your /etc/samba/smb.conf file.

Installing this utility is easy:

$ sudo apt-get install system-config-samba

To run the utility type Samba in the Dash or sudo system-config-samba at the shell.

Adding a directory to share is easy. Choose File > Add Share and provide the directory path, the name it should appear as in SMB, choose whether it should be writeable and visible.

In the Access tab, choose whether you want everyone to access the directory or just some specific users. If you choose everyone then no login or password is required by SMB clients to access this shared directory. If you pick some users, then the SMB clients need to provide one of those user and password to access this shared directory. Choose Add and you are done.

For sharing with everyone, you need an extra customization. Find the section in /etc/samba/smb.conf that refers to the shared directory and provide an username that should be forcefully used when anyone accesses this share:

    path = /home/joe/pics
    guest ok = yes
    ; Add the line below
    force user = joe

To restart the Samba server after making these changes:

$ sudo service smbd restart

Tried with: system-config-samba 1.2.63 and Ubuntu 14.04

How to access a NFS shared directory from Raspbmc

Raspberry Pi running Raspbmc functions as an excellent HTPC.Β If you have videos, music or photos on one of your home Ubuntu or Linux computers, then it might be convenient to access or view the media right from your Raspbmc over the home network. The easiest way to do this is to share the media files in a NFS shared directory and access that from Raspbmc as NFS client. I am assuming that the Ubuntu computer and Raspbmc are connected to the same wireless router or the same home network.

First setup the Ubuntu computer:

  1. Your Raspbmc will access your Ubuntu computer using its IP address. So, it might be convenient to configure a static IP address for the Ubuntu computer. In any case, note down the IP address of the Ubuntu computer.
  2. Create a directory and make sure the directory name has no spaces in it. Drop all the media files you want to share into this directory. Share this directory using NFS.

Next setup the Raspbmc to access the shared directory:

  1. Make sure you can ping the Ubuntu computer from the Raspbmc. You can do this by SSH to Raspbmc (here is how) and pinging the IP address of the Ubuntu computer.
  2. Assuming you want to access the video files in the shared directory. (The steps for Audio is similar, just use the Audio menu in these steps). In XBMC, go to Videos β†’ Files β†’ Add videos β†’ Browse
  3. In the Browse dialog, choose Network Filesystem (NFS). The IP address of your Ubuntu computer must be listed here. Enter it and pick the shared directory and choose OK.
  4. The Ubuntu computer shared directory now appears in the listing, choose OK. Press OK in the next dialog. Now the shared directory is visible in the Files listing and you should be able to browse through the media files inside it and play them whenever needed.

Have fun playing the content from your Ubuntu computer on your Raspbmc πŸ™‚

Tried with: Ubuntu 12.04 LTS and Raspbmc Release 1.0

How to setup NFS server and client

NFS is a popular method to share a directory for read and write access between two Linux computers. The computer whose hard disk where the shared directory actually resides is the NFS server. The computer which will mount the directory on the NFS server for read and write access is the NFS client.

On the NFS server computer

  • Install the NFS server software:
$ sudo apt install nfs-kernel-server
  • Add an entry in /etc/exports that informs the NFS server which directory is being shared, to which computer on the network and with what settings.

  • For example, if user joe_on_server wants to share his workspace directory to all computers on the network:

/home/joe_on_server/workspace *(rw,sync,no_subtree_check)

The * indicates that NFS clients of all IP addresses can access this shared filesystem. rw indicates that the NFS client can read and write to this directory. async improves performance. no_subtree_check also improves performance by not checking the sub-directories. no_root_squash prevents the normal behavior of converting access by root user to normal user. insecure turns off the checking if the access is originating from reserved ports. More information about the options can be seen in man exports.

  • If we want to share only with a specific computer on the network, then specify its IP address or hostname:

Remember to ping and be sure that the hostname or IP address works.

  • If the user on the NFS client machine has a different UID or GID from the UID or GID of the directory and files being shared from the NFS server, you will get permission denied errors. If this is the case, then specify what UID and GID on the NFS server should be used to map all users who access on NFS client:
  • Export the share:
$ sudo exportfs -a
  • Restart the NFS server:
$ sudo service nfs-kernel-server restart
  • Check if the share is visible:
$ showmount -e

On the NFS client machine

  • Install NFS client software:
$ sudo apt install nfs-common
  • Check if the share of server is visible:
$ showmount -e nfs_server_hostname
  • Create a directory where you want to mount the NFS share:
$ sudo mkdir /mnt/joe_nfs_share

I do not recommend mounting to a directory inside your home directory. This can lead to all kinds of irritating UID and GID permission problems.

  • Add an entry in /etc/fstab to request NFS to mount to this directory:
nfs_server_hostname:/home/joe_on_server/workspace  /mnt/joe_nfs_share none bind 0 0
  • Mount the NFS share:
$ sudo mount /mnt/joe_nfs_share

That is it! You should be able to have read and write access to files in your NFS share on the client machine.

If you run into any problems, please check these:

  • Hostname or IP should be pingable
  • UID and GID of users on NFS server and NFS client machines
  • If you make any change to file permissions, remember to umount on NFS client machine and mount again.

I found the NFS Overview and Gotchas very useful to setup and debug my NFS problems.

Tried with: Ubuntu 14.04