SMB with IPv6 on Alt-F 1.0

392 views
Skip to first unread message

Jacek Glinianowicz

unread,
Oct 22, 2017, 4:23:49 PM10/22/17
to Alt-F
Hi João,
first of all, thanks for your hard work. Very nice piece of software!

I just upgraded my two DNS323 boxes (ver A1 and B1) from RC4 to 1.0. Upgrade was smooth, then I enabled IPv6 with kernel modules. Here is what I noticed on both my boxes:
-ping with IPv6 works just after box start as it should
-samba with IPv6 does not work just after boot/reboot (IPv4 works correctly), samba IPv6 requires to stop and restart smb service (from GUI)
I tested the bevaviour several times, so it seems to be repeatable. Maybe IPv6 addresses are not known yet when smb starts the first time?

Regards,
Jacek

João Cardoso

unread,
Oct 22, 2017, 8:34:12 PM10/22/17
to Alt-F
That might well be the case on a dns-323/321, as the IPv6 kernel module is loaded only when filesystems are found and mounted the Alt-F folder is found, while samba(-small) is on the firmware and is (most probably) started before.

You might solve that by installing samba (not small) as an on-disk Alt-F package, and in that case samba will be automatically restarted when found. The catch is that now samba is running from disk.

And thanks, I didn't knew that samba worked (after restarted) on IPv6 :-)


Regards,
Jacek

Jacek Glinianowicz

unread,
Oct 23, 2017, 4:39:42 PM10/23/17
to Alt-F


W dniu poniedziałek, 23 października 2017 02:34:12 UTC+2 użytkownik João Cardoso napisał:


That might well be the case on a dns-323/321, as the IPv6 kernel module is loaded only when filesystems are found and mounted the Alt-F folder is found, while samba(-small) is on the firmware and is (most probably) started before.

You might solve that by installing samba (not small) as an on-disk Alt-F package, and in that case samba will be automatically restarted when found. The catch is that now samba is running from disk.

And thanks, I didn't knew that samba worked (after restarted) on IPv6 :-)


 
Thanks for the hint, it works!
I tried with following lines in user script: 
/etc/init.d/S61smb stop
/etc/init.d/S61smb start
But apparently user script is run before IPv6 kernel module loaded, as well.
Installation of samba (not small) solves the issue.

Regards,
Jacek

João Cardoso

unread,
Oct 24, 2017, 12:19:18 PM10/24/17
to Alt-F
Yes, the user script is run before filesystems and the Alt-F folder (with the on-disk installed packages) being found.
As the script runs in background, you can wait (for ever...) for that to happens before continuing. E.g.

# wait for specific filesystem to be mounted, if needed
waitfor="md1 sda4 sdb3"     # adapt to your case
for i in $waitfor; do
    echo -n "waiting for $i:"
    while ! mountpoint -q /mnt/$i; do
        echo -n '.'
        sleep 5
    done
    echo OK
done

#  wait for an Alt-F folder to be found and available. This is enough for your case
echo -n "Waiting for aufs.sh to finish:" 
while ! aufs.sh -s >& /dev/null; do
       echo -n '.'
       sleep 1
done

rcsmb restart

 
Installation of samba (not small) solves the issue.

If you don't want samba to not run from disk you can use the above 


Regards,
Jacek

Jacek Glinianowicz

unread,
Oct 25, 2017, 1:56:26 PM10/25/17
to Alt-F

#  wait for an Alt-F folder to be found and available. This is enough for your case
echo -n "Waiting for aufs.sh to finish:" 
while ! aufs.sh -s >& /dev/null; do
       echo -n '.'
       sleep 1
done


Seems like hangs on this line :-)

João Cardoso

unread,
Oct 26, 2017, 11:06:22 AM10/26/17
to Alt-F
You might have mistyped it (or copy/paste added extraneous characters). try:

aufs.sh -s; echo $?

[root@DNS-320L]# aufs.sh -s; echo $?
OK
0

now, stop all services and unmount aufs:

rcall stop
aufs
.sh -u # this might unfortunately fail


