# Got afs work on 2.6 Kernel

## Weaselweb

Hi people,

i want to write a mini-how-to for using afs under a 2.6 kernel. I tested it with openafs 1.3.73 and kernel 2.6.9-r1.

Before we start: According to the hint from furanku, make sure you have defined PORTDIR_OVERLAY in your /etc/make.conf (If not define it) or your changes will be deleted, the next "emerge sync" is being executed. I used PORTDIR_OVERLAY="/usr/local/portage" and the instructions will follow this definition. Create the directories until /usr/local/portage/net-fs/openafs/files, if it doesn't allready exists.

```
mkdir -p /usr/local/portage/net-fs/openafs/files
```

will create all required directories.

First: Get the ebuild. Rename it to openafs-1.3.73.ebuild to use the newest version of openafs. Copy/Move it to /usr/local/portage/net-fs/openafs

2.: This ebuild is hard-masked, so you have to unmask openafs-1.3

```
echo "=net-fs/openafs-1.3*" >> /etc/portage/package.unmask
```

3.: You have to build a digest, type in your console (note: this will download the openafs-1.3.73-src.tar.bz2, if not allready done)

```
ebuild /usr/local/portage/net-fs/openafs/openafs-1.3.73.ebuild digest
```

 and compare the MD5 in "/usr/local/portage/net-fs/openafs/files/digest-openafs-1.3.73" with those from the openafs site.

4.: Emerge openafs by typing

```
emerge openafs
```

It should comile without errors. I hadn't any.

5. The standard init.d script didn't work for me. I had to edit it.

This is the diff-output:

```
--- ../../../etc/init.d/afs   2004-10-24 22:02:14.000000000 +0200

+++ ../../../usr/portage/net-fs/openafs/files/afs.rc.rc6   2004-01-21 18:49:27.000000000 +0100

@@ -82,7 +82,7 @@

    # For now, just use uname -r to get the module version. 

    VERSION=`uname -r`

 

-   LIBAFS=libafs-$VERSION$MP.ko

+   LIBAFS=libafs-$VERSION$MP.o

 }

 

 #

@@ -94,7 +94,7 @@

 # a kernel built from ftp.kernel.org

 #

 

-KSYMS_FILE=/proc/kallsyms

+KSYMS_FILE=/proc/ksyms

 SEARCH_STR="unregister_filesystem"

 DEFAULT_SMP_PREFIX="smp_" # Redhat kernels need "smp" instead

 PREFIX="" # none needed for UP with <= 1Gig memory

@@ -105,7 +105,7 @@

    h8="$h$h$h$h$h$h$h$h"

    prefix_set=0

 

-   set X `fgrep $SEARCH_STR $KSYMS_FILE 2> /dev/null`; shift; shift

+   set X `fgrep $SEARCH_STR $KSYMS_FILE 2> /dev/null`; shift

    str=$2

    case $str in

    ${SEARCH_STR}_R$h8)

@@ -156,7 +156,7 @@

 

    # use the prefix command if required

    set_prefix

-   /sbin/insmod ${PREFIX:+-P $PREFIX} -f $MODLOADDIR/$LIBAFS > $MODLOADDIR/libafs.map #2>&1

+   /sbin/insmod ${PREFIX:+-P $PREFIX} -f -m $MODLOADDIR/$LIBAFS > $MODLOADDIR/libafs.map 2>&1

 }

 

 start(){
```

Some comments to the change, that everybody could follow me:

1. My module has the suffix .ko

2. /proc/ksyms doesn't exist on 2.6. So i used /proc/kallsyms 

3. I added a "shift" because on 2.6 there was one row added, now we want row 3

That's a 2.4 output (fgrep unregister_filesystem /proc/ksyms):

```
c02371f0 unregister_filesystem_Rsmp_1090531f
```

Compare it with that from 2.6 (fgrep unregister_filesystem /proc/kallsyms). We just need the first line:

```
c01736a0 T unregister_filesystem

c01736a0 U unregister_filesystem        [nfs]

c01736a0 U unregister_filesystem        [sunrpc]

c01736a0 U unregister_filesystem        [libafs]

c01736a0 U unregister_filesystem        [ntfs]

c01736a0 U unregister_filesystem        [xfs]
```

4. I removed the "-m" parameter, becaue it doesn't work for me. Try it your own.

Finally don't forget to crate an ext2 partition described in the Gentoo Linux OpenAFS Guide.

Edit your "/etc/afs/CellServDB" and "/etc/afs/ThisCell" to your needs. In the guide named above it is recommended to do this before emerging, but i didn't so and it works to. So the defaults in "/usr/poratge/net-fs/openafs/files/" aren't overwritten.

After doing that just start "/etc/init.d/afs start" and hope that it works (it should). Now you can browse the afs in /afs directory.

Just do "klog" to get an afs ticket. If your local name and that from the afs isn't the same, use "klog -principal <afs name>" instead.

Now "emerge sync" doesn't delete our own ebuild files. Thanks again to furanku. Changes are corrected above. If you read this the first time, all will be fine.

I hope i could help somebody with the afs on 2.6 kernel. Comments and tips are very welcome.

greetings

WeaselwebLast edited by Weaselweb on Tue Oct 26, 2004 1:54 pm; edited 1 time in total

----------

## rabbit

Here at Clarkson we're trying something similar and are having issues.  We'll try out your ebuild and see if it works.

As far as losing the ebuild/digest and such, all you need to do is use a portage overlay instead of placing it in the default portage directory.

----------

## Weaselweb

it's not my ebuild file, i just used the link from another posting.

can you give me some hints/links for the portage overlay, so i can change the howto for the others.

regards

Weaselweb

----------

## furanku

Just put the ebuild in /usr/local/portage (or wherever PORTAGE_OVERLAY in /etc/make.conf points to), not in /usr/portage. Probably you have to create some directories to mirror the structure of /usr/portage (e.g. /usr/local/portage/net-fs/openafs).

