Chinaunix首页 | 论坛 | 博客
  • 博客访问: 202220
  • 博文数量: 50
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 583
  • 用 户 组: 普通用户
  • 注册时间: 2012-08-12 14:38
文章分类

全部博文(50)

文章存档

2013年(50)

我的朋友

分类: 其他平台

2013-04-13 20:46:45

Ubuntu12.10搭建tftpnfs服务器

参考博客:点击打开链接

一、搭建tftp

1.安装tftp

     sudo apt-get install tftp-hpa tftpd-hpa

     其中:tftp-hpa是客户端,tftpd-hpa是服务器端

2.配置tftp服务器

     a.修改/etc/default/tftpd-hpa配置文件

          TFTP_DIRECTORY="/var/lib/tftpboot"修改为TFTP_DIRECTORY="/home/m/tftpboot"

          TFTP_OPTIONS="--secure"修改为TFTP_OPTIONS="-l-c -s"

     b.建立服务器文件夹

          mkdir/home/m/tftpboot

3.重启tftp服务并测试

     m@ubuntu> sudo service tftpd-hpa restart

     [sudo]password for m:

     tftpd-hpastop/waiting

     tftpd-hpastart/running, process 6014

     m@ubuntu~/tftpboot> echo -e "Hello,zhouyixing!\n" >> a.txt

     m@ubuntu~/tftpboot> echo -e "Hello,zhouyixing. You are a great man!\n" >> b.txt

     m@ubuntu~/tftpboot> cd /home/

     m@ubuntu~> tftp localhost

     m@ubuntu~> echo -e "Hello,tftp service! \n" >> b.txt

     m@ubuntu~> tftp localhost

     tftp>get a.txt

     tftp>put b.txt

     tftp>quit

     m@ubuntu~> cat -n a.txt

          1 Hello,zhouyixing

     m@ubuntu~> cd tftpboot/

     m@ubuntu~/tftpboot> cat -n b.txt

          1 Hello,tftpservice!

二、配置nfs服务器

     1.安装nfs

          $sudo apt-get install nfs-kernel-server rpcbind

     2.配置nfs,添加nfs共享目录

          a.修改/etc/exports,在该文件最后面添加:

          /home/m/Books/*(rw,sync,no_root_squash)

          其中

               *代表允许所有网段访问

               rw代表读写权限

               sync代表同步写入内存和硬盘

           另外

               ro只读访问
               rw
读写访问

               sync所有数据在请求时写入共享
               asyncnfs
在写入数据前可以响应请求
               securenfs
通过1024以下的安全TCP/IP端口发送
               insecurenfs
通过1024以上的端口发送
               wdelay
如果多个用户要写入nfs目录,则归组写入(默认)
               no_wdelay
如果多个用户要写入nfs目录,则立即写入,当使用async时,无需此设置.
               hide
nfs共享目录中不共享其子目录
               no_hide
共享nfs目录的子目录
               subtree_check
如果共享/usr/bin之类的子目录时,强制nfs检查父目录的权限(默认)
               no_subtree_check
和上面相对,不检查父目录权限
               all_squash
共享文件的UIDGID映射匿名用户anonymous,适合公用目录。
               no_all_squash
保留共享文件的UIDGID(默认)
               root_squashroot
用户的所有请求映射成如anonymous用户一样的权限(默认)
               no_root_squasroot
用户具有根目录的完全管理访问权限
               anonuid=xxx
指定nfs服务器/etc/passwd文件中匿名用户的UID
               anongid=xxx
指定nfs服务器/etc/passwd文件中匿名用户的GID

          b.设置访问权限

          ***/etc/hosts.deny***
          portmap:ALL
          lockd:ALL
          mountd:ALL
          rquotad:ALL
          statd:ALL
          ***/etc/hosts.allow***
          portmap:172.22.1.56
          lockd:172.22.1.56
          mountd: 172.22.1.56
          rquotad: 172.22.1.56
          statd:172.22.1.56

    3.重启nfs服务并测试

    m@ubuntu~> sudo /etc/init.d/nfs-kernel-server restart

    [sudo]password for m:

    *Stopping NFS kernel daemon [ OK ]

    *Unexporting directories for NFS kernel daemon... [OK ]

    *Exporting directories for NFS kernel daemon... exportfs: /etc/exports [2]: Neither 'subtree_check' or'no_subtree_check' specified for export             "*:/home/m/Books/".

    Assumingdefault behaviour ('no_subtree_check').

    NOTE:this default has changed since nfs-utils version 1.0.x


    [OK ]

    *Starting NFS kernel daemon [ OK ]

    m@ubuntu~> showmount -e

    Exportlist for ubuntu:

    /home/m/Books*

    m@ubuntu~> sudo mount -t nfs -o nolock localhost:/home/m/Books /mnt

    [sudo]password for m:

    m@ubuntu~> df

    df:`/root/.gvfs': Permission denied

    Filesystem 1K-blocks Used Available Use% Mounted on

    /dev/sda1 31994800 5310292 25059268 18% /

    udev 505476 4 505472 1% /dev

    tmpfs 205328 800 204528 1% /run

    none 5120 0 5120 0% /run/lock

    none 513312 164 513148 1% /run/shm

    none 102400 52 102348 1% /run/user

    localhost:/home/m/Books 31994880 5310336 25059328 18% /mnt

注:只要设置正确IP,也可以在arm开发板挂载nfs

阅读(1960) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~