How to mount with NFS an USB hard disk

I’ve used YAST to include a USB hard disk in the export list and mount it to remote machine with NFS. That worked first time the disk was mounted. On the next reboot I saw that the USB disk was mounted again in “/media” but in new folder and its previous folder existed but empty and was mounted with nfs. It seems that first nfs comes mounted in booting time and then USB gets mounted after logging as a user. USB hard disk finds its folder occupied and automatically creates new folder in “/media”. What should be done in order to USB hard disk and nfs to be mounted in the same point automatically on the boot ?
The second question : When I mount an external disk to be accessible remotely with nfs I get refused to unmount the disk as a USB device. Is it possible to be unmounted as a USB disk done without unmounting it as a nfs as well?

Thanks in advance


OpenSuSE 11.4 x64

About your first question: The mount point should be fixed. AFAIK you can achieve this in two ways, either by creating a specific udev rule for that particular device OR by adding the mount in /etc/fstab. This last one is easier, I think, as all you have to do is let the device be mounted automatically, open /etc/mtab in a text editor or viewer and copy the mount line to fstab, probably with the “soft” option so mount won’t throw an error at boot time. Better yet, if you open Yast’s partitioner with the usb disk mounted, and it will show the device’s partition(s) unique IDs, so you can be sure the same device will always be mounted in the same mount point. You’ll probably have to test a bit with booting with/without the usb device mounted, to see how the system works. And a good read of man mount and man fstab are highly recommended.

Second question: I don’t think you can, and it makes sense. You can’t unmount a device that is in use (by NFS). You have first to unmount the nfs share in the client and then remove the device in the server.

Disclaimer: This is theoretical, in the sense that I never actually did this, only thought about it now, so YMMV.

Check if /media doesn’t have any hidden .lock file or such, if so you can safely delete it and the empty folder, that it will be recreated next time you connect the device. Las time I looked into this was because improperly removed device folders were not cleared (along with their lock files), and subsequent mounts would use sequential numbering, like /mount/DISK, /mount/DISK1, /mount/DISK2, etc. Note that this was some time ago, in oS 11.0 or such, it may have changed now.

I once specified a specific mount point for a particular usb drive and that caused me nothing but problems, most noticeable being that any other usb drive I connected to the system attempted to mount to the same place but couldn’t complaining it already existed. I just don’t think the way the system handles usb drives lends itself to permanent points for them very well

I do wonder though why you want to set a usb drive up as a network share, the nature of usb drives is to be portable and plugged in wherever they’re needed, the only reason I can think of to keep your drive as usb is in the event you wish to unplug it in which case a permanent nfs mount wouldn’t be appropriate anyway and could lead to other problems

Don’t know if you’ve ever seen them but I think a nas enclosure for the drive might be a better option, or even taking the drive out of it’s usb enclosure and put the drive in your server as you would any other internal drive

As a network attached storage (nas) drive it would get it’s own ip address and you would access it via that but personally, if your server has a space for the drive and appropriate power/motherboard connections I would put the drive in the server as it would be tidier, easier and probably more reliable (probably faster too)

On 2011-07-06 17:36, Ecky wrote:
>
> I once specified a specific mount point for a particular usb drive and
> that caused me nothing but problems, most noticeable being that any
> other usb drive I connected to the system attempted to mount to the same
> place but couldn’t complaining it already existed. I just don’t think
> the way the system handles usb drives lends itself to permanent points
> for them very well

I have been doing that for years without problems. Just do not use /media,
but /mnt.


Cheers / Saludos,

Carlos E. R.
(from 11.4 x86_64 “Celadon” at Telcontar)

It was a long time go but I don’t think it was under either as I recall mate

I don’t have a lot of faith in the reliability of usb drives tbh so other than flash drives I rarely use them, for sure can’t see any scenario where I’d wanna use one as network storage