Thanks for the HOW-TO!

----------

## Weaselweb

thanks

it has been changed. But notice it's not PORTAGE_OVERLAY, it's PORTDIR_OVERLAY   :Very Happy:  Compare with "emerge info"

regards

Weaselweb

----------

## furanku

Oooops  :Wink: 

Of course, you're right! But on the other hand: At least, it shows that I have a life, not to know all portage relevant env-vars by heart.

Anyway, thanks again for the howto and the correction!

----------

## Weaselweb

 :Smile:  That's ok.

----------

## dma

I just got fed up with it so I did:

# insmod /usr/vice/etc/modload/libafs-2.6.8-gentoo-r3.ko 

# afsd 

to load it and

# umount /afs 

# rmmod libafs

to unload it.  without the initscripts.

BTW if there are any problems with that ebuild, you can blame me.  :Neutral: 

----------

## Weaselweb

If it works, why not?

But i prefer init.d-scripts. So everybody has to do their own thing.

Greetings

Weaselweb

----------

## TimG

I'm using this along with the guide to try to set up an afs server.  Everything works until I get to code listing 4.19 in the guide.  When I run:

```
/usr/afs/bin/fs setacl /afs system:anyuser rl
```

I get:

```
fs:'/afs': Function not implemented
```

Any idea what I where I should be looking for the problem?

The services seem to be running correctly

bos status mymachine -long -noauth gives me:

```
Instance kaserver, (type is simple) currently running normally.

    Process last started at Sat Nov  6 19:44:46 2004 (1 proc starts)

    Command 1 is '/usr/afs/bin/kaserver'

Instance buserver, (type is simple) currently running normally.

    Process last started at Sat Nov  6 19:44:46 2004 (1 proc starts)

    Command 1 is '/usr/afs/bin/buserver'

Instance ptserver, (type is simple) currently running normally.

    Process last started at Sat Nov  6 19:44:46 2004 (1 proc starts)

    Command 1 is '/usr/afs/bin/ptserver'

Instance vlserver, (type is simple) currently running normally.

    Process last started at Sat Nov  6 19:44:46 2004 (1 proc starts)

    Command 1 is '/usr/afs/bin/vlserver'

Instance fs, (type is fs) currently running normally.

    Auxiliary status is: file server running.

    Process last started at Sat Nov  6 19:44:46 2004 (2 proc starts)

    Command 1 is '/usr/afs/bin/fileserver'

    Command 2 is '/usr/afs/bin/volserver'

    Command 3 is '/usr/afs/bin/salvager'

Instance upserver, (type is simple) currently running normally.

    Process last started at Sat Nov  6 19:44:46 2004 (1 proc starts)

    Command 1 is '/usr/afs/bin/upserver -crypt /usr/afs/etc -clear /usr/afs/bin'
```

----------

## Weaselweb

Puh, about an afs-server i can't tell you anything, sorry. That's too much for my 3 PCs   :Wink:  I prefer NFS.

My only intend was to use the afs-client

Regards

Weaselweb

----------

## TimG

I figured it out.  

I had to do:

```

insmod /usr/vice/etc/modload/libafs-2.6.9-gentoo-r1.mp.ko

afsd &

```

Then 

```
fs setacl /afs system:anyuser rl

```

worked fine.

----------

## TimG

This works with 1.3.74 too.

----------

## Thiemo

I successfully compiled 1.3.75 though I didn't yet try to set up and get working afs.

Cheers

Thiemo

----------

## Weaselweb

1.3.75 works

and 1.3.76 works for me.

Hoplefully for others too.

Regards

Weaselweb

----------

## KermitTheFragger

1.3.77 Works also, I also configed AFS and it works like a dream. Man i really love AFS  :Smile: 

----------

## stevew

Please post your init scripts or any info on how to get them working; I seem to be able to bring afs up by hand, but following what I've been reading in these forums, the init script isn't doing so well.

Also, the ebuilds (for openafs with 2.6 kernel on x86) I've tried doesn't seem to do much with the contents of the files directory, which in the 1.2 version is populated with lots of interesting stuff; where are these files supposed to come from for openafs-1.3.7x? 

Thanks!

----------

## Weaselweb

Afs doesn't compile under 2.6.10  :Exclamation: 

After some googling i found this post in the openafs mailing list:

 *Quote:*   

> > /usr/src/openafs-1.3.73/src/libafs/MODLOAD-2.6.10-rc1-MP/afs_osi.c:861:
> 
> >               error: `TASK_ZOMBIE' undeclared (first use in this function)
> 
> Apparently they removed TASK_ZOMBIE from the kernel between 2.6.9 and
> ...

 

Although they write about 1.3.73 i think that hasn't changed in actual version of afs.

So i think, if you want to use afs, u must stay at kernel version <= 2.6.9

Greetings

Weaselweb

----------

## discostu

I wasn't able to get either 1.3.73 or 1.3.77 to build using the howto from the first post (this is under 2.6.10-gentoo-r4). It's due to the TASK_ZOMBIE thing that Weaselweb mentioned.

----------

## depontius

The recent weekly news mentioned how the 2005.0 release was going to start "urging" people to the 2.6 kernel, unless they took steps to stay at 2.4. I doubt this really matters as long as I stay at my 2004.3 profile, and when I migrate I'll make sure to go to the 2.4-specific 2005.0 profile.

But I really would like to be running a 2.6 kernel. 

OpenAFS is the one package keeping me at 2.4. I wonder if TPTB are aware of this block. Maybe it's time for me to join Bugzilla and Gentoo-users, instead of just the forums.

----------

## irondog

I can't get AFS working. 

```

afsd & 

afsd: All AFS daemons started.

afsd: Can't mount AFS on /afs(22)

