0

I have searched all over the Internet, and perhaps I missed the answer to this question, but I still cannot solve it yet.

So far, I have successfully mounted my QNAP drive:

  1. Make a folder for the mount point: /home/t420/QNAP
  2. Edit (after getting root privileges) the /etc/fstab file to include the following:
    • //192.168.x.xxx/homes /home/t420/QNAP nfs defaults
    • sudo mount -a
    • For those who are new at this and trying to learn or those trying to understand what the heck I am doing, this is what I understand of the first line I added:
      • 1st field is the "block device", the address and folder of the device you are trying to mount.
      • 2nd field is the mount point folder.
      • 3rd field is the file system type (nfs in my case).
      • 4th field are mount point options (using defaults).
      • 5th field is for the ability of a backup utility to dump the file system, or something like that. I've left that field blank for now.
  3. The second line in the fstab file is my attempt to automatically mount the NAS drive.

The drive fails to mount automatically, although QNAP appears in the list of drives. If I try to click on the QNAP under the list of drives, I get the message

  • Unable to mount QNAP mount:/home/t420/QNAP: operation permitted for root only.

I am able to manually mount the drive:

  • If I enter root mode by typing su root, then the password, and then type the following:
  • mount -t nfs 192.168.x.xxx/homes:/home/t420/QNAP

See error and correction in my comment below

|===============================================================|

To make matters more frustrating, I am now unable to mount the drive manually either. I get the message "can't find in /etc/fstab". I typed the mount command exactly as you see it above (with x's replaced by the appropriate address numbers), and the line in the fstab file also exactly as you see it. It seems that it won't recognize my QNAP folder. I really want to love Linux, but this learning curve is very icy right now.

What am I doing wrong here?!?

Larry

2
  • Solved one problem. When manually mounting, the line: mount -t nfs 192.168.x.xxx/homes: /home/t420/QNAP must have the space between homes: and /home. Instructions from QNAP did not show this space which caused me this grief.
    – larryjb
    Commented Mar 25, 2023 at 3:22
  • Lines in the /etc/fstab have been changed to: 192.168.x.xxx/homes /home/t420/QNAP nfs defaults and sudo mount -a. The two // have been removed. I have also tried mount -a, and also tried mount -t nfs 192.168.1.141: /home/t420/qnap. The drive still fails to automatically mount. (The drive would manually mount even when using the //, but they are now removed as they are not to be used here.)
    – larryjb
    Commented Mar 25, 2023 at 15:52

3 Answers 3

0

Add auto to the options in the entry in your fstab; that will cause the mount to be executed at boot-time.

2
  • By adding "auto", do you mean replace "defaults" with "auto", or does this have to go somewhere in the fstab file? According to what I understand, auto is part of the default setting for this line when the -a switch is used with the mount command.
    – larryjb
    Commented Mar 25, 2023 at 2:14
  • Replacing "defaults" with "auto" did not automount the drive.
    – larryjb
    Commented Mar 25, 2023 at 3:43
0

It took me the entire day to finally abandon trying to use /etc/fstab to automatically mount drives, or at least nfs type drives.

In one go I got AutoFS to work. I did need to install it, but the instructions I came across were splendid. They are from https://devconnected.com/how-to-install-autofs-on-linux/

Essentially, what you do is this:

  • Open the terminal then make sure your Linux is up to date: $ sudo apt-get update

  • Install AutoFS: $ sudo apt-get install autofs

  • enable AutoFS to run at startup: $ sudo systemctl enable autofs

  • create a map file so autofs knows where to mount the drive: $ sudo touch /etc/auto.anyname

  • edit the map file using your favourite editor $ sudo nano /etc/auto.anyname

  • add the lines:

    #Create direct map with AutoFS

    # <remote_ip>:

    /media/anyfolder -fstype=nfs 192.168.xxx.xx:/remotefolder

  • save and close this file.

  • open /etc/auto.master and add the following: /- /etc/auto.anyname

  • save and close this file

  • restart autofs $ sudo systemctl restart autofs

And it worked! Best of all, after reboot, it still mounted the network drive. This was WAY easier than messing with /etc/fstab. I think the issue is that nfs needs root privileges to mount. I don't think that is the case with other types.

I'm a happy camper, at least for now.

0

See man fstab - under section "The first field", in the second paragraph it says:

For NFS mounts, this field is <host>:<dir>, e.g., knuth.aeb.nl:/.

Note that there is no leading //, it's just the hostname (or IP Address), a colon, and the remote directory name. // is how you specify a remote filesystem in Windows, not in Linux.

As an absolute minimum (but see man 5 nfs for details on various options) that would be:

192.168.x.xxx:/homes /home/t420/QNAP nfs defaults 0 0

the last two fields are optional, but I prefer to include them in fstab entries.

3
  • Thanks for pointing out my error. Unfortunately this does not help to automatically mount the drive.
    – larryjb
    Commented Mar 25, 2023 at 15:54
  • Then you're doing something else wrong, maybe the qnap server is misconfigured, maybe /home/t420/QNAP doesn't exist. dunno, but this /etc/fstab entry is 100% correct, I've been mounting NFS like this for decades. Unless there's some other problem, the fs will be auto-mounted on boot. or by running mount -a or mount /home/t420/QNAP as root.
    – cas
    Commented Mar 25, 2023 at 16:10
  • The -t switch does require root privileges. Could this be preventing auto-mounting? I can manually mount the drive in root, so the server must be configured correctly and the /home/t420/QNAP must be correct.
    – larryjb
    Commented Mar 25, 2023 at 16:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .