11 votes

Best way to set up NAS?

so I have a setup where I have a NUC that has docker on it, one of the containers is my nextcloud that I use for sharing my files across my computers.

I also have a synology NAS which is connected to my NUC via NFS and the files themselves are stored on that NFS file via a docker volume mount.

Hopefully that made sense.

My problem: not often but it does happen where my router has an issue, today it just needed a restart. another time it was cause I deliberately disconnected it from the power not realizing it would mess up the connection between my NUC and my NAS.
Why is this an issue? it causes my nextcloud to freeze up as the files it is supposed to share are no longer available. necessitates me restarting my NUC to get the connection going again.
Thankfully hasn't happened often but still something that can be scary in the moment. My question is, is this just one of the pitfalls I have to accept of utilizing a NAS the way I am or is there a way to connect a Synology to a NUC and ensure router issues don't cause the nextcloud docker instance to freeze?

17 comments

  1. [11]
    tibpoe
    Link
    Can you connect the NAS and the NUC through a separate Ethernet switch? If the router goes down, then the connection should still be good.

    Can you connect the NAS and the NUC through a separate Ethernet switch? If the router goes down, then the connection should still be good.

    3 votes
    1. [10]
      b3_k1nd_rw1nd
      Link Parent
      so I have them connected via https://www.primecables.ca/p-309924-tl-sg1016d-tp-link-tl-sg1016d-16-port-gigabit-unmanaged-desktoprackmount-switch and that connects to my router. are you saying to...

      so I have them connected via https://www.primecables.ca/p-309924-tl-sg1016d-tp-link-tl-sg1016d-16-port-gigabit-unmanaged-desktoprackmount-switch and that connects to my router.

      are you saying to disconnect that switch from the router? won't that result in neither getting an I.P. address and therefore not having a way to send packets to each other?

      1 vote
      1. [8]
        first-must-burn
        Link Parent
        You could assign them static IPs. Use IPs in the same subnet but outside the Dynamic IP range of the router. The router will have a setting to specify the DHCP range. For example, if the router is...

        You could assign them static IPs. Use IPs in the same subnet but outside the Dynamic IP range of the router. The router will have a setting to specify the DHCP range.

        For example, if the router is 192.168.1.1, the widest possible DHCP range would be: 192.168.1.2 - 192.168.1.254. Set it to 192.168.1.2 - 192.168.1.220. Then statically configure the IP address of the NUC and NAS to 192.168.1.221 and 192.168.1.222. By putting them outside the DHCP range, you know the router will never assign that IP to anything else. The NAS and the NUC won't depend on the router DHCP to talk to each other, and should work even if the router is down.

        4 votes
        1. [5]
          b3_k1nd_rw1nd
          Link Parent
          interesting, do you know of any useful tutorials on how to do so? never assigned static IPs outside of the I.P. range myself.

          interesting, do you know of any useful tutorials on how to do so? never assigned static IPs outside of the I.P. range myself.

          1 vote
          1. first-must-burn
            Link Parent
            The important thing to know about static addresses is this is something you configure on each device. If you're SSHed into your NUC (I'm assuming it's headless) or connected to the synology via...

            The important thing to know about static addresses is this is something you configure on each device. If you're SSHed into your NUC (I'm assuming it's headless) or connected to the synology via the web browser interface, as soon as you update the IP, you'll lose your connection and need to reconnect on the new (static) IP you set.

            Here is one for synology NAS

            Here's one covering the various Linux distributions which I'm assuming is what your running on the NUC.

            You'll also have to manually set the DNS and the Gateway in each config. The Gateway will be the address of your router, e.g. 192.168.1.1 (but yours might be different!).
            For DNS I would use Cloudflare 1.1.1.1 or Google 8.8.8.8.

            1 vote
          2. [3]
            elight
            Link Parent
            The how would depend on the router's user interface. You will likely need the MAC (a hard-coded unique address for the physical Ethernet adapters) for your NUC and your Synology. You'll use these...

            The how would depend on the router's user interface.

            You will likely need the MAC (a hard-coded unique address for the physical Ethernet adapters) for your NUC and your Synology. You'll use these to tell your router which Ethernet adapters on your network should get which static IP. I don't recall how to get that from Linux. With Windows, pretty sure it'll be listed as a "property" of the Ethernet adapter in network settings. The synology may have it printed somewhere on the case but likely also lists it I. The synology's software (however you configure it).

            In my (old) router, IIRC, DHCP is also in the same page as static IPs. I reduced the DHCP address range (you can specify the high and low boundary addresses).

            Then, in your router, under DHCP, you'll probably need to find the MAC address for the two devices. In my router, IIRC, theres a button or some sort of link to switch the device from DHCP to a static IP. Then you should be able to set the static IP (that you choose yourself). Don't forget to hit "save" or similar. These router UIs can be fussy. Your router may have to reboot itself after changing these settings but probably not.

            I hope this helps. Each brand and generation of router tends to be a bit different and have different software.

            1. [2]
              papasquat
              Link Parent
              Even if it's labeled as "static IP" in the router, this is actually what's known as a DHCP reservation. Addresses learned from DHCP have a set lease time, usually around 8 hours. A DHCP...

              Even if it's labeled as "static IP" in the router, this is actually what's known as a DHCP reservation.
              Addresses learned from DHCP have a set lease time, usually around 8 hours. A DHCP reservation just makes sure that for a given MAC address, the DHCP server always assigns a set IP address. The issue with this in OPs case is that if the DHCP server is down (in this case, his router) when the lease expires, the server and NAS will automatically stop using that IP address because it no longer has a valid lease on it.

              True Static IPs should instead be configured, which is done on the devices themselves. Those IPs should be outside of the router's DHCP scope, otherwise there's a chance the router will assign some other device the same IP of the NAS or server, since those IPs will be configured independently of DHCP.

              1. elight
                Link Parent
                Ah, yes, I see. Excellent point.

                Ah, yes, I see. Excellent point.

        2. [2]
          LetterCounter
          Link Parent
          Just curious, why wouldn't you just use DHCP address reservation? Wouldn't this do the same thing? If it's just about not relying on the router to stay connected, then I don't see the benefit. If...

          Just curious, why wouldn't you just use DHCP address reservation? Wouldn't this do the same thing?

          If it's just about not relying on the router to stay connected, then I don't see the benefit. If the router is down, the power is likely out, and if the power is out, I'm not going to waste energy on a network. I'd prioritize my refrigerator and keeping phones charged.

          1. first-must-burn
            Link Parent
            If it's a commodity / SOHO router, then I wouldn't assume the router will never (or even rarely) fail on its own. The OP also said the router already went down, causing these problems. DHCP...

            If it's a commodity / SOHO router, then I wouldn't assume the router will never (or even rarely) fail on its own. The OP also said the router already went down, causing these problems.

            DHCP reservation could work for short outages, but if you get unlucky, the lease might expire during the outage. That static IPs mean the NUC stays up as long as the switch is up.

            1 vote
      2. tibpoe
        Link Parent
        No, keep the router connected. It sounds like you have the setup I was thinking of in place already, I'm not sure why it isn't working. Was the switch getting powered off at the same time as the...

        No, keep the router connected. It sounds like you have the setup I was thinking of in place already, I'm not sure why it isn't working. Was the switch getting powered off at the same time as the router?

  2. [4]
    Liru
    Link
    It's basically how NFS works, unfortunately. The reason it happens is because your Nextcloud instance is attempting to connect to the NAS, the NFS link is down, and the Nextcloud instance blocks...

    Why is this an issue? it causes my nextcloud to freeze up as the files it is supposed to share are no longer available. necessitates me restarting my NUC to get the connection going again.

    It's basically how NFS works, unfortunately. The reason it happens is because your Nextcloud instance is attempting to connect to the NAS, the NFS link is down, and the Nextcloud instance blocks because of the attempts to retry, thinking that it's just taking a long time to read.

    There are a few workarounds for that, but if you're insistent on using NFS, I'd look into using autofs to mount it.

    I'm unsure of what the failure mode is of Nextcloud trying to access a share that suddenly doesn't exist, though, as opposed to one that hangs when attempting to access a share.

    My question to you is, why is the Nextcloud instance on the NUC and not on the NAS?

    1 vote
    1. [3]
      b3_k1nd_rw1nd
      Link Parent
      cause I like having my docker-compose config files on my git repos and something I can run from command-line and Synology makes it really unfriendly to do docker stuff from command-line.

      My question to you is, why is the Nextcloud instance on the NUC and not on the NAS?

      cause I like having my docker-compose config files on my git repos and something I can run from command-line and Synology makes it really unfriendly to do docker stuff from command-line.

      1. gil
        Link Parent
        Not sure if you have something specific but I run my containers from the CLI inside my Synology NAS, also with a docker-compose, and it works well. Regardless, I'd say if Nextcloud freezes when...

        Not sure if you have something specific but I run my containers from the CLI inside my Synology NAS, also with a docker-compose, and it works well.

        Regardless, I'd say if Nextcloud freezes when the connection drops, then it's probably more a Nextcloud limitation that doesn't play well when storage isn't guaranteed. And with your setup, you can never guarantee it 100% of the time anyways. I'd try to write a script to reconnect NFS and restart the Nextcloud container when that happens.

        1 vote
      2. JXM
        Link Parent
        I’ve found that using Portainer to manage my docker containers on my Synology gives me 95% of the features I’d want to use a command line for.

        I’ve found that using Portainer to manage my docker containers on my Synology gives me 95% of the features I’d want to use a command line for.

  3. Rudism
    Link
    Does your NAS support using SMB/CIFS instead of NFS? I don't have a NAS but instead a Raspberry Pi with some hard drives plugged in that I share to both windows and linux clients (including...

    Does your NAS support using SMB/CIFS instead of NFS? I don't have a NAS but instead a Raspberry Pi with some hard drives plugged in that I share to both windows and linux clients (including mounting shared directories into some docker containers on the linux clients) and it seems to survive router resets and other network hiccups just fine.

  4. dfx
    Link
    It may be worthwhile to buy a couple of USB 1g ethernet dongles (or 2.5 if you’re so inclined and have USB ports that will support it), assign each interface a static IP address on a different...

    It may be worthwhile to buy a couple of USB 1g ethernet dongles (or 2.5 if you’re so inclined and have USB ports that will support it), assign each interface a static IP address on a different subnet, and connect those two interfaces directly to each other via a single Ethernet cable. Use the new IP on the new subnet in your NFS connection settings on the NUC and you’ll never have to rely on your router to make that connection.

    The only thing to watch out for is making sure there aren’t any driver compatibility issues with the Synology and USB adapter.