Automounting NFS share unstable and DNSMasq doesn't autostart

I want to write the pihole log to a Synology NAS share as my last sdcard got corrupted after so many read+writes. I followed this guide Moving the Pi-hole log to another location/device
and to mount my NFS share I have this in my fstab:

xxx.xxx.x.xxx:/volume1/Pihole_Logs /mnt/logs nfs defaults,noatime,x-systemd.automount 0 0

sudo mount -a works flawless and I can access the share, but when I reboot my pi3 (Raspbian Jessie Light) it sometimes gets automounted but sometimes it doesn't.
Also the pi-hole dnsmasq service doesn't automatically start anymore.

I've searched and read a lot of tips but nothing seems to work yet. Can anyone help please?

you could use sysv-rc-conf to see what's starting and how it's starting/stopping.

sudo apt-get install sysv-rc-conf and run it with sudo sysv-rc-conf

As for the sporadic mount of the network share I think that your system executes the mount command before the network is up.

You could sudo raspi-config and go to Boot Options and enable Wait for network at Boot.
image

Hopefully this will provide some consistency.

L.E. If you are using FTLDNS then dnsmasq is behaving as it’s supposed to. With FTLDNS, dnsmasq is not supposed to start.

1 Like

Thanks for your reply.
I installed the rc-conf and this is what's running right after a reboot:
image
image

The DNS Service is then down in Pihole and it's not working. When I restart dnsmasq through pihole everything works again (except logging to the NFS share).
I don't know if I run the FTLDNS. I can't recall such a question when installing pihole and left most things default. At least I know nothing works when I just booted and don't start dnsmasq through pihole (or command line).
What is a bit strange is that your command does show dnsmasq as being active, however pihole still gives the error and I need to (re)start it manually.

Regarding the automounting it's driving me crazy. I already enabled that "wait for network boot" setting so no that doesn't help unfortunately. By the way if I run sudo mount -a I don't see any running services.

When it fails, try running a pihole -d (Without enabling dnsmasq)

If it fails to upload, edit /etc/resolv.conf and change from 127.0.0.1 into 1.1.1.1

Re-run pihole -d, upload to tricorder and provide the debug token.

I’m using cifs.mount for my network share, called from a script in init.d and it always loads.

I don’t like fstab :slight_smile:

@RamSet: Could you give me a hint how to automount like you do it (PM?)? I am relatively new to Linux...
fstab isn't working as expected (exactly the same issue as @PuckStar)...
Thanks!

Try adding the "_netdev" option:

$ man mount
[..]
FILESYSTEM-INDEPENDENT MOUNT OPTIONS
       Some of  these  options  are  only  useful  when  they  appear  in  the
       /etc/fstab file.

       Some  of  these  options could be enabled or disabled by default in the
       system kernel.  To  check  the  current  setting  see  the  options  in
       /proc/mounts.   Note that filesystems also have per-filesystem specific
       default mount options (see for  example  tune2fs  -l  output  for  extN
       filesystems).

       The  following  options  apply  to any filesystem that is being mounted
       (but not every filesystem actually honors them – e.g., the sync  option
       today has an effect only for ext2, ext3, fat, vfat and ufs):
[..]
       _netdev
              The filesystem resides on a device that requires network  access
              (used  to  prevent  the  system  from  attempting to mount these
              filesystems until the network has been enabled on the system).
[..]

@deHakkelaar Adding _netdev didn't help :frowning:

@RamSet This is the token: bniwqc2p7i
If you have a better solution than fstab then please do share it with us :).
I wanted to try autofs as mentioned by this guy: Saving query logs for long-term analysis - #5 by colindean, but the command sudo apt-get autofs already doens't work.

I’m away from a computer. I will reply tomorrow with the way i do it :blush:

@Rico_Lino and @PuckStar since you both asked for this:

Here we go.

The way I do it requires samba and cifs-utils.
If you don't mind installing/having this on your machine then follow along:) Otherwise, don't use this info.

One needs to install the dependencies:

sudo apt-get install samba-common smbclient samba-common-bin smbclient cifs-utils

After that create a folder that will be used as the mount point for the network share:

sudo mkdir -p /media/YourFolder (you can pick any path you want -We'll use this one for this example).

Change ownership (to the user this will be executed under via init.d) sudo chown pi:pi -R /media/YourFolder

My share (in order to avoid users and passwords has guest access enabled read/write) and I mount it with:

sudo mount.cifs //192.168.1.1/share/ /media/YourFolder -o guest

You can run that command (we'll have that executed at boot via init.d) to mount/test it.

To see if it mounted run df -h and you should see it there.

Now, to have it executed at boot, you need to create a file in init.d that will execute this at system boot.

sudo nano /etc/init.d/sharemount (or name it however you want)

We'll need to set the header for it so that the command is executed when the dependencies are loaded (in this case $local_fs $remote_fs $network).

Here is the code that needs to be placed in sharemount:

 #! /bin/sh
 #
 # init script for sharemount
  
 ### BEGIN INIT INFO
 # Provides:          sharemount
 # Required-Start:    $local_fs $remote_fs $network
 # Required-Stop:     $local_fs $remote_fs $network
 # Default-Start:     S
 # Default-Stop:      0 1 6
 # Short-Description: sharemount
 ### END INIT INFO
  
 PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
 case "$1" in
  start)
 sleep 10
 sudo mount.cifs //192.168.1.1/share /media/YourFolder -o guest
 ;;
 stop)
 # optional
 /sudo umount /media/YourFolder
         ;;
 esac

What this does is it waits for the resources to be loaded and 10 seconds later, it mounts the shared path via the command.

On computer restart or shutdown, it unmounts it (optional).

Once the above content is saved in the file, you need to sudo chmod 775 /etc/init.d/sharemount in order to make it executable and then sudo update-rc.d sharemount defaults to enable it at boot.

Hope this works for you. Might not be the cleanest way, but this has been been stable/working for me for quite some time now.

Change IP's and paths to your need.

2 Likes

I guess this doesn't work if I have a NFS share on my NAS right?

Never tried it but see if it works with sudo mount.nfs instead of cifs

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.