What's new

smb.conf from /mnt/sda1/overlay isn't copied at boot

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

mith_y2k

Regular Contributor
Today I was fiddling with my Orbi configuration running Voxel and wanted to reboot to make sure everything was clean. After reboot all my custom configuration started as expected, i.e. DNSCrypt, but strangely Samba went back to Voxel's default. I am confident I put the files in the right place, but after another reboot it still didn't copy over. If I manually copy smb.conf in /etc/samba and restart Samba it reads it correctly.

This is my Samba directory in my USB drive: https://imgur.com/a/6Pc85Br
 
I was searching the forums for anyone else having issues with overlay and found this message:Before I install Voxel on Orbi#6 which made me dig more and I found that after a reboot I have "/overlay" (at root level) with a number of files and subdirectories, but not "samba". Any idea why? Do I need to force some file/directory copy and restart the service like Wireguard or OpenVPN in hotplug2.mount?

This is a screenshot: https://imgur.com/zpenRnD
 
Don't know the specifics for Orbi, but on R7800, /etc/samba is a symlink to /tmp/samba
So if you copy smb.conf to /etc/samba then it effectively is in /tmp/samba/smb.conf.

And because /tmp is in memory, your changes are lost at reboot.

What the firmware seems to do during boot is copy /etc/config/samba/smb.conf to /tmp/samba/smb.conf (or /etc/samba/smb.conf) and then make some adjustments (like renaming the share to the name of the USB disk.)

So either you must add your config to /etc/config/samba/smb.conf (and hope that it still works after firmware is changing it during boot).
Or you could try to delete the symlink /etc/samba and replace it with a folder /etc/samba.
(but that would only work if netgear code is copying the file to /tmp/samba, while samba is reading it from /etc/samba)

Or you'd have to dig deeper into the code to see if you can prevent firmware from overwriting your file.
 
update, you mentioning hotplug2.mount was a good tip:

/sbin/hotplug2.mount somewhere after mounting the USB disk calls update_smb $diskname
And it seems that this binary is generating the /etc/samba/smb.conf

So commenting out that line, replacing /etc/samba symlink with a folder and placing your smb.conf in that folder should also do the trick
(until you update your firmware of course)
(and no guarantees that there are other processes (like the web-gui) that would still try to mess with your config)
 
and to fully answer your question: you do not need to put files in /overlay. This happens automatically if you change/delete/add something on the file system. (except for /tmp and some other folders that are in RAM)
And if you'd delete a file from /overlay then the corresponding file in / is reverted back to the original (like in /rom).

(simply put /rom + /overlay = /)
 
and to fully answer your question: you do not need to put files in /overlay. This happens automatically if you change/delete/add something on the file system. (except for /tmp and some other folders that are in RAM)
And if you'd delete a file from /overlay then the corresponding file in / is reverted back to the original (like in /rom).

(simply put /rom + /overlay = /)

Thanks for your replies. Trying to put two and two together here. The samba configuration is copied to /tmp on boot so any edits I make there will be lost after reboot. I get that part. Where would I save my custom smb.conf so that at boot it is automatically copied over the stock file AND Samba is started or relaunched with my parameters? That’s what I thought the /overlay directory was for.
 
No the overlay is for modifying files that are part of the ROM that would otherwise be readonly.

Currently the ROM contains symlink /etc/samba to /tmp/samba.
If you delete that symlink, then in /overlay/etc a marker is placed, indicating the deletion.
If you next create folder /etc/samba, then that also is stored as /overlay/etc/samba.

If you place your custom smb.conf in there, then that is also stored in overlay.
And in itself, that will survive reboots and stuff.

But that hotplug2.mount will try to modify the config.
And this can probably be prevented by editing /sbin/hotplug2.mount and comment the line that has update_smb $diskname
The moment you save the modified hotplug2.mount, also that will be visible as /overlay/sbin/hotplug2.mount

If you'd want to revert the change, then you could delete /overlay/sbin/hotplug2.mount again, and then /sbin/hotplug2.mount would again be the same as /rom/sbin/hotplug2.mount.
 
Thanks R. Gerrits, I did some more tests and I'm still hitting a wall. This is what I did:
  1. I verified (as you suggested) that if I go for example to /etc and edit a file it magically appears in /overlay (same path same name). I edited /etc/config/samba/smb.conf
  2. I also verified that if I create the file /mnt/sda1/overlay/etc/config/samba/smb.conf and reboot this file is copied to /etc/config/samba as I expected originally
  3. I also verified that Samba is always started with Voxel's default config not matter what I change; I am at this point not sure where it comes from
  4. If I manually restart Samba (/etc/init.d/samba restart) it actually loads some basic file that is not Voxel's; also, a little scary, the script also sets a password for users admin and root (I'm guessing from Voxel)
    1. smb.conf is overwritten by update_smb.sh (not the binary file you suggested in your message)
  5. I think I also found the binary you referred to, see https://github.com/Getnear/R7800/blob/master/package/samba-scripts/src/update_smb.c, this also overwrites the smb.conf file
  6. I also confirmed that other files such as the dnscrypt-proxy-2.toml file I have in /mnt/sda1/overlay/etc are picked up correctly; it seems like /etc/samba is special or smb.conf gets overwritten
At this point I'm out of options again. I did find that once the router has started I can easily overwrite smb.conf and restart it manually.
 

Latest threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top