AFS kernel module cannot be built

Problem

I tried to install the OpenAFS client. The package installation failed, complaining that the AFS kernel module could not be built for my Linux kernel:

$ sudo apt install openafs-client
AFS module /lib/modules/3.19.0-28-generic/fs/openafs.ko does not exist.
Not starting AFS.  Please consider building kernel modules using
instructions in /usr/share/doc/openafs-client/README.modules
Setting up openafs-modules-dkms (1.6.7-1ubuntu1) ...
Loading new openafs-1.6.7 DKMS files...
First Installation: checking all kernels...
Building only for 3.19.0-28-generic
Building initial module for 3.19.0-28-generic
Traceback (most recent call last):
  File "/usr/share/apport/package-hooks/dkms_packages.py", line 97, in <module>
    with open(apport.fileutils.make_report_path(report), 'wb') as f:
AttributeError: 'module' object has no attribute 'make_report_path'
Error! Bad return status for module build on kernel: 3.19.0-28-generic (x86_64)
Consult /var/lib/dkms/openafs/1.6.7/build/make.log for more information.
Processing triggers for ureadahead (0.100.0-16) ...

Restarting the OpenAFS service, complained about the missing kernel module:

$ sudo /etc/init.d/openafs-client restart
Stopping AFS services:.
Starting AFS services:
AFS module /lib/modules/3.19.0-28-generic/fs/openafs.ko does not exist.
Not starting AFS.  Please consider building kernel modules using
instructions in /usr/share/doc/openafs-client/README.modules

Running any OpenAFS program, like klog for example, gave a strange error:

$ klog
Unable to authenticate to AFS because a pioctl failed.

Solution

The AFS kernel module did not compile because of changes in recent kernel source code. The bug is reported here. It can be fixed if you can install patches and recompile the kernel or pull a modified kernel from Ubuntu servers.

An easier solution is to get the updated OpenAFS package from their PPA here:

$ sudo apt-get purge openafs-client
$ sudo add-apt-repository ppa:openafs/stable
$ sudo apt-get update
$ sudo apt install openafs-client

The AFS kernel module was compiled successfully when I tried this and everything worked fine!

Tried with: Ubuntu 14.04 and Linux kernel 3.19.0-28

How to change the directory and size of AFS cache

A typical OpenAFS installation uses the /var/cache/openafs directory as a cache for the files and directories you access on the AFS distributed file system. It typically mounts the file system at the local directory named /afs where you can access it as if it existed on your local storage. The commonly used size of the cache is 50MB.

To change any of these 3 parameters, edit the /etc/openafs/cacheinfo file. A typical line in this file is:

/afs:/var/cache/openafs:50000

The first item is the local directory where AFS is mounted, the second is the location of the cache and the third is the size in KB. Change these to any values you want and restart the OpenAFS client for it to take effect:

$ sudo /etc/init.d/openafs-client restart

Tried with: OpenAFS 1.6.7 and Ubuntu 14.04

File too large error on AFS

Problem

You might get this error when you create a file or copy some files in a AFS filesystem: File too large

Solution

This error message is misleading because I found that the file I was creating or copying was not large at all. In fact, an attempt to create an empty file also gave this error!

On investigation, I found that this error happens because the AFS filesystem seems to have a limit of 64435 files in any given directory. If your AFS directory already has this many files, any attempt to create or copy over a file gives the above error.

One possible solution is to archive the files using tar and copy that archive file to AFS.

Tried with: OpenAFS 1.6.1-1 and Ubuntu 12.04 LTS

How to view your disk quota in AFS

In the AFS distributed filesystem, you might be given write access to one or more volumes. To view your disk quota in any of those volumes, change to any directory in the volume and use this command:

$ fs listquota -human

This prints out the size of your disk quota on that volume and how much of that is already occupied by files.

Tried with: OpenAFS 1.6.1-1 and Ubuntu 12.04 LTS

How to give user access to a file or directory in AFS

A user can be given access to a file or directory in AFS by using the fs program. Using the setacl parameter of the program, the user can be given one or more of these permissions: r (read), w (write), l (list), k (lock), i (insert), d (delete) and a (change ACL).

For example, to give joe access to read, write and list contents of a directory Foo:

$ fs setacl Foo joe rwl

Tried with: OpenAFS 1.6.1-1

How to find out when your AFS authentication expires

The tokens program can be used to find out the tokens you have with AFS servers. With each token, the date and time of its expiry will also be displayed. This tells you when your authentication with that AFS server expires. If you do not see a token for that AFS server, then your authentication for it has already expired.

Tried with: Ubuntu 12.04.1 LTS

How to authenticate with AFS

You need to authenticate with the authentication server of the Andrew File System (AFS) before you can access files on it. This is done using the klog program.

If your username on AFS is the same as the username you are using on your computer:

$ klog

If your username on AFS is different, say afs-joe, then use this:

$ klog -principal afs-joe

In either case, you will be asked for your password. Use the password that works with AFS, not your local password.

Tried with: Ubuntu 12.04.1 LTS