我在Ubuntu 12.04上创build了自己的PXE / NFSnetworking启动服务器,如下所述。 如果我在服务器端更改/etc/exports文件,我可以在客户端写入文件:
/srv/ubuntulivecd/ *(rw,async,no_root_squash,no_subtree_check)
我只想在本地更改文件。 我的意思是这不应该改变NFS分区上的文件,如果我写本地文件。 如果我将rw(read-write)选项更改为ro(read-only) ,由于权限,我无法更改文件(如预期的那样)。 有没有办法在本地或临时更改文件(所有文件必须在重新启动或closures后删除)在客户端?
在客户端中,您可以将文件复制到tmpfs (与live-cd启动相同)。 您需要在NFS的RO文件系统和本地机器上的tmpfs RW文件系统之间设置联合typesFS( aufs )。
example for tmps: $ mount -t tmpfs no_device /tmp
现在你在/ tmp上做的所有事情都可以在ramfs上运行
example for union: $ ls dir1 subdir $ ls dir1/subdir file1 $ ls dir2 subdir $ ls dir2/subdir file2 $ mkdir dir_union $ mount -t aufs -o dirs=dir1=rw:dir2=ro no_device dir_union $ ls dir_union subdir $ ls dir_union/subdir file1 file2
注意dir1 = rw和dir2 = ro 。 现在你可以$ rm dir_union/subdir/file2 ,这应该是ro ,但是在union中你可以修改它,你将不会有错误。 事实上只有差异被映射。 如果你这样做
$ ls -la dir_union file1 .wh.file2
其中.wh.file2是映射不同的文件。
与光盘相同:
$ mount -o ro /dev/cdrom /mnt/cdrom mount -t tmpfs no_device /mnt/rw mount -t aufs -o dirs=/mnt/rw=rw:/mnt/cdrom=ro no_device /mnt/union
在这里,您将在/ mnt / union中看到CD-ROM的所有原始文件。 如果修改了这些差异,则可以在/ mnt / union中更改文件,但是/ mnt / cdrom中的原始文件保持不变。
现在,作为练习,做一个NFS挂载;)
干杯