```

----------

## Jinidog

Is there write-support or only read-support, as described in the kernel help?

----------

## Weaselweb

The kernel drivers afair support read-only. But the openafs support write/read-access.

@irondog:

I had several times this problem.

Is the mountpoint /afs created? Are you using the init-script or start you by shell-prompt?

HTH

Weaselweb

----------

## Weaselweb

BTW, openafs-1.3.78 does compile with kernel 2.6.10!

When i get more time in march, i will create something for the wiki, with more actual scripts and ebuilds.

Greetings

Weaselweb

----------

## depontius

 *Weaselweb wrote:*   

> BTW, openafs-1.3.78 does compile with kernel 2.6.10!
> 
> When i get more time in march, i will create something for the wiki, with more actual scripts and ebuilds.
> 
> Greetings
> ...

 

I've seen on the OpenAFS lists that the 1.3 series was working with kernel 2.6. But this is for my work machine, and I'd just as soon keep that on ebuilds. So I suspect I'll wait until it's out there in ~86, and keep that machine on kernel 2.4 in the meantime. Of course at the moment OpenAFS is at 1.2.10-r1, and the ~86 is at 1.2.11. I have no idea how far the 1.2.x series goes before starting the 1.3 series, or why the 1.3 series is up to 1.3.78 with no ebuilds, yet. (I know, if I want an ebuild, become a Gentoo OpenAFS developer.)

Are you one of the OpenAFS developers?

----------

## statmobile

Someone please save me, I felt like I'm so close.  I'm using 2.6.10-gentoo-r6, and compiled openafs 1.3.79.  My fstab reads:

```

/dev/hdb1               /usr/vice/cache ext2            defaults                0 0

```

I'm using my University's CellServDB, and the server is appropriate.  The cache partition is 512 MB, and my cacheinfo reads:

```

/afs:/usr/vice/cache:465493

```

Yet whenever I try to run the init script above, afs fails to start up, claiming that I may not have enough cache. The error I keep receiving is

```

 * Starting AFS services...

afsd: WARNING: cache probably too small!

afsd: malloc() failed for cache file inode table with -25 entries.

 * Error starting AFS                                                               [ !! ]

```

Any ideas, fellas?

----------

## Weaselweb

I got this error too, on first time I started with 1.3.78 (or so).

In this version, the config has changed some bit. Now the cachesize if calculated automatically and the option either. That doesn't work out of the box.

It's done in /etc/afs/afs.conf and you have to change your init-script. Try this one. The changes, I have made, should be self-explanatory. You can mail me, if you have some questions.

HTH

Weaselweb

----------

## statmobile

Okay, I'll send you a PM about my questions.  At least, I think that's what you meant in your previous post.

----------

## gustafson

Hi, thanks for the how-to.

I followed the instructions in the 1st post and was able to compile without any issues.  However, no init.d script was installed.  Any ideas?

Thanks,

----------

## statmobile

There is a link to the init script a few posts above yours, just copy that as afs to 

```

/etc/init.d/

```

Make sure you make it executable by

```

chmod +x /etc/init.d/afs

```

Hopefully you will have more luck with it than me.  If it works, let me know what kernel and version of afs you are using, please.

----------

## Weaselweb

At the moment i have no idea, but should use that one, from my last post, since several changes have occured in the meanwhile.

When i got time, i will create a complete how-to with fixed scripts and so on.

----------

## gustafson

Not working for me.  This is the error message.

 *Quote:*   

>  * Starting AFS services...
> 
> /sbin/runscript.sh: line 304: /usr/vice/etc/modload/libafs-2.6.9-gentoo-r14.ko: Permission denied
> 
> 

 

Checking permissions:

 *Quote:*   

> ls -l /usr/vice/etc/modload/libafs-2.6.9-gentoo-r14.ko
> 
> -rw-r--r--  1 root root 787718 Mar  8 12:09 /usr/vice/etc/modload/libafs-2.6.9-gentoo-r14.ko
> 
> 

 

When I do:

 *Quote:*   

> insmod /usr/vice/etc/modload/libafs-2.6.9-gentoo-r14.mp.ko 

 

It doesn't complete

It might be important to note that I am running an AMD64 system.  I haven't seen any forums anyone has made this work.  Any ideas?  Thanks,

----------

## Weaselweb

 *gustafson wrote:*   

>  *Quote:*    * Starting AFS services...
> 
> /sbin/runscript.sh: line 304: /usr/vice/etc/modload/libafs-2.6.9-gentoo-r14.ko: Permission denied
> 
>  
> ...

 

Puh, looks like mine. I have no idea about that.

 *gustafson wrote:*   

> When I do:
> 
>  *Quote:*   insmod /usr/vice/etc/modload/libafs-2.6.9-gentoo-r14.mp.ko  

  AFAIK this module is only needed for multi-cpu-pc.

 *gustafson wrote:*   

> 
> 
> It might be important to note that I am running an AMD64 system.

 

Well, i dont have any AMD64. Maybe it doesn't work on amd64, there is something to compile like x86, perhaps this will help.

Greetings

Weaselweb

----------

## Weaselweb

1.3.79 does compile on kernel 2.6.11 (gentoo-dev-sources), but it has problems during module unloading, which breaks shutdown or reboot.

I do not recommend using it under 2.6.11.

Let's hope, there will be a new version of openafs.

Greetings

Weaselweb

----------

## Jinidog

Unloading the module was succesful with 1.3.79 for me.

/etc/init.d/afs didn't work, but perhaps only because I have no afs-server available.

1.3.80 didn't compile.

----------

## Jinidog

I'm now trying getting this openafs-1.79 to work.

The init-script is aborting when starting the daemon.

So, when I start /usr/sbin/afsd directly, it says that it was unable to mount to /afs(22).

Can anybody help?

It's a kernel 2.6.11.

----------

## zeek

What kind of performance do you think openafs would give if you grepped through a directory of a million files? (as compared to the local filesystem or a NFS setup)

----------

## statmobile

Any new news on the status of afs on the 2.6 kernel?

A buddy of mine just forwarded me an email from my school LUG list, and someone claims that 1.3.81 has been running pretty well on their machine lately.  Any successful gentoo installations running out there with this version of afs?

----------

## Weaselweb

I'm using 1.3.82 on several machines. I noticed that using distcc on compiling give some connections losses. But apart from this it works.

Greetings

Weaselweb

----------

## Jinidog

I have a well working installation of 1.3.81.

Just don't use "preemptible kernel".

----------

## Weaselweb

Well, I use "preemptible kernel" on my laptop, which works even better than my desktop. somebit strange  :Question: 

----------

## statmobile

preemptible kernel?  Which kernel is this?

----------

## Jinidog

It's the option "preemtible" which you can chose in the menuconfig of kernel 2.6 (and perhaps some 2.4 kernels).

It should make the machine more responsive.

However, this options caused trouble and lockups with openafs and it is known to make problems.

----------

## gustafson

Glad to see that there is activity again in the openafs forums.

I tried 1.3.81.  It seemed to compile fine.

```
 /etc/init.d/afs start

 * Starting AFS services...

