Is it possible to create a NFS Share from a CIFS mounted directory?

9,077

Solution 1

You can pass from cifs mount to nfs export via a fuse filesystem, though I don't think I would recommend it for something as essential as backup.

When I tried this once I looked for a fuse filesystem that would be as transparent as possible, and ending up with fuse-convmvfs. This software is intended to convert filenames from one encoding to another, but if you configure it to the same encoding at both sides, it seems to work as you need.

Quite simply, if you have your cifs mount at /mnt/samba, you can mount your fuse at /mnt/fuse and export this directory by nfs using an /etc/exports entry like

/mnt/fuse backupmachine(ro,fsid=55)

and the commands

$ sudo sh -c 'echo user_allow_other >>/etc/fuse.conf'
$ sudo convmvfs /mnt/fuse -o srcdir=/mnt/samba,icharset=iso-8859-1,ocharset=iso-8859-1,user_allow_other
$ sudo exportfs -a

The user_allow_other part is probably not needed for nfs export. While this is ok as an experiment, note that nfs is dangerous with filesystems that do not use the same inode in a repeatable way, and that is probably why nfs on top of cifs is not implemented. Adding the fuse layer is not necessarily going to fix this. Perhaps if you can independently produce a list of md5 sums of each file locally on the cifs server, and locally on the backup machine, and compare the two, you might have some confidence in a backup.

Solution 2

CIFS is not officially supported.

http://nfs.sourceforge.net/

C6. Which local file systems can I export with the Linux NFS server?

A. We expect the following local file systems to work, as they are tested often: ext2, ext3, jfs, reiserfs, xfs.

These local file systems may work or may have a few minor-ish issues: iso9660, ntfs, reiser4, udf. Ask on the NFS mailing list for details.

Any file system based on FAT or not having the ability to provide permanent inode numbers will have trouble with NFS versions 2 and 3 (see question C4).

Local file systems that are known not to work with the Linux NFS server are: procfs, sysfs, tmpfs (and friends)

Don't know whether this list of supported file systems is up-to-date. However I would recommend to only use one of these supported ones. Even if other file systems may seem to work there could be subtle bugs, like ext4/nfs readdir problem.

Share:
9,077

Related videos on Youtube

flobbi123
Author by

flobbi123

Updated on September 18, 2022

Comments

  • flobbi123
    flobbi123 over 1 year

    The problem is that I have a directory which is mounted over CIFS. For this directory I want to create a NFS Share. I need this to create backups on a backup system which is only mountable over CIFS, from our ESX (But the ESX can only create backups on NFS Shared directorys with "ghettoVCB").

    To solve this issue my first attempt was create a third Linux Machine with Debian.

    test arrangement:

    Backup Storage -> Debian machine (mounting CIFS directory and creating NFS Share) -> ESX (where we create the Backups)

    Procedure:

    Mount directory over CIFS. Then create an entry in /etc/exports for this mounted directory. After creating the export I get this Error: exportfs: /mnt/backup does not support NFS export

    I hope you get what I wanted to say. If you need more information let me know.

    Well someone said to me that it is not possible. Perhaps anybody of you can help me with this issue or can give me an alternative solution.

    • Арсений Черенков
      Арсений Черенков over 7 years
      you can't export something that is already exported. either export NFS from first host (to both production server and backup host), or have another backup agent.
    • flobbi123
      flobbi123 over 7 years
      Ok, you are right. Seems logic, but unfortunatley I just want to create a kind of forwarding. So the backup server is only compatible with CIFS and the ESX only with NFS (It is not depending on the service "ghettoVCB"). Do you know any solution how to create something like that? Or do you know any backupagent where I can create something like this.
    • drHogan
      drHogan over 7 years
      You may try explicitly nfs <=3 as v4 seems to be more restrictive. Though maybe waste of time.
    • Thomas
      Thomas over 7 years
      It might work with a user space NFS server like ganesha or unfs. But you really should thoroughly test the setup.
    • flobbi123
      flobbi123 over 7 years
      I will test it and let you know if it works
    • flobbi123
      flobbi123 over 7 years
      It also won't work with ganesha, but thanks for the alternative.
    • Levi Uzodike
      Levi Uzodike over 4 years
      @Archemar Is there any documentation to support your claim? I believe you, but I need solid evidence to prove it to someone else. In my case, I was using sshfs to mount on (accessed through remote port forwarding using Putty) server A a directory that was cifs mounted on server B from a Windows server. (directory on Windows -cifs mount->server A -sshfs->server B). I was told to try substituting sshfs with a cifs mount (directory on Windows -cifs mount->server A -cifs mount->server B). According to your statement, this would fail as well, right?
  • flobbi123
    flobbi123 over 7 years
    Many thanks.. than i should see if I can find an alternative solution if it is not possible with CIFS.
  • flobbi123
    flobbi123 over 7 years
    You are right. Normally we backup our data directly via NFS but this is a special case, because we want to use the backup storage from our hoster.
  • flobbi123
    flobbi123 over 7 years
    I will try this and see if it works non-disruptive. But many thanks in advance!
  • flobbi123
    flobbi123 over 7 years
    Just one question. The File Converter convmfs: In which packet can I find this converter? It seems like there are only two google hits with this topic :) I just found convmv but this is not the tool I was looking for.
  • meuh
    meuh over 7 years
    I found the fuse filesystem in package fuse-convmvfs, on Fedora 22, Ubuntu 14 and Debian 8.6.
  • flobbi123
    flobbi123 over 7 years
    Just one more question ... Now the connection works. If I add an entry in the cifs Folder it is pushed automatically to the nfs folder. But when I want to do this backwards, I mean from the nfs Folder to the Cifs Folder it says I have not the rights to create the data.. I think it is because of the User from CIFS. Can you help me one more time... This is a topic which is too special for me..
  • meuh
    meuh over 7 years
    There are a lot of places where user permissions are being checked that you need to look at. To start with did you use rw instead of ro in the /etc/exports for nfs? I presume you also tried changing the cif mounted files before doing the fuse mount, and it was ok. To see if the problem is with cifs or fuse, try using the fuse method on a local set of files and see if you can change them from nfs. Look at the mount.cifs man page, and fuse man page. I don't use cifs much so I don't really know any more. Perhaps you can post a new question with specific details for more help.