I have a linux board (board 1) using linux 4.19.0 and a rootfs from buildroot. This board has a partition (ext2) that is to be used for another board (board 2) to nfs mount for its rootfs.
So the problem occurs before we even have a mount event. The problem occurs when the exportfs command executes.
Here’s the output from the exportfs command:
$ ./exportfs -rav
exporting *:/srv/nfs/disc1_1
exportfs: /srv/nfs/disc1_1 does not support NFS export
$
I was very annoyed with the level of information so I then ran it with strace and here is the relevant area of the output where the application decides that the export is not valid:
openat(AT_FDCWD, "/etc/exports.d", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = -1 ENOENT (No such file or directory)
fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0), ...}) = 0
write(1, "exporting *:/srv/nfs/disc1_1n", 29exporting *:/srv/nfs/disc1_1
) = 29
newfstatat(AT_FDCWD, "/srv/nfs/disc1_1", {st_mode=S_IFDIR|0755, st_size=0, ...}, 0) = 0
openat(AT_FDCWD, "/proc/net/rpc/auth.unix.ip/channel", O_WRONLY) = 3
write(3, "nfsd 0.0.0.0 9223372036854775807"..., 47) = 47
close(3) = 0
openat(AT_FDCWD, "/proc/net/rpc/nfsd.export/channel", O_WRONLY) = 3
close(3) = 0
statfs("/srv/nfs/disc1_1", {f_type=RAMFS_MAGIC, f_bsize=4096, f_blocks=0, f_bfree=0, f_bavail=0, f_files=0, f_ffree=0, f_fsid={val=[0, 0]}, f_namelen=255, f_frsize=4096, f_flags=ST_VALID}) = 0
openat(AT_FDCWD, "/proc/net/rpc/nfsd.export/channel", O_WRONLY) = 3
write(3, "-test-client- /srv/nfs/disc1_1 "..., 53) = -1 EINVAL (Invalid argument)
close(3) = 0
write(2, "exportfs: ", 10exportfs: ) = 10
write(2, "/srv/nfs/disc1_1 does not suppor"..., 44/srv/nfs/disc1_1 does not support NFS export) = 44
write(2, "n", 1
) = 1
I also tried to dig into the file that is referred to in the trace: “/proc/net/rpc/nfsd.export/channel”. I tried a write to it using “echo” from the command line and piping in the string that is defined by exportfs (I actually dug around in exportfs.c and printed this out using some debug, “-test-client- /srv/nfs/disc1_1 3 8192 65534 65534 0”) to that file, it was reported as not existing so I gather it is some other kind of file that doesn’t allow this.
I was able to export a directory on the same board that was in a partition of type jffs2 but since it’s RO I can’t use it for a rootfs. I only did it to ensure that the kernel did indeed support NFS exports.
Obviously my question is, why doesn’t the exportfs work on a system for a ext2 directory when it does for a JFFS2 directory. Also, what is that file being referred to: “/proc/net/rpc/nfsd.export/channel”.
Cheers!!