zoukankan      html  css  js  c++  java
  • Ubuntu: 搭建tftp,nfs服务器

    Ubuntu12.04搭建tftp&nfs服务器 http://blog.163.com/thinki_cao/blog/static/83944875201411610467306/

    硬件环境:HP CQ45 308
    操作系统:KUbuntu12.04 LTS 32bit

    以下tftp与nfs配置方法经本人实测,均切实可行!

    tftp服务器
    1 安装相关的软件包:

    sudo apt-get install tftpd-hpa tftp-hpa

    2 修改配置
    配置文件在 /etc/default/tftpd-hpa,内容如下:
     
    # /etc/default/tftpd-hpa
     
    TFTP_USERNAME=”tftp”
    TFTP_DIRECTORY=”/tftpboot”
    TFTP_ADDRESS=”0.0.0.0:69″
    TFTP_OPTIONS=”-l -c -s”
     
    /tftpboot为tftp服务的目录,如果事先不存在的话我们需要创建它

    sudo mkdir /tftpboot

    3重新启动TFTP服务:

    sudo service tftpd-hpa restart

    4 测试
    $ cd /tftpboot
    $ echo “hello tftp service”>>a.txt
    $ tftp localhost
    tftp> get a.txt
    如果这一步执行成功的话说明从tftp服务器下载东西已经成功!
    注意:tftp-hpa有一个问题,就是每次开机使用之前都需要重启一下服务
    nfs服务器
    1、安装Ubuntu nfs
    Ubuntu上默认是没有安装Ubuntu nfs服务器的,因此我们首先安装Ubuntu nfs服务器端:

    $sudo apt-get install nfs-kernel-server

    2、配置/etc/exports
    Ubuntu nfs允许挂载的目录及权限在文件/etc/exports中进行了定义例如,我们要将根目录下的rootfs目录共享出来,那么我们需要在/etc/exports文件末尾添加如下一行:
    /rootfs *(rw,sync,no_root_squash)
     
    其中:/rootfs是要共享的目录,*代表允许所有的网络段访问,rw是可读写权限,sync是资料同步写入内存和硬盘,no_root_squash是Ubuntu nfs客户端分享目录使用者的权限,如果客户端使用的是root用户,那么对于该共享目录而言,该客户端就具有root权限
     
    本人的配置如下:
    /rootfs *(rw,sync,no_subtree_check)
     
    注意:在使用之前请将挂载的目录权限全部设置成777即执行sudo chmod 777 /rootfs。另外请把/rootfs替换成你希望挂载的目录
     
    PS:rw sync等之间是不能有空格的,否则报exportfs: /etc/exports:1: syntax error: bad option list
     
    3、Ubuntu nfs重启服务
    $sudo service portmap restart
    $sudo service nfs-kernel-server restart
    如果出现如下错误:
    mount: wrong fs type, bad option, bad superblock on xxxxxx,
    missing codepage or helper program, or other error
    (for several filesystems (e.g. nfs, cifs) you might
    need a /sbin/mount. helper program)
    In some cases useful info is found in syslog – try
    dmesg | tail or so
     
    解决方法:

    sudo apt-get install nfs-common

     
    4、测试Ubuntu nfs
    此时可以运行以下命令来显示一下共享出来的目录:

    $showmount -e

    或者可以使用以下命令把它挂载在本地磁盘上,例如将/rootfs挂载到/mnt下:

    $ sudo mount -t nfs localhost:/rootfs /mnt

    可以运行df命令查看是否挂载成功。查看后可以使用以下命令卸载:

    $ sudo umount /mnt

     
  • 相关阅读:
    构建之法阅读笔记01
    最长英语单词链
    第十五周学习总结
    寻找“水王”
    Happy Necklace HDU
    Bi-shoe and Phi-shoe LightOJ
    The Embarrassed Cryptographer POJ
    Big Number HDU
    矩阵乘法模板C/C++
    Baby Step,Giant Step算法模板
  • 原文地址:https://www.cnblogs.com/mylinux/p/5150344.html
Copyright © 2011-2022 走看看