ParseCacheInfoFile: Format error in cache info file!

        2 out of 3 fields successfully parsed.

 * Error starting AFS                                                     [ !! ]
```

My /etc/afs/cacheinfo:

```
/afs:/usr/vice/cache:173000
```

my mounted ext2 partition:

```
/dev/md1 /usr/vice/cache ext2 rw 0 0
```

kernel 2.6.11-gentoo-r9 on AMD64 (tried it with both preemptible and nonpremtible kernels).

Any ideas?  I've been afsless since getting my new machine, and I'm anxious to get it working.

Thanks.

----------

## Weaselweb

 *Jinidog wrote:*   

> However, this options caused trouble and lockups with openafs and it is known to make problems.

 

According to this post you should use select preemptive kernel AND SMP or none of both. I don't use SMP, i can't say anything about that.

----------

## Weaselweb

 *gustafson wrote:*   

> 
> 
> ```
>  /etc/init.d/afs start
> 
> ...

 

AFAIK, the config changes a bit, since 1.3.80(?). It is calculated automatically on my machines. Try delete this file (oder move somewhere) and restart the service, to create a new one.

For comparison: my /etc/afs/afs.conf has this 2 lines:

```
CACHESIZE=AUTOMATIC

OPTIONS=AUTOMATIC
```

I remind me that is changed the init-script some weeks(month?) ago, that this automatism can be used.

HTH

Weaselweb

----------

## gustafson

I had tried starting without a cacheinfo file.

Now I've also tried with your minimalist afs.conf file.  Still no luck.

----------

## Weaselweb

 *gustafson wrote:*   

> Now I've also tried with your minimalist afs.conf file.  Still no luck.

 

Oh, this should not imply, that this are the only lines on my config file  :Exclamation: 

But afair this were the lines, that changed during version upgrade.

If you want, i can mail my init- and conf-files.

----------

## gustafson

