LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   NFS mount external drive (https://www.linuxquestions.org/questions/linux-networking-3/nfs-mount-external-drive-601848/)

gmh04 11-23-2007 05:08 AM

NFS mount external drive
 
Hello

I'm having some trouble NFS mounting a USB external drive.

On my server I mount the drive in /etc/fstab as:

Quote:

/dev/sda1/ /media/archive vfat rw,user,gid=archive,umask=007 0 0
On the client I can mount it with

Quote:

mount -t nfs 198.168.1.2:/media/archive /archive
However I get permission denied when I try to access /archive

I can successfully mount any other location from the server, but not the /media/archive which is a USB external drive.

I'm running Debian Etch on both machines.

Attempting to mount the same drive from Ubuntu give me the following error:

Quote:

mount: wrong fs type, bad option, bad superblock on 192.168.1.2:/media/archive,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try
dmesg | tail or so
Any help is appreciated.

jschiwal 11-23-2007 05:39 AM

Could you show "ls -ld /media/archive" on the server.

Also, /etc/exports on the server and /usr/sbin/showmount --exports 192.168.1.2 at the client.

You might want to use the "uid=<username>" option in mounting the devices.

gmh04 11-23-2007 05:58 AM

ls -ld /media/archive/

Quote:

drwxrwx--- 11 root archive 32768 1970-01-01 01:00 /media/archive/
/etc/exports

Quote:

/media/archive 192.168.1.0/20(rw,sync,subtree_check)
(on client) /sbin/showmount --exports 192.168.1.2

Quote:

Export list for 192.168.1.2:
/media/archive 192.168.1.0/20

Can you give me an example of using "uid=<username>" option, I'm having a bit of trouble with it?

jschiwal 11-23-2007 07:22 AM

For an external drive use the UUID= or LABEL= entry instead of the device node. The device node could easily change for an external drive.

Code:

udevinfo -q env -n /dev/sdb1
DEVTYPE=partition
ID_VENDOR=SanDisk
ID_MODEL=Cruzer_Mini
ID_REVISION=0.1
ID_SERIAL=SanDisk_Cruzer_Mini_200517395007FC20132F-0:0
ID_SERIAL_SHORT=200517395007FC20132F
ID_TYPE=disk
ID_INSTANCE=0:0
ID_BUS=usb
ID_PATH=pci-0000:00:02.2-usb-0:2.7:1.0-scsi-0:0:0:0
ID_FS_USAGE=filesystem
ID_FS_TYPE=vfat
ID_FS_VERSION=FAT16
ID_FS_UUID=3B69-1AFD
ID_FS_UUID_ENC=3B69-1AFD
ID_FS_LABEL=XMas
ID_FS_LABEL_ENC=XMas
ID_FS_LABEL_SAFE=XMas

Here I just now plugged in a pendrive. To create a unique fstab entry for this, I will use the UUID instead of the device. Some of these options were selected because it is a pendrive.
Code:

UUID=3B69-1AFD /media/xmas vfat rw,noauto,nosuid,nodev,noatime,flush,uid=1000,utf8,shortname=lower 0 0
Another way is to use a username instead:

Code:

UUID=3B69-1AFD /media/xmas vfat rw,noauto,nosuid,nodev,noatime,flush,user,uid=jschiwal,gid=jschiwal,fmask=117,dmask=007,utf8,shortname=lower 0 0
The noauto, and uid and user options work good together. (Come to think of it, using the "owner" option might be even better in this case) The uid= option sets the ownership of the mounted partition, and it's contents. The ownership for vfat and ntfs are set in the fstab options and not using "chown" as you could with a native Linux filesystem.

Using the above fstab entry, a normal user can mount and umount the disk. The ownership and group ownership will be jschiwal.jschiwal and the permissions will be rwxrrx--- on directories and rw-rw--- on files. Because the uuid number is unique, I can have more than one fstab entry, one for each pendrive. Another user could not access it on this computer. (very weak security I know, but still convenient.) User jschiwal can mount it without using sudo. It could even be mounted by a command in ~/profile.

On the client (hpmedia.jesnet) I added this to /etc/fstab:
Code:

hpamd64.jesnet:/mnt/xmas /mnt/xmas nfs noauto,defaults,soft,_netdev 0 0

On the server (hpamd64.jesnet) I added this to /etc/fstab:
Code:

UUID=3B69-1AFD  /mnt/xmas      vfat    rw,noauto,nosuid,nodev,noatime,flush,user,uid=jschiwal,gid=jschiwal,fmask=117,dmask=007,utf8,shortname=lower 0 0
and to /etc/exports:
Code:

cat /etc/exports
/mnt/xmas      *.jesnet(fsid=0,ro,root_squash,sync,no_subtree_check)

Now on the client:
Code:

sudo mount /mnt/xmas
root's password:
jschiwal@hpmedia:~> ls -ld /mnt/xmas
drwxrwx--- 2 jschiwal jschiwal 16384 Dec 31  1969 /mnt/xmas

If the pendrive weren't mounted on the server, then trying to mount /mnt/xmas on the client would fail. Also, I didn't change the ownership of /mnt/xmas on the client. Before mounting it's owned by root.

One difference is that I didn't use root as the owner, and I used root_squash on the export definition. I assume that in your case a member of user "archive" uses this nfs share for creating backups.

I wouldn't recommend using ntfs (or vfat) as the filesystem of choice. Use a native Linux filesystem. While ntfs-3g has read/write support, I wouldn't trust it for something as important as backups. Fat32 has a small filesize limit and isn't very robust.

Using /media/ for the drive mount may not be a good idea either on the nfs server. While /media/ is used for external media, since you are offering it up as a share and since you have an entry for it in /etc/fstab, using /media might cause problems due to hald interaction. I'm not certain but would use /mnt/ instead as a precaution.
---

I hope I remember to undo all this after posting!:eek:

gmh04 11-23-2007 08:33 AM

Thanks for that, I can mount the drive from a debian client. A number of points though, my device has a blank ID_FS_UUID so I had to stick with /dev/sda1, and the flush option was not recognised (I just removed it).

More frustratingly though, I still have the same error on the Ubuntu client. I run the same command and still get:

Quote:

mount: wrong fs type, bad option, bad superblock on 192.168.1.2:/media/archive,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try
dmesg | tail or so

gmh04 11-24-2007 04:03 AM

I solved the problem on Ubuntu by installing nfs-common. I didn't realise this was required on the client.

jschiwal, thanks for you help and advice!

borobudur 12-30-2007 05:58 AM

Serveral User Problem with remote usb mount
 
Nice explanation jschiwal!

I just have one little problem with my remote usb-drive.

I have two users on the client and one of them can't access the mount because the owner after mounting is the user with uid=1000.

I don't understand who sets it to this user?

Here a better explanation of the actual condition:
Server has user X
Client has user Y and Z
After mounting the mounted directory has the owner Y and group Y.
Z can't access

Any idea??


All times are GMT -5. The time now is 04:42 PM.