# Automount fails: mount(nfs): no hosts available

## devilheart

Hello,

recently one of our gentoo desktop clients has started to show problems when trying to automount some nfs shares. Standard logs didn't show anything interesting, so I ran the automounter with:

```
automount -d -v -f /etc/auto.master
```

And I get these messages:

```

Starting automounter version 5.1.1, master map /etc/auto.master

using kernel protocol version 5.02

lookup_nss_read_master: reading master file /etc/auto.master

do_init: parse(sun): init gathered global options: (null)

spawn_mount: mtab link detected, passing -n to mount

spawn_umount: mtab link detected, passing -n to mount

lookup_read_master: lookup(file): read entry +auto.master

lookup_nss_read_master: reading master files auto.master

do_init: parse(sun): init gathered global options: (null)

lookup_nss_read_master: reading master nis auto.master

do_init: parse(sun): init gathered global options: (null)

master_do_mount: mounting /home

automount_path_to_fifo: fifo name /run/autofs.fifo-home

lookup_nss_read_map: reading map file /etc/auto.home

do_init: parse(sun): init gathered global options: (null)

spawn_mount: mtab link detected, passing -n to mount

spawn_umount: mtab link detected, passing -n to mount

lookup_read_map: read included map +auto.home

lookup_nss_read_map: reading map files auto.home

lookup_nss_read_map: reading map nis auto.home

do_init: parse(sun): init gathered global options: (null)

lookup_read_map: map read not needed, so not done

mounted indirect on /home with timeout 300, freq 75 seconds

st_ready: st_ready(): state = 0 path /home

handle_packet: type = 3

handle_packet_missing_indirect: token 12562, name myuser, request pid 17044

attempting to mount entry /home/myuser

lookup_mount: lookup(file): looking up myuser

lookup_one: lookup(file): lookup included map +auto.home

lookup_mount: lookup(yp): looking up myuser

lookup_mount: lookup(yp): myuser -> -rw,rsize=8192,wsize=8192,intr,tcp nfs_server:/lhome0/myuser

parse_mount: parse(sun): expanded entry: -rw,rsize=8192,wsize=8192,intr,tcp nfs_server:/lhome0/myuser

parse_mount: parse(sun): gathered options: rw,rsize=8192,wsize=8192,intr,tcp

parse_mount: parse(sun): dequote("nfs_server:/lhome0/myuser") -> nfs_server:/lhome0/myuser

parse_mount: parse(sun): core of entry: options=rw,rsize=8192,wsize=8192,intr,tcp, loc=nfs_server:/lhome0/myuser

sun_mount: parse(sun): mounting root /home, mountpoint myuser, what nfs_server:/lhome0/myuser, fstype nfs, options rw,rsize=8192,wsize=8192,intr,tcp

mount_mount: mount(nfs): root=/home name=myuser what=nfs_server:/lhome0/myuser, fstype=nfs, options=rw,rsize=8192,wsize=8192,intr,tcp

mount_mount: mount(nfs): nfs options="rw,rsize=8192,wsize=8192,intr,tcp", nobind=0, nosymlink=0, ro=0

get_nfs_info: called with host nfs_server(158.110.28.52) proto 6 version 0x30

[b]mount(nfs): no hosts available[/b]

st_readmap: state 1 path /home

re-reading map for /home

lookup_nss_read_map: reading map file /etc/auto.home

dev_ioctl_send_fail: token = 12562

failed to mount /home/myuser

do_init: parse(sun): init gathered global options: (null)

lookup_read_map: read included map +auto.home

handle_packet: type = 3

lookup_nss_read_map: reading map files auto.home

lookup_nss_read_map: reading map nis auto.home

do_init: parse(sun): init gathered global options: (null)

lookup_read_map: map read not needed, so not done

handle_packet_missing_indirect: token 12563, name myuser, request pid 17044

dev_ioctl_send_fail: token = 12563

st_ready: st_ready(): state = 4 path /home

```

Autofs configuration is delivered networkwide via nis, so /etc/auto.master reads just

```
/home /etc/auto.home
```

and

```

# cat /etc/auto.home

+auto.home

# ypcat auto.home

-rw,rsize=8192,wsize=8192,intr,tcp nfs_server:/lhome0/myuser

```

I am running automount 5.1.1-r1 on gentoo sources 4.4.6

From the automount output, I see that it gets the correct mount options but, for some reason, it fails to mount the directory.

Of course, I am able to directly mount that directory.

nfs_server is running ubuntu 12.04, but it is not under my control and other gentoo clients in the network can automount that directory just fine.

I believe this started to happen after the last sync&update, but I'm not sure if that is the cause

Some other info:

```

# emerge --info

Portage 2.2.28 (python 2.7.10-final-0, default/linux/amd64/13.0/desktop/plasma, gcc-4.9.3, glibc-2.22-r4, 4.4.6-gentoo x86_64)

=================================================================

System uname: Linux-4.4.6-gentoo-x86_64-Intel-R-_Core-TM-_i3-4030U_CPU_@_1.90GHz-with-glibc2.2.5

KiB Mem:     3964692 total,   3459620 free

KiB Swap:    8392700 total,   8392700 free

Timestamp of repository gentoo: Sun, 26 Jun 2016 13:30:01 +0000

sh bash 4.3_p42-r1

ld GNU ld (Gentoo 2.25.1 p1.1) 2.25.1

app-shells/bash:          4.3_p42-r1::gentoo

dev-lang/perl:            5.20.2::gentoo

dev-lang/python:          2.7.10-r1::gentoo, 3.4.3-r1::gentoo

dev-util/cmake:           3.3.1-r1::gentoo

dev-util/pkgconfig:       0.28-r2::gentoo

sys-apps/baselayout:      2.2::gentoo

sys-apps/openrc:          0.19.1::gentoo

sys-apps/sandbox:         2.10-r1::gentoo

sys-devel/autoconf:       2.69::gentoo

sys-devel/automake:       1.11.6-r1::gentoo, 1.14.1::gentoo, 1.15::gentoo

sys-devel/binutils:       2.25.1-r1::gentoo

sys-devel/gcc:            4.9.3::gentoo

sys-devel/gcc-config:     1.7.3::gentoo

sys-devel/libtool:        2.4.6::gentoo

sys-devel/make:           4.1-r1::gentoo

sys-kernel/linux-headers: 4.3::gentoo (virtual/os-headers)

sys-libs/glibc:           2.22-r4::gentoo

Repositories:

gentoo

    location: /usr/portage

    sync-type: rsync

    sync-uri: rsync://rsync.gentoo.org/gentoo-portage

    priority: -1000

science

    location: /var/lib/layman/science

    sync-type: laymansync

    sync-uri: git://anongit.gentoo.org/proj/sci.git

    masters: gentoo

    priority: 50

ACCEPT_KEYWORDS="amd64"

ACCEPT_LICENSE="*"

CBUILD="x86_64-pc-linux-gnu"

CFLAGS="-O2 -pipe -march=corei7 -g -g3"

CHOST="x86_64-pc-linux-gnu"

CONFIG_PROTECT="/etc /usr/share/config /usr/share/gnupg/qualified.txt /var/spool/torque"

CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"

CXXFLAGS="-O2 -pipe -march=corei7 -g -g3"

DISTDIR="/usr/portage/distfiles"

EMERGE_DEFAULT_OPTS="-k --keep-going y"

FCFLAGS="-O2 -pipe"

FEATURES="assume-digests binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles installsources merge-sync metadata-transfer news parallel-fetch parallel-install preserve-libs protect-owned sandbox sfperms splitdebug strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"

FFLAGS="-O2 -pipe"

GENTOO_MIRRORS="http://distfiles.gentoo.org"

LANG="en_US.utf8"

LDFLAGS="-Wl,-O1 -Wl,--as-needed"

MAKEOPTS="-j8"

PKGDIR="/usr/portage/packages"

PORTAGE_CONFIGROOT="/"

PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"

PORTAGE_TMPDIR="/var/tmp"

USE="X acl acpi alsa amd64 berkdb bindist branding bzip2 cairo cli cracklib crypt cups cxx dbus declarative dri firefox fortran gdbm gif glamor gpm iconv icu ipv6 jpeg kde kipi lcms libnotify llvm mmx mmxext mng modules multilib ncurses nis nls nptl opengl openmp pam pango pcre pdf plasma png policykit ppds qml qt3support qt4 qt5 readline seccomp session spell sse sse2 ssl startup-notification svg tcpd tiff truetype udev udisks unicode upower usb widgets xattr xcb xcomposite xinerama xml xscreensaver xv xvid zlib" ABI_X86="64" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="mmx mmxext sse sse2" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="keyboard mouse evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LINGUAS="en it" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-5" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7 python3_4" RUBY_TARGETS="ruby20 ruby21" USERLAND="GNU" VIDEO_CARDS="intel i965" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"

Unset:  CC, CPPFLAGS, CTARGET, CXX, INSTALL_MASK, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, USE_PYTHON

```

Kernel config is here

Any ideas?

----------

## devilheart

Ok, I have an update:

```
# ldd /usr/sbin/automount 

        linux-vdso.so.1 (0x00007ffc21fb6000)

        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fa0e8249000)

        libdl.so.2 => /lib64/libdl.so.2 (0x00007fa0e8045000)

        libc.so.6 => /lib64/libc.so.6 (0x00007fa0e7ca9000)

        /lib64/ld-linux-x86-64.so.2 (0x00007fa0e8465000)
```

This seems all normal, but if I remove --as-needed from LDFLAGS 

```
# ldd /usr/sbin/automount

        linux-vdso.so.1 (0x00007ffe349d1000)

        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f14d272a000)

        libtirpc.so.1 => /lib64/libtirpc.so.1 (0x00007f14d2503000)

        libnsl.so.1 => /lib64/libnsl.so.1 (0x00007f14d22eb000)

        libdl.so.2 => /lib64/libdl.so.2 (0x00007f14d20e7000)

        libc.so.6 => /lib64/libc.so.6 (0x00007f14d1d4b000)

        /lib64/ld-linux-x86-64.so.2 (0x00007f14d2946000)
```

Now two more libraries are linked and automount works as expected. The odd thing is that on other gentoo boxes, which have --as-needed enabled, automount still works fine.

----------

## krinn

libtirpc should depend on the libtirpc useflag, but once set, the build system should link and use them, --as-needed no has need to remove them, as its task is to remove link lib that are in real not use.

if you have in your examples the libtirpc useflag set, then it's a bug that should be report. Because --as-needed or not, if one was build with it set and the other not, that's expected result then.

----------

## devilheart

Hello, I made a few more experiments and this is what I see:

On all of my gentoo boxes, autofs was built with libtirpc use flag enabled but it doesn't work on only one box

It will work if I remove the --as-needed flag

functions from libtirpc are called in modules/rpc_subs.c file but if I remove it from the Makefile and I do not link against libtirpc, autofs emerges but does not work

if I disable libtirpc use flag, autofs works even with --as-needed

----------