Here is my afs.conf file (everything that isn't a comment), all of it came default with the ebuild:

```
AFS_CLIENT=on

AFS_SERVER=off

ENABLE_AFSDB=on

ENABLE_DYNROOT=on

XXLARGE="-fakestat -stat 4000 -dcache 4000 -daemons 6 -volumes 256 -files 50000"

XLARGE="-fakestat -stat 3600 -dcache 3600 -daemons 5 -volumes 196 -files 50000"

LARGE="-fakestat -stat 2800 -dcache 2400 -daemons 5 -volumes 128"

MEDIUM="-fakestat -stat 2000 -dcache 800 -daemons 3 -volumes 70"

SMALL="-fakestat -stat 300 -dcache 100 -daemons 2 -volumes 50"

CACHESIZE=AUTOMATIC

OPTIONS=AUTOMATIC

AFSDIR=/afs

CACHEDIR=/usr/vice/cache

CACHEINFO=/usr/vice/etc/cacheinfo

VERBOSE=

AFS_POST_INIT=

```

----------

## Weaselweb

mine is completly the same.

maybe it is your init-script.

----------

## gustafson

I don't think it is the init script.  When I issue the afsd command the following happens.  

```
%afsd

ParseCacheInfoFile: Format error in cache info file!

        2 out of 3 fields successfully parsed.

```

In case it is useful, the following is my init script:

```
#! /sbin/runscript

#RCUPDATE:34:77:This line is required for script management

# Copyright 2000, International Business Machines Corporation and others.

# All Rights Reserved.

# 

# This software has been released under the terms of the IBM Public

# License.  For details, see the LICENSE file in the top-level source

# directory or online at http://www.openafs.org/dl/license10.html

# AFS   Start and stop AFS components

# 

# 

# chkconfig: 345 60 20

# description:  AFS is a distributed file system which provides location

#      transparency, caching and secure authentication.

#      Additional configuration can be done in the /etc/sysconfig/afs

#      file. Read the documentation in that file for more information.

#

# Note that AFS does not use a pid file in /var/run. It is turned off by

# unmounting /afs.

#

# Modified by Holger Brueckner <darks@fet.org> for gentoo-linux 

# Modified by Karsten Kretschmer <kkretsch@ph.tum.de> for OpenAFS 1.3.x

# Gather up options and post startup script name, if present

if [ -f /etc/openafs/afs.conf ]; then

   . /etc/openafs/afs.conf

fi

# dependecies

depend() {

    need net

}

# check for ext2 partition

check_ext2() {

    PART=`cat /proc/mounts | grep /usr/vice/cache | grep ext[23] | awk '{print $1}'`

    if [ -z "$PART" ]

    then

        echo ">>> PLEASE CREATE A EXT2 (no reiserfs) PARTITION (of aprox. 200M)"

        echo ">>> AND MOUNT IT TO /usr/vice/cache !!!"

        return 1

    fi

}

# check if cacheinfo exist, otherwise create it !!

check_cacheinfo(){

    if [ ! -f /etc/openafs/cacheinfo ]; then

        PART=$(cat /proc/mounts | grep /usr/vice/cache | grep ext[23] | awk '{print $1}')

        CACHESIZE=$(df $PART | grep ^/ | awk '{print $4}')

        CACHESIZE=$(expr $CACHESIZE \* 9)

        CACHESIZE=$(expr $CACHESIZE / 10)

        echo "/afs:/usr/vice/cache:$CACHESIZE" > /etc/openafs/cacheinfo     

    fi

}

# is_on returns 1 if value of arg is "on"

is_on() {

    if test "$1" = "on"; then

        return 0

    else

        return 1

    fi

}

# load_client loads the AFS client module if it's not already loaded. 

load_client() {

    /sbin/modprobe libafs

}

start(){

    # Load kernel extensions

   

    if check_ext2; then :

    else

        eend 1 "Error: No ext2 partition for afs cache"

    fi

    check_cacheinfo

    

    ebegin "Starting AFS services"

    if load_client; then :

    else

        echo Failed to load AFS client, not starting AFS services.

        eend "Error Starting AFS client"

    fi

    # Start bosserver, it if exists

    if is_on $AFS_SERVER && test -x /usr/sbin/bosserver; then

        /usr/sbin/bosserver 

    fi

    # Start AFS client

    if is_on $AFS_CLIENT && test -x /usr/sbin/afsd; then

        /usr/sbin/afsd ${OPTIONS} 1>&2

   STATUS=$? 

   $AFS_POST_INIT

    fi

    eend $STATUS "Error starting AFS"

}

stop() {

    # Stop AFS

    ebegin "Stopping AFS services"

    if is_on $AFS_CLIENT  ; then

        umount /afs

   STATUS=$? 

    fi

    if is_on $AFS_SERVER && test -x /usr/bin/bos ; then

        echo "Stopping AFS bosserver"

   /usr/bin/bos shutdown localhost -localauth -wait

   killall -HUP bosserver

    fi

    /sbin/rmmod libafs

    STATUS=$? 

    eend $STATUS "Error stopping AFS"

}
```

----------

## irondog

I created new ebuilds and rc-scripts for openAFS.

Here is a howto if you would like to try it out:

https://forums.gentoo.org/viewtopic-t-331633.html

1.3.82 is very stable for me and 1.4 is close to be released.

----------

## Weaselweb

Well, my init-script isn the same, has even some more functions

here we go:

```
#! /sbin/runscript

#RCUPDATE:34:77:This line is required for script management

# Copyright 2000, International Business Machines Corporation and others.

# All Rights Reserved.

# 

# This software has been released under the terms of the IBM Public

# License.  For details, see the LICENSE file in the top-level source

# directory or online at http://www.openafs.org/dl/license10.html

# AFS   Start and stop AFS components

# 

# 

# chkconfig: 345 60 20

# description:  AFS is a distributed file system which provides location

#      transparency, caching and secure authentication.

#      Additional configuration can be done in the /etc/sysconfig/afs

#      file. Read the documentation in that file for more information.

#

# Note that AFS does not use a pid file in /var/run. It is turned off by

# unmounting /afs.

#

# Modified by Holger Brueckner <darks@fet.org> for gentoo-linux 

# Gather up options and post startup script name, if present

if [ -f /etc/afs/afs.conf ]; then

   . /etc/afs/afs.conf

fi

CACHEINFO=${CACHEINFO:-/usr/vice/etc/cacheinfo}

CACHE=${CACHEDIR:-/usr/vice/cache}

AFS=${AFSDIR:-/afs}

# dependecies

depend() {

    need net

}

# check for ext2 partition

check_ext2() {

  PART=`cat /proc/mounts | grep vice | grep ext2 | awk '{print $1}'`

  if [ -z "$PART" ]

  then

    echo ">>> PLEASE CREATE A EXT2 (no reiserfs) PARTITION (of aprox. 200M)"

    echo ">>> AND MOUNT IT TO /USR/VICE/CACHE !!!"

    return 1

  fi

}

# check if cacheinfo exist, otherwise create it !!

check_cacheinfo(){

 [ ! -f /usr/vice/etc/cacheinfo ] && {

    PART=`cat /proc/mounts | grep vice | grep ext2 | awk '{print $1}'`

    CACHESIZE=`df $PART | grep ^/ | awk '{print $4}'`

    CACHESIZE=`expr $CACHESIZE \* 9`

    CACHESIZE=`expr $CACHESIZE / 10`

    echo "/afs:i$CACHE:$CACHESIZE" > /usr/vice/etc/cacheinfo     

 }

}

generate_cacheinfo() {

  if [ "$CACHESIZE" = "AUTOMATIC" ]; then

    LINE=`df -k $CACHE | tail -n 1`

    PART=`echo $LINE | awk '{ if ( ($NF != "/usr")  && ($NF != "/") ) print $NF; else print "NONE";}'`

    if [ "$PART" = "NONE" ]; then

      echo "$CACHE or /usr/vice is not a separate partition"

      echo "you have to change the cachesize in /etc/afs/afs.conf by hand"

      exit 1

    else

      PARTSIZE=`echo $LINE | awk '{print $2}'`

      CACHESIZE=`echo $PARTSIZE | awk '{printf "%d",int(($1*.8)/1000)*1000}'`

    fi

  fi

  if [ "x$CACHESIZE" != "x" ]; then

    echo $AFS:$CACHE:$CACHESIZE > $CACHEINFO

    chmod 0644 $CACHEINFO

  else

    CACHESIZE=`awk -F: '{print $3}' < $CACHEINFO`

  fi

}

choose_afsdoptions() {

  if [ -z "$OPTIONS" -o "$OPTIONS" = "AUTOMATIC" ]; then

    if [ $CACHESIZE -lt 131072 ]; then

      OPTIONS=$SMALL

    elif [ $CACHESIZE -lt 524288 ]; then

      OPTIONS=$MEDIUM

    elif [ $CACHESIZE -lt 1048576 ]; then

      OPTIONS=$LARGE

    elif [ $CACHESIZE -lt 2097152 ]; then

      OPTIONS=$XLARGE

    else

      OPTIONS=$XXLARGE

    fi

  fi

  AFSD_OPTIONS="$OPTIONS $VERBOSE"

  if is_on $ENABLE_AFSDB; then

    AFSD_OPTIONS="$AFSD_OPTIONS -afsdb"

  fi

  if is_on $ENABLE_DYNROOT; then

    AFSD_OPTIONS="$AFSD_OPTIONS -dynroot"

  fi

}

# is_on returns 1 if value of arg is "on"

is_on() {

   if  test "$1" = "on" ; then return 0

   else return 1

   fi

}

# If choose_client can't correctly determine which client to use, set

# LIBAFS manually.

choose_client() {

   # Use the second field of the uname -v output instead of just

   # doing a match on the whole thing to protect against matching

   # a timezone named SMP -- I don't know of one, but let's be

   # paranoid.

   set X `uname -v`; shift

   case $2 in

   SMP) MP=.mp ;;   # MP system

   *)   MP= ;;   # SP system

   esac

   # For now, just use uname -r to get the module version. 

   VERSION=`uname -r`

   LIBAFS=libafs-$VERSION$MP.ko

}

#

# Find prefix symbol to use with insmod.  We find the unregister_filesystem

# string from /proc/kallsyms since we know it's there.  If /proc/kallsyms

# does not exist, we print that info to the console and use the uname -v

# output to decide on a prefix.

# unregister_filesystem_Rsmp_b240cad8 is a typcial SMP version string from

# a kernel built from ftp.kernel.org

#

KSYMS_FILE=/proc/kallsyms

SEARCH_STR="unregister_filesystem"

DEFAULT_SMP_PREFIX="smp_" # Redhat kernels need "smp" instead

PREFIX="" # none needed for UP with <= 1Gig memory

set_prefix()

{

   h='[0-9a-fA-F]'

   h8="$h$h$h$h$h$h$h$h"

   prefix_set=0

   set X `fgrep $SEARCH_STR $KSYMS_FILE 2> /dev/null`; shift

   str=$3

   case $str in

   ${SEARCH_STR}_R$h8)

      # No prefix required

      ;;

   $SEARCH_STR)

      # No versioning in kernel symbols

      ;;

   ${SEARCH_STR}_R*$h8)

      suffix=${str#${SEARCH_STR}_R}

      PREFIX=${suffix%$h8}

      ;;

   *)

      case $str in

      '')

         echo afsd: Cannot find \"$SEARCH_STR\" in file $KSYMS_FILE

         ;;

      *)

         echo afsd: Malformed kernel version symbol \"$str\"

         ;;

      esac

      echo Guessing prefix from output of uname -v

      set X `uname -v`; shift

      case $2 in

      SMP)

         PREFIX=$DEFAULT_SMP_PREFIX

         ;;

      esac

      ;;

   esac

}

MODLOADDIR=/usr/vice/etc/modload

# load_client loads the AFS client module if it's not already loaded. 

load_client() {

   # If LIBAFS is set, use it.

   if [ -z "$LIBAFS" ] ; then

      # Try to determine the right client.

      choose_client

   fi

    

   if [ ! -f $MODLOADDIR/$LIBAFS ] ; then

      echo AFS module $MODLOADDIR/$LIBAFS does not exist. Not starting AFS.

      return 1

   fi

   # use the prefix command if required

   #set_prefix

   #/sbin/insmod ${PREFIX:+-P $PREFIX} -f $MODLOADDIR/$LIBAFS > $MODLOADDIR/libafs.map #2>&1

   

   # so it possible to start, even if module is allready loaded

   if [ `lsmod | grep libafs | wc -l` -eq 0 ]; then

     /sbin/insmod $MODLOADDIR/$LIBAFS > $MODLOADDIR/libafs.map 2>&1

   fi

}

start(){

   # Load kernel extensions

   

   if check_ext2 ; then :

   else

      eend 1 "Error: No ext2 partition for afs cache"

   fi

   ebegin "Starting AFS services"

   

   if  load_client  ; then :

   else

      echo Failed to load AFS client, not starting AFS services.

      eend 1 "Error Starting AFS client"

   fi

   # Start bosserver, it if exists

   if  is_on $AFS_SERVER && test -x /usr/afs/bin/bosserver  ; then

      /usr/afs/bin/bosserver 

   fi

   # Start AFS client

   if  is_on $AFS_CLIENT && test -x /usr/sbin/afsd  ; then

      # check_cacheinfo

      install -d /afs

      generate_cacheinfo

      choose_afsdoptions

      # echo "AFSD_OPTIONS: ${AFSD_OPTIONS}"

      /usr/sbin/afsd -nosettime ${AFSD_OPTIONS} 1> /dev/null

                STATUS=$? 

      # Start AFS version of inetd.conf if present.

      #if  test -f /usr/afsws/etc/inetd.conf -a -x /usr/afsws/etc/inetd.afs ; then

      #   /usr/afsws/etc/inetd.afs /usr/afsws/etc/inetd.conf

      #fi

      $AFS_POST_INIT

   fi

   eend $STATUS "Error starting AFS"

}

stop() {

   # Stop AFS

   ebegin "Stopping AFS services"

   if  is_on $AFS_CLIENT  ; then

#      killall inetd.afs

      umount /afs

                STATUS=$? 

   fi

   if  is_on $AFS_SERVER && test -x /usr/afs/bin/bos ; then

      echo "Stopping AFS bosserver"

      /usr/afs/bin/bos shutdown localhost -localauth -wait

      killall -HUP bosserver

   fi

   LIBAFS=`/sbin/lsmod | fgrep libafs`

   if [ -n "$LIBAFS" ] ; then

      LIBAFS=`echo $LIBAFS | awk 'BEGIN { FS = " " } { print $1 }'`

      /sbin/rmmod $LIBAFS

                STATUS=$? 

   fi

   unset LIBAFS

       eend $STATUS "Error stopping AFS"

}

        
```

----------

## Weaselweb

 *irondog wrote:*   

> I created new ebuilds and rc-scripts for openAFS.
> 
> Here is a howto if you would like to try it out:
> 
> https://forums.gentoo.org/viewtopic-t-331633.html
> ...

 

Ah, splitted into kernel module and the other. Very good. Are the headers and libs are also installed?

----------

## irondog

No, never expected someone would ever need that.

----------

## gustafson

Good news!  I was able to get openafs up and working on my AMD64 machine using the scripts provided by irondog at https://forums.gentoo.org/viewtopic-t-331633.html

Vanilla kernel version 2.6.10.  (linux-2.6.11-gentoo-r9 provided by gentoo sources did not work for some reason)

There are two problems I had.

First the init script didn't work.  I think related to the question above:

 *Quote:*   

> Are the headers and libs are also installed?

 

modprobe was not able to find libafs, likely because it was not installed(?).  So I had to load it myself using:

```
insmod  /etc/afs/modload/libafs-2.6.10.ko
```

Then with it loaded, I was able to start afs with:

```
afsd
```

Secondly, for some reason on my machine klog was installed in:

```
/usr/afs/bin/klog
```

which was not in the path, so I had to type the whole path.

Other than those two minor problems, I'm up and running.  This is great, as I've been without afs on my AMD64 machine since I got it.  Now I can re-deploy the box I kept around for afs on kernel 2.4.

Thanks to irondog, and anybody else who has contributed along the way.

----------

## Weaselweb

irondog:

your ebuild works great.

But i didn't get it to work with a swsusp2 patched kernel (vanilla-sources+swsusp2-patchset). I didn't work with my old ebuild too.

On insmod i get the error:

```
insmod: error inserting '/etc/afs/modload/libafs-2.6.11.10-hibernate.ko': -1 Unknown symbol in module
```

And in dmesg i get the line:

```
libafs: Unknown symbol refrigerator
```

Has anybody an idea or fix for that?

Greetings

Weaselweb

----------

## Weaselweb

openafs-1.3.83 is out.

I'm just compiling at the moment. Some experience later this day.

Greets

Weaselweb

----------

## Weaselweb

It does not work on my 2.6.11-gentoo-r9. I get the error message:

```
insmod: error inserting '/usr/vice/etc/modload/libafs-2.6.11-gentoo-r9.ko': -1 Unknown symbol in module
```

And dmesg says:

```
libafs: Unknown symbol rxkad_stats
```

So I have to downgrade.

Greetings

Weaselweb

----------

## Weaselweb

Hi there,

OpenAFS 1.3.84 works really good, better than the last ones.

BTW: I found script, which helps during service stop:

```
#!/bin/sh

#

# kill all processes using AFS with signal $1

#

if [ $# -eq 1 ]; then

   SIGNAL=$1

else

   SIGNAL=TERM

fi

if [ ! -x /usr/sbin/lsof ]; then

   exit

fi

PIDS=`/usr/sbin/lsof -Fp /afs | /bin/sed -e 's/p//'`

if [ "x" != "x$PIDS" ]; then

   /bin/kill -$SIGNAL $PIDS >/dev/null 2>&1

   sleep 5

fi
```

Which is invoked by those lines:

```
stop)

[...]

   if  is_on $AFS_CLIENT  ; then

      if [ -x /usr/vice/etc/killafs ] ; then

         runcmd "Sending all processes using /afs the TERM signal ..." /usr/vice/etc/killafs TERM

         runcmd "Sending all processes using /afs the KILL signal ..." /usr/vice/etc/killafs KILL

      fi

      # Unmounting afs stops afsd

      umount /afs || return 1

   fi

[...]
```

To use that script, you need also sys-process/lsof. Maybe this is a usefull extension to the init-script.

Greetings

Weaselweb

----------

## irondog

 *Weaselweb wrote:*   

> To use that script, you need also sys-process/lsof. Maybe this is a usefull extension to the init-script.

 

It's important openafs is shut down very late in the shutdown sequence. Open files make shutdown of openafs fail, so it might be an idea to do some kind of a check inside the script.

I've found some other changed ebuilds by Michael Hordijk on Bugzilla. These are not mine. I'll try to adopt the goods things he made, but I'm not so happy with the installation of many useless files. Some even collide with other packages. I'm not happy with the non-transarc defaults he uses either. Things should first become stable and well tested before exploiting it. Thanx anyway.

----------

## statmobile

Seems like the gentoo developers are paying attention to the 2.6 kernel openafs users now that 2.6 is the default kernel.  I read a comment in the GWN that they are planning to put some serious attention into this.  Has anybody worked with the masked versions in portage?

----------

## Weaselweb

It is not really masked, just ~arch Keyword. ATM I edited the ebuild to use the first RC from openafs. Works most of the time. Maybe in the near future there will be a stable version of OpenAFS 1.4

Greetings

Weaselweb

----------

## stefaan

They work for me  :Smile: 

Currently you may want to look out that you have a seperate partition for your afs-cache (in /var/cache/openafs, unless you configure it otherwise).  Those with a flair for tweaks may try "dd if=/dev/zero of=/dev/shm/openafs-cache; mke2fs -F /dev/shm/openafs-cache; mount -o loop /dev/shm/openafs-cache /var/cache/openafs" before starting the client.  

Take care of the transitions.  /usr/vice, /usr/afs, ... don't exist anymore.  Everything is now cleanly in /usr/sbin, /var/lib/openafs, ...  Modules are in /lib/modules/$(uname -r)

Also there are now two init-scripts, one for the client and the server seperately.  

The documentation isn't very up to date.  If someone reading this thread is interested in doing a good job on that, I'd be thrilled   :Wink: 

Regards,

Stefaan

----------

## gustafson

 *statmobile wrote:*   

> Has anybody worked with the masked versions in portage?

 

I've tried all the ebuilds up to openafs-1.4.0_rc2, both on my amd64 and my x86 boxes.  None have worked out of the box, though I saw that openafs-1.4.0_rc3 was out earlier today and I'm going to try again.  

The errors have been:

1) Not properly installing the module.

 *Quote:*   