[root@DNS-320L]# rcall stop
root: Stopping sshd: OK.
root: Stopping smbd: OK. Stopping nmbd: OK.
root: Stopping ntpd: OK.
root: Stopping news: OK.
root: Stopping smartd: OK.
root: Stopping crond: OK.
root: Stopping sysctrl: OK.
root: Stopping urandom: OK.
root: Stopping klogd: OK. Stopping syslogd: OK.
[root@DNS-320L]# aufs.sh -u # this might fail
[root@DNS-320L]# aufs.sh -s; echo $?
/mnt/DATA/Alt-F is not a aufs branch.
1

So, while 'aufs.sh -s' does return 1, the Alt-F folder is not available and aufs mounted, and the command is repeated a one second latter; when 'aufs.sh -s' returns 1 the cycle stops

To return to normal operation after the above commands,

aufs.sh -m
rcall start

[root@DNS-320L]# aufs.sh -m
[root@DNS-320L]# aufs.sh -s
OK
[root@DNS-320L]# rcall start
root: Starting syslogd: OK.
Starting klogd: OK.
root: Starting urandom: OK.
root: Starting sslcert: OK.
root: Starting modload: OK.
root: Starting btrfs: OK.
root: quota on sda2 is disabled
root: Starting sysctrl: OK.
root: Starting smartd: OK.
root: Starting crond: OK.
Starting news: OK.
root: Starting inetd: OK.
root: ntpd: Setting up crontab... OK.
root: Starting dbus-uuidgen: OK.
Starting dbus-daemon: OK.
Starting avahi-daemon: OK.
Starting netatalk: OK.
root: Starting nmbd: OK.
Starting smbd: OK.
root: Starting sshd: OK.
root: Starting rmount: OK.
root: Starting ffp: No ffp instalation found.
root: Starting user: OK.

just type 'aufs.sh' to see all available options


Jacek Glinianowicz

unread,
Oct 26, 2017, 1:13:45 PM10/26/17
to al...@googlegroups.com
Hi João,
unfortunately, there is no typo in the script. It works when run later, but behaves wrongly when run on startup.
Here is the last sentence in the system log:

Oct 26 19:00:58 DNS323-JG-1 user.notice root: crond running
Oct 26 19:00:58 DNS323-JG-1 user.notice root: sysctrl running
Oct 26 19:00:58 DNS323-JG-1 user.notice root: sslcert stopped
Oct 26 19:00:58 DNS323-JG-1 user.notice root: urandom started
Oct 26 19:00:58 DNS323-JG-1 user.notice root: syslogd running
Oct 26 19:02:36 DNS323-JG-1 user.notice aufs: Couldn't get lock, exiting.
Oct 26 19:02:36 DNS323-JG-1 user.notice hot_aux: Alt-F directory found in sda2 but not used, aufs mount failed.

There are orange lights on the front panel, and Alt-F modules are not available. I can log to console, disks are mounted, samba (small) works, www works. Looks like error message is generated after timeout with aufs.

Funny thing... I exchanged the test line to simple one
#while ! aufs.sh -s >& /dev/null; do
while ! test -e /usr/bin/ipkg-cl; do
Result is exactly the same. My guess is that Alt-F is not mounted until user script finished.

Regards

João Cardoso

unread,
Oct 26, 2017, 5:19:28 PM10/26/17
to Alt-F


On Thursday, 26 October 2017 18:13:45 UTC+1, Jacek Glinianowicz wrote:
Hi João,
unfortunately, there is no typo in the script. It works when run later, but behaves wrongly when run on startup.
Here is the last sentence in the system log:

Oct 26 19:00:58 DNS323-JG-1 user.notice root: crond running
Oct 26 19:00:58 DNS323-JG-1 user.notice root: sysctrl running
Oct 26 19:00:58 DNS323-JG-1 user.notice root: sslcert stopped
Oct 26 19:00:58 DNS323-JG-1 user.notice root: urandom started
Oct 26 19:00:58 DNS323-JG-1 user.notice root: syslogd running
Oct 26 19:02:36 DNS323-JG-1 user.notice aufs: Couldn't get lock, exiting.
Oct 26 19:02:36 DNS323-JG-1 user.notice hot_aux: Alt-F directory found in sda2 but not used, aufs mount failed.