>  * Starting AFS client ...
> 
>  * AFS module /usr/vice/etc/modload/libafs-2.6.12-gentoo-r9.ko does not exist. Not starting AFS.
> 
> 

 

2) When I linked to the modules, the some sort of (false) parse error.

 *Quote:*   

>  * Caching service dependencies ...                                       [ ok ]
> 
>  * Starting AFS client ...
> 
> ParseCacheInfoFile: Format error in cache info file!
> ...

 

----------

## stefaan

Hi!  Thanks for trying out the ebuilds!

Your first problem:

modules are no longer in /usr/vice/etc/modload..., but in the standard /lib/modules/... directories.  The new init-scripts are adapted to do this, but they seem not to be installed (known bug in openafs-1.4.0_rc2)

Your second problem is also init-script related, as the current init-scripts don't read the cache-info file so thoroughly (as it was deemed unnecessary because of many changes in openafs, and it only reduced the flexibility of your setup).

So, to summarize:

openafs-1.4.0_rc2 had a problem with not installing the init-scripts in /etc/init.d, that has been fixed in openafs-1.4.0_rc2-r1.  I recommend trying out the latest rc3-version, as this has the least known bugs  :Smile:  (a bug failing to install documentation when you have the "doc" USE-flag, but I don't think it'll show because it should only fail on revision bumps)

If you don't succeed, let me know, I'd be happy to fix any bugs to make using this ebuild just an "install and run" procedure.  

And, don't forget to run "etc-update"!!!!

Stefaan

----------

## gustafson

OK, I tried openafs-1.4.0_rc3.

Same outcome as above.  Is there a way to manually install the appropriate init scripts?  

Thanks for the work on this project.  It is important to many of us, myself included.

----------

## stefaan

It's a bit difficult guessing what's going on then.  I'll give a few pointers...

```
ls -ld /lib/modules/$(uname -r)/openafs/libafs*
```

 should tell you whether the kernel module is installed or not.

```
ls -ld /etc/init.d/afs*
```

 should show you which init-scripts for afs are available.  Something worth mentioning: the init scripts have been split into -client and -server, so I actually suspect you'll be seeing three init-scripts: the old one, and the two newer ones.  Please try the newer ones rather then the old ones.

```
cat /etc/openafs/cacheinfo
```

 tells you what your cache-options are.  A standard install would give you: /afs:/var/cache/openafs:50000.  

the first part being the mount-point of afs (always /afs as far as I know)

the second being the place where you have your afs-cache (at the moment I'd still recommend something else then the rootfs, though not strictly necessary)

the third one being the size of the cache (should be less than 95% or something like that of the filesystem size)

If you would provide the results of these commands, it could help figure out what's wrong with your setup (or my ebuilds for that matter   :Embarassed:  ).  If the problem turns out to be complicated, I suggest your contact me on irc.freenode.net (though I'm on holiday starting wednesday evening).  In that case I'll post any solution on this forum afterwards.  