There is definitively a race condition, worth to fix, but I couldn't reproduce it.

Notice the time stamp, the "couldn't get lock message" appears ~2 minutes after the previous one. Two minutes is the amount of time that aufs.sh tries to get a lock to avoid concurrent operation. In my duplication attempt, aufs.sh waits 20 seconds for a lock, because /etc/init.d/S99user is still running (the "syslogd running" messages comes from there):

[root@DNS-320L]# logread | grep -E 'aufs:|syslogd running'
Oct 26 21:09:33 DNS-320L user.notice aufs: waiting for lock
Oct 26 21:09:50 DNS-320L user.notice root: syslogd running
Oct 26 21:09:50 DNS-320L user.notice aufs: got lock
Oct 26 21:09:50 DNS-320L user.notice aufs: remove lock

Where have you saved your userscript?
 
There are orange lights on the front panel, and Alt-F modules are not available. I can log to console, disks are mounted, samba (small) works, www works. Looks like error message is generated after timeout with aufs.

Yes it gives up after 2 minutes, so no disk-installed packages are available
 

Funny thing... I exchanged the test line to simple one
#while ! aufs.sh -s >& /dev/null; do
while ! test -e /usr/bin/ipkg-cl; do

That's almost the same thing, as ipkg-cl is saved on disk, on /Alt-F/usr/bin/ipkg-cl, and as aufs.sh gives up mounting the Alt-F folder no "unioning" will occur.

Result is exactly the same. My guess is that Alt-F is not mounted until user script finished.
 
The user script is run as the last thing to do after a filesystem being processed (and eventually Alt-F found), see comment in the code:
# the user script might need the Alt-F dir aufs mounted, so run it last

This has to be handled without time dependencies, that is why a "lock" is attempted.

It looks like you can't use the user script in this way, don't (yet) know why.
To recap: on a dns-321/323 we want the user boot script to determine if kernel modules are available in order to restart samba because of IPv6.
You could change your script to check for ipv6 to be in use:

while ! $(lsmod | grep -q ipv6); do sleep 1; done
rcsmb restart

Even if the above works, I'm still wondering why the race occurred


Regards

Jacek Glinianowicz

unread,
Oct 26, 2017, 6:30:36 PM10/26/17
to al...@googlegroups.com
while ! $(lsmod | grep -q ipv6); do sleep 1; done

:-)  the same:
Couldn't get lock, exiting


>Where have you saved your userscript?

This can be the key.... My userscript is located at
/mnt/sda2/Users/disk_admin/
Alt-F dir is at the same hdd

Regards


EDIT:
My userscript was different then skeleton (never changed for years). It did not contain all the lines below, just a script line by line. Now I changed to proposed formula inserting my lines inside case-start, like the while loop below.

#!/bin/sh
exec >> /var/log/user.log 2>&1
case "$1" in
start)
echo "Starting $0"
while ! $(lsmod | grep -q ipv6); do sleep 1; done
;;
stop)
echo "Stopping $0"
;;
esac

FINALLY IT SEEMS TO WORK.
THANKS!!!!!

João Cardoso

unread,
Oct 27, 2017, 11:11:54 AM10/27/17
to Alt-F
Glad it is working now! No matter what I did I couldn't reproduce your results.

Your script is missing an important piece of information:

# Script to execute as the root user at boot time.
# You can loose your data or make the system inaccessible
# if using the wrong commands. You have been warned!
 
;-)

I also found a possible issue in your script path location: it should be at the base of a filesystem, such as /mnt/sda2/mybootscript.sh

The reason is that the userscript can be run at two different moments:
-either at boot time when S99user is executed and the filesystem and script is already available,
-or latter when the filesystem and script finally becomes available.

If the filesystem needs a filesystem check (fsck) at boot time, it will not be available when S99user runs, and it will instead be started by hot_aux.sh after the fs check completes. Due to an unfortunate bug, the latter only happens if the script is located at the fs base.


Jacek Glinianowicz

unread,
Oct 27, 2017, 5:57:22 PM10/27/17
to Alt-F
Thanks for hints, I moved the script
Jacek
Reply all
Reply to author
Forward
0 new messages