Thanks for the appreciation of the work, I hope it'll prove worthy of it  :Smile: 

----------

## gustafson

Success!!!

I mounted the afs cache partition in the new default location, updated the cacheinfo to reflect it, and used the new afs-client init script.  After correctly including my CellServeDB and ThisCell files, I'm up and running.  I feel like throwing a party. 

Great work on this ebuild, thanks a bunch!

----------

## gustafson

Hi.  

After having this working for almost a month, I'd like to report that it has been very effective, ie no unworkable problems, however it is slow.  I've been experiencing significant delays accessing files on AFS.  Sometimes listing the files takes ~15seconds.

I don't believe that it is network related, I'm plugged into a university ethernet jack which generally provides excellent access.   Comparatively, AFS was significantly faster when I was running based on 2.4 kernel, same access point.  I also have a second machine running behind a cable modem at home, which has very similar delays. 

I am willling to consider that it is something I'm doing wrong, and will listen to any suggestions.  

My setup is the default afs.conf file with a dedicated partion for cache, openafs-1.4.0_rc3, amd64.

/dev/md/1             213M   18M  185M   9% /var/cache/openafs

If I'm not doing anything poorly... then I'd like to feedback to the openafs developers, so they can improve the software.  For now, I thought I might ask this group to see if I'm making glaring mistakes.

I want to emphasize that I'm very greatful for the work that has gone into openafs and the gentoo ebuild.   :Smile:   Keep it up!

----------

## Weaselweb

Well, i noticed several delays too. But mostly this was the first access to the afs share. After that there was nearly no delay.

But i noticed, that OpenAFS 1.4.0-rc5 has more and bigger delays than rc4. I'm running a x86 machine.

Well that delays does not really matters me, i'm happy that it doesn't crash m ysystem again.

Greetings

Weaselweb

----------

## stefaan

 *Weaselweb wrote:*   

> Well, i noticed several delays too. 

 

There's currently some related traffic on the openafs-devel mailing list. Seems like other people are experiencing the same symptoms. So whatever it is, it's being worked on  :Smile: 

----------

## gustafson

Hey guys, I've having trouble with the latest release... but it seems like this thread is probably not current with the latest release so I started a new one.

https://forums.gentoo.org/viewtopic-p-2881364.html#2881364

Please check it out, Thanks,

----------

