无盘节点

From Gentoo Wiki
Jump to: navigation, search
This page is a translated version of the page Diskless nodes and the translation is 75% complete.

Other languages:
English • ‎español • ‎français • ‎русский • ‎中文(中国大陆)‎ • ‎日本語 • ‎한국어

这篇HOWTO将帮助创建和安装Gentoo Linux的无盘节点。

介绍

关于这篇HOWTO

This article will help setting up diskless workstations based on the Gentoo Linux distribution. This is guide is intended to make the process as user friendly as possible and cater to the Linux newbie, because everyone was at a certain point. While an experienced user could easily tie the multiple articles available on diskless nodes and networking together it's hoped that this guide can ease the installation for all interested users, geeks, or not.

什么是无盘机?

一台无盘机器是一台没有任何诸如硬盘、软盘驱动器或CD-ROM等常见引导设备的PC。无盘节点引导自网络,并需要一台服务器来提供当作本地硬盘来使用的存储空间。从现在开始,服务器将称为“master”,而无盘机器将称为“slave”(从名字中能看出来什么?:)。slave节点需要一块支持PXE引导或Etherboot的网络适配器;支持的列表可以查看Etherboot.org。现在大多数的卡都支持PXE,很多主机集成的适配器也同样可以。

开始之前

Gentoo应该安装在master节点,并且master有足够的空间来为slave节点提供文件系统的储存。同时要确保还有一块独立于本地连接的网卡用于接入互联网。

Configuration

配置master和slave

关于内核

内核是一个介于硬件和其它装载于本地软件之间的软件,也就是基于内核的操作系统的心脏。当一台计算机启动,BIOS运行在硬盘预留引导空间的找到的指令。这些指令通常是一个用于加载内核的引导器。当内核被加载后,所有的进程都由内核来处理。

关于内核及内核配置的更多信息,可访问内核HOWTO

配置master的内核

master的内核可以很大也可以按照需要来定制,但是这些内核选项必须要选中。输入以下命令进入内核配置菜单:

root #cd /usr/src/linux
root #make menuconfig

这里有用来替代手动编辑/usr/src/linux/.config文件的一个灰色和蓝色的GUI。如果这个内核当前工作正常,退出GUI并输入以下命令来保留当前的配置文件将会是一个好的主意:

root #cp .config .config_working

进入下面的子目录并确保列出的条目都选择为内建(而非模块)。下面的选项是取自于2.6.10版本的内核。如果使用不同版本的内核,文字或者顺序可能会不同。只需确保至少选择了以下这些。

KERNEL master的内核选项
[*] Networking support --->
  Networking options --->
    <*> Packet socket
    <*> Unix domain sockets
    [*] TCP/IP networking
    [*]   IP: multicasting
    [ ] Network packet filtering (replaces ipchains)
  
File systems --->
  Network File Systems  --->
    <*> NFS server support
    [*]   Provide NFSv3 server support

如果需要通过master节点访问互联网和/或需要一个安全防火墙,确保添加了对iptables的支持:

KERNEL 启用iptables支持
  [*] Network packet filtering (replaces ipchains)
  IP: Netfilter Configuration  --->
    <*> Connection tracking (required for masq/NAT)
    <*> IP tables support (required for filtering/masq/NAT)

如果还需要包过滤,一会再将剩下的作为模块添加。确保已阅读在Gentoo安全手册中关于防火墙的章节来让它正常工作。

Note
这些内核配置选项仅是应该增加到原系统配置选项中,而不是完整的替换掉原有的内核配置。

在重新配置master的内核之后,需要对它进行重建:

root #make && make modules_install
root #cp arch/i386/boot/bzImage /boot/bzImage-master

然后根据所使用引导器的不同,在lilo.confgrub.conf中为新内核添加一个条目,并确保新内核是默认的那个。现在新的bzImage已经复制到了boot目录,所有所做的这些是为了在重启系统后可以载入这些新的选项。

关于slave的内核

建议将slave的内核编译成无任何模块,因为通过远程引导加载和安装他们是一个困难并且没必要的过程。另外,为了有效的从网络引导,slave的内核应该尽可能的小和精简。slave的内核将在和配置master同样的位置进行编译。

为了避免混乱和浪费时间,键入以下命令来备份master的配置文件将会是一个好主意:

root #cp /usr/src/linux/.config /usr/src/linux/.config_master

现在,slave的内核已经配置得和master的内核的kernel一样时尚了。如果需要一个全新的配置文件,可以键入以下命令来还原默认/usr/src/linux/.config文件:

root #cd /usr/src/linux
root #cp .config_master .config

现在键入以下命令进入GUI配置:

root #cd /usr/src/linux
root #make menuconfig

确保将以下的选项选择为内建而不是内核模块。

KERNEL slave的内核选项
[*] Networking support --->
  Networking options --->
    <*> Packet socket
    <*> Unix domain sockets
    [*] TCP/IP networking
    [*]   IP: multicasting
    [*]   IP: kernel level autoconfiguration
    [*]     IP: DHCP support
  
File systems --->
  Network File Systems  --->
    <*> file system support
    [*]   Provide NFSv3 client support
    [*]   Root file system on NFS
Note
另外也可以通过安装BOOTP服务器来得到一个DHCP服务器。
Important
将节点的网络适配器添加到内核(并且不是作为模块)是重要的。尽管无盘节点使用模块通常不会有问题。

现在的slave需要进行编译。这里要小心不要覆盖或者弄乱为master编译的模块(如果有的话):

root #cd /usr/src/linux
root #make

现在在master上创建用来保持slave自己的及必须的系统文件的目录。这里使用的是/diskless,但是仍然在这可以选择任何更好的位置。现在复制slave的bzImage到/diskless目录:


Note
如果要使用不同的架构,将相应配置各自保存到.config_arch可能会有点用。对镜像文件也是一样的:将它们在/diskless中保存为bzImage_arch


root #mkdir /diskless
root #cp /usr/src/linux/arch/i386/boot/bzImage /diskless

配置一个slave的初步文件系统

master和slave的文件系统可以调整并变更一些。现在的兴趣点是获得一个有合适的配置文件和挂载点的初始的文件系统。首先需要在/diskless中为第一个slave创建目录。由于共享同一系统文件将会造成权限问题及硬崩溃,每个slave需要它们各自的根文件系统。这些目录可以叫作任何管理员觉得合理的名字,但是作者建议使用惟一的并且不会混乱的slave的IP地址。第一个slave的静态IP将以192.168.1.21 为例:

root #mkdir -p /diskless/192.168.1.21/etc

/etc中的许多配置文件需要改变为slave所使用的。键入以下命令复制master的/etc目录到新slave的根:

root #cp -r /etc/* /diskless/192.168.1.21/etc/

这个文件系统仍然没有完成,因为它需要许多挂载点和目录。键入以下命令去创建它们:

root #mkdir /diskless/192.168.1.21/home
root #mkdir /diskless/192.168.1.21/dev
root #mkdir /diskless/192.168.1.21/proc
root #mkdir /diskless/192.168.1.21/tmp
root #mkdir /diskless/192.168.1.21/mnt
root #chmod a+w /diskless/192.168.1.21/tmp
root #mkdir /diskless/192.168.1.21/mnt/.initd
root #mkdir /diskless/192.168.1.21/root
root #mkdir /diskless/192.168.1.21/sys
root #mkdir /diskless/192.168.1.21/var
root #mkdir /diskless/192.168.1.21/var/empty
root #mkdir /diskless/192.168.1.21/var/lock
root #mkdir /diskless/192.168.1.21/var/log
root #mkdir /diskless/192.168.1.21/var/run
root #mkdir /diskless/192.168.1.21/var/spool
root #mkdir /diskless/192.168.1.21/usr
root #mkdir /diskless/192.168.1.21/opt

Most of these "stubs" should be recognizable; stubs like /dev, /proc, or /sys will be populated when the slave starts, the others will be mounted later. The /diskless/192.168.1.21/etc/conf.d/hostname file should also be changed to reflect the hostname of the slave. Binaries, libraries and other files will be populated later in this HOWTO right before attempting to boot the slave.

尽管/dev会在稍后被udev占据,仍然需要创建console条目。否则,将会遇到“unable to open initial console”(无法开启初始化控制台)错误信息。

root #mknod /diskless/192.168.1.21/dev/console c 5 1

配置DHCP服务器

关于DHCP服务器

DHCP代表着动态主机配置协议。DHCP服务器将是当slave从网络启动时第一个通信的计算机。DHCP服务器的主机作用是指派IP地址。DHCP服务器能基于主机以太网的MAC地址来指派IP地址。一旦slave拥有一个IP地址,DHCP服务器将告诉slave去哪里获得它的初始化文件系统及内核。

开始之前

在它们正确工作之前,有一些事情需要确认。首先检查网络连通性:

root #ifconfig eth0 multicast
root #ifconfig -a

确认有一个eth0设备运行。它看起来应该像这样:

CODE 一个正常工作的eth0设备
eth0      Link encap:Ethernet  HWaddr 00:E0:83:16:2F:D6
          inet addr:192.168.1.1  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:26460491 errors:0 dropped:0 overruns:2 frame:0
          TX packets:32903198 errors:0 dropped:0 overruns:0 carrier:1
          collisions:0 txqueuelen:100
          RX bytes:2483502568 (2368.4 Mb)  TX bytes:1411984950 (1346.5 Mb)
          Interrupt:18 Base address:0x1800

它说MULTICAST是非常重要的,如果不是即必须重新编译包括有多播支持的内核。

安装DHCP服务器

如果网络中还没有安装一台DHCP服务器,现在就需要安装一台:

root #emerge --ask dhcp

如果网络中已经安装有一台DHCP服务器,编辑配置文件来使PXE引导能正常工作。

配置DHCP服务器

在启动DHCP服务器之前,只需要编辑一个配置文件:/etc/dhcp/dhcpd.conf。复制并编辑提供的示例文件:

root #cp /etc/dhcp/dhcpd.conf.sample /etc/dhcp/dhcpd.conf
root #nano -w /etc/dhcp/dhcpd.conf

通常文件应该做成一个时尚的缩进式布局,看起来像这样:

CODE dhcpd.conf示例
# global options here
ddns-update-style none;
shared-network LOCAL-NET {
  # shared network options here
  subnet 192.168.1.0 netmask 255.255.255.0 {
    # subnet network options here
    host slave{
        # host specific options here
    }
    group {
        # group specific options here
    }
  }
}

shared-network块是可选的,并且应该用于需要将IP指派到同一网络拓扑中。至少一个subnet应该被声明并且可选的group块允许选项中其中被分组。一个好的dhcpd.conf示例看起来像这样:

CODE dhcpd.conf示例
#
# Sample dhcpd.conf for diskless clients
#
  
# Disable dynamic DNS
ddns-update-style none;
  
# Assume one default gateway for IP traffic will do
option routers 192.168.1.1;
  
# Provide DNS info to clients
option domain-name-servers 192.168.1.1;
option domain-name "mydomain.com";
  
# Specify the TFTP server to be used
next-server 192.168.1.1;
  
# Declare a vendor-specific option buffer for PXE clients:
# Code 1: Multicast IP address of boot file server
# Code 2: UDP port that client should monitor for MTFTP responses
# Code 3: UDP port that MTFTP servers are using to listen for MTFTP requests
# Code 4: Number of seconds a client must listen for activity before trying
#         to start a new MTFTP transfer
# Code 5: Number of seconds a client must listen before trying to restart
#         a MTFTP transfer
  
option space PXE;
option PXE.mtftp-ip               code 1 = ip-address;
option PXE.mtftp-cport            code 2 = unsigned integer 16;
option PXE.mtftp-sport            code 3 = unsigned integer 16;
option PXE.mtftp-tmout            code 4 = unsigned integer 8;
option PXE.mtftp-delay            code 5 = unsigned integer 8;
option PXE.discovery-control      code 6 = unsigned integer 8;
option PXE.discovery-mcast-addr   code 7 = ip-address;
  
# Declare the subnet where our diskless nodes will live
subnet 192.168.1.0 netmask 255.255.255.0 {
  
  # Provide PXE clients with appropriate information
  class "pxeclient" {
    match if substring(option vendor-class-identifier, 0, 9) = "PXEClient";
    vendor-option-space PXE;
  
    # At least one of the vendor-specific PXE options must be set in
    # order for the client boot ROMs to realize that we are a PXE-compliant
    # server.  We set the MCAST IP address to 0.0.0.0 to tell the boot ROM
    # that we can't provide multicast TFTP.
  
    option PXE.mtftp-ip 0.0.0.0;
  
    # This is the name of the file the boot ROMs should download.
    filename "pxelinux.0";
  }
  
  # Provide Etherboot clients with appropriate information
  class "etherboot" {
    match if substring(option vendor-class-identifier, 0, 9) = "Etherboot";
    filename "vmlinuz_arch";
  }
  
  # Add one host declaration for each diskless host
  host slave21 {
    hardware ethernet 00:02:A5:04:3B:66;
    fixed-address 192.168.1.21;
  }
}
Note
没有任何事物阻止PXE引导和Etherboot同时使用。上面的Code Listing只是一个例子;如果仍然有问题,请参考DHCPd文档。

跟在next-server后面的IP地址将会被查询指定的filename。这个IP地址应该是tftp服务器的IP,通常就是master的IP地址。filename是相对于/diskless目录的(这将会在稍后提到的tftp服务器选项中指定)。在host块内,hardware ethernet选项指定一个MAC地址,同时fixed-address指派一个固定IP地址到那个特有的MAC地址。这里有一个相当不错的dhcpd.conf的man页解释这篇HOWTO中所使用的选项。可以键入以下命令来阅读这个man页:

user $man dhcpd.conf

启动DHCP服务器

在启动dhcp初始化脚本之前,编辑/etc/conf.d/dhcp文件让它看起来像这样:

CODE /etc/conf.d/dhcp示例
IFACE="eth0"
# Insert any customizations needed

IFACE变量是DHCP服务器将要运行的设备,在这里是eth0。添加更多参数到IFACE变量对于一个拥有多网卡的复杂网络拓扑环境将相当有用。键入以下命令来启动dhcp服务器:

root #/etc/init.d/dhcpd start

键入以下命令添加dhcp服务器到开机自启动脚本:

root #rc-update add dhcpd default

排查DHCP服务器

通过查看/var/log/messages可以知道是否引导了一个节点。如果一个节点成功引导,messages文件将会有一些看起来像是下面的这些行:

CODE dhcp产生的日志文件条目示例
DHCPDISCOVER from 00:00:00:00:00:00 via eth0
DHCPOFFER on 192.168.1.21 to 00:00:00:00:00:00 via eth0
DHCPREQUEST for 192.168.1.21 from 00:00:00:00:00:00 via eth0
DHCPACK on 192.168.1.21 to 00:00:00:00:00:00 via eth0
Note
这个日志文件还可以用于帮助查找slave的MAC地址。

如果出现下面的信息,它大概是说配置文件有什么错误,但是DHCP服务器在正常的广播。

CODE dhpc服务器错误示例
no free leases on subnet LOCAL-NET

在每一次更改配置文件后,DHCP服务器必须重启。键入以下命令重启服务器:

root #/etc/init.d/dhcpd restart

配置TFTP服务器和PXE Linux引导器和/或Etherboot

关于TFTP服务器

TFTP stands for Trivial File Transfer Protocol. The TFTP server is going to supply the slaves with a kernel and an initial filesystem. All of the slave kernels and filesystems will be stored on the TFTP server, so it's probably a good idea to make the master the TFTP server.

安装TFTP服务器

A highly recommended tftp server is available as the tftp-hpa package. This tftp server happens to be written by the author of SYSLINUX and it works very well with pxelinux. To install simply type:

root #emerge --ask tftp-hpa

配置TFTP服务器

Edit /etc/conf.d/in.tftpd. The tftproot directory needs to specified with INTFTPD_PATH and any command-line options with INTFTPD_OPTS. It should look something like this:

FILE /etc/conf.d/in.tftpd
INTFTPD_PATH="/diskless"
INTFTPD_OPTS="-l -v -s ${INTFTPD_PATH}"

The -l option indicates that this server listens in stand alone mode so inetd does not have to be run. The -v indicates that log/error messages should be verbose. The -s /diskless specifies the root of the tftp server.

启动TFTP服务器

To start the tftp server type:

root #/etc/init.d/in.tftpd start

This should start the tftp server with the options that were specified in the /etc/conf.d/in.tftpd. If this server is to be automatically started at boot type:

root #rc-update add in.tftpd default

关于PXELINUX

This section is not required if only Etherboot is being used. PXELINUX is the network bootloader equivalent to LILO or GRUB and will be served via TFTP. It is essentially a tiny set of instructions that tells the client where to locate its kernel and initial filesystem and allows for various kernel options.

开始之前

Now the file pxelinux.0 is required, which comes in the SYSLINUX package by H. Peter Anvin. This package can be installed by typing:

root #emerge --ask syslinux

安装PXELINUX

Note
This isn't needed for Etherboot

Before starting the tftp server pxelinux needs to be set up. First copy the pxelinux binary into the /diskless directory:

root #cp /usr/share/syslinux/pxelinux.0 /diskless
root #mkdir /diskless/pxelinux.cfg
root #touch /diskless/pxelinux.cfg/default

This will create a default bootloader configuration file. The binary pxelinux.0 will look in the pxelinux.cfg directory for a file whose name is the client's IP address in hexadecimal. If it does not find that file it will remove the rightmost digit from the file name and try again until it runs out of digits. Versions 2.05 and later of syslinux first perform a search for a file named after the MAC address. If no file is found, it starts the previously mentioned discovery routine. If none is found, the default file is used.

CODE PXE在pxelinux.cfg/中查找文件的顺序
## (Leading 01 means Ethernet, next bytes match our slave's MAC address)
01-00-40-63-c2-ca-c9
  
## (Assigned IP in hexadecimal)
C0A80115
C0A8011
C0A801
C0A80
C0A8
C0A
C0
C
  
default
Note
These are all in lowercase.

Let's start with the default file:

CODE pxelinux.cfg/default示例
DEFAULT gentoo
LABEL gentoo
LINUX /bzImage
APPEND ip=dhcp root=/dev/nfs nfsroot=192.168.1.1:/diskless/192.168.1.21

The DEFAULT tag directs pxelinux to the kernel bzImage that was compiled earlier. The APPEND tag appends kernel initialisation options. Since the slave kernel was compiled with NFS_ROOT_SUPPORT , the nfsroot will be specified here. The first IP is the master's IP and the second IP is the directory that was created in /diskless to store the slave's initial filesystem. Other NFS options may also be supplied. For example, to use NFS v4.1 over TCP, append ,tcp,vers=4.1 to the nfsroot kernel option: nfsroot=192.168.1.1:/diskless/192.168.1.21,tcp,vers=4.1.

关于Etherboot

Note
This isn't required if PXE boot is being used.

Etherboot boots network boot images from a TFTP server. As the PXE this is equivalent to LILO or GRUB. The mknbi utility enables the creation of different images using different options.

开始之前

The mknbi (utility for making tagged kernel images useful for netbooting) package is needed to create the Etherboot images. This tool will create a preconfigured kernel image from the original kernel. This contains the boot options as shown further down.

root #emerge --ask mknbi

安装Etherboot

In this section a simple etherboot image will be created. As the dhcp server gives out the clients root-path in the "option root-path" dhcp.conf, this does not have to be included here. More details can be found in the mknbi manual.

user $man mknbi

Making the boot images. This will create a ELF bootable image capable of passing dhcp and the rootpath to the kernel. Also forcing the kernel to browse the network for a dhcp server.

root #mkelf-linux -ip=dhcp /diskless/bzImage > /diskless/vmlinuz
Note
For the arch specific images bzImage_arch and vmlinuz_arch have to be typed.

排查网络启动过程

There are a few things that can be done to debug the network boot process. Primarily a tool called tcpdump can be used. To install tcpdump type:

root #emerge --ask tcpdump

Now various network traffic can be listened to, to make sure the client/server interactions are functioning. If something isn't working there are a few things that could be checked. First make sure that the client/server is physically connected properly and that the networking cables are not damaged. If the client/server is not receiving requests on a particular port make sure that there is no firewall interference. To listen to interaction between two computers type:

root #tcpdump host client_ip and server_ip

The tcpdump command can also be configured to listen on particular port such as the tftp port by typing:

root #tcpdump port 69

A common error that might be received is: "PXE-E32: TFTP open time-out". This is probably due to firewall issues. If TCPwrappers is being used, it might be worth checking /etc/hosts.allow and /etc/hosts.deny and make sure that they are configured properly. The client should be allowed to connect to the server.

配置NFS服务器

关于NFS服务器

NFS stands for Network File System. The NFS server will be used to serve directories to the slave. This part can be somewhat personalized later, but right now all that is wanted is a preliminary slave node to boot diskless.

关于Portmapper

Various client/server services do not listen on a particular port, but instead rely on RPCs (Remote Procedure Calls). When the service is initialised it listens on a random port and then registers this port with the Portmapper utility. NFS relies on RPCs and thus requires Portmapper to be running before it is started.

开始之前

The NFS Server needs kernel level support so if the kernel does not have this, the master's kernel needs to be recompiled. To double check the master's kernel configuration type:

root #grep NFS /usr/src/linux/.config_master

The output should look something like this if the kernel has been properly configured:

KERNEL 在master的内核配置中,配置NFS特需的选项
CONFIG_PACKET=y
# CONFIG_PACKET_MMAP is not set
# CONFIG_NETFILTER is not set
CONFIG_NFS_FS=y
CONFIG_NFS_V3=y
# CONFIG_NFS_V4 is not set
# CONFIG_NFS_DIRECTIO is not set
CONFIG_NFSD=y
CONFIG_NFSD_V3=y
# CONFIG_NFSD_V4 is not set
# CONFIG_NFSD_TCP is not set

安装NFS服务器

The NFS package that can be acquired through portage by typing:

root #emerge --ask nfs-utils

This package will emerge a portmapping utility, nfs server, and nfs client utilities and will automatically handle initialisation dependencies.

配置NFS服务器

There are three major configuration files that will have to be edited:

CODE Nfs配置文件
/etc/exports
/diskless/192.168.1.21/etc/fstab
/etc/conf.d/nfs

The /etc/exports file specifies how, to who and what to export through NFS. The slave's fstab will be altered so that it can mount the NFS filesystems that the master is exporting.

A typical /etc/exports for the master should look something like this:

FILE /etc/exportsmaster exports file
# one line like this for each slave
/diskless/192.168.1.21   192.168.1.21(sync,rw,no_root_squash,no_all_squash)
# common to all slaves
/opt   192.168.1.0/24(sync,ro,no_root_squash,no_all_squash)
/usr   192.168.1.0/24(sync,ro,no_root_squash,no_all_squash)
/home  192.168.1.0/24(sync,rw,no_root_squash,no_all_squash)
# if you want to have a shared log
/var/log   192.168.1.21(sync,rw,no_root_squash,no_all_squash)

The first field indicates the directory to be exported and the next field indicates to who and how. This field can be divided in two parts: who should be allowed to mount that particular directory, and what the mounting client can do to the filesystem: ro for read only, rw for read/write; no_root_squash and no_all_squash are important for diskless clients that are writing to the disk, so that they don't get "squashed" when making I/O requests. The slave's fstab file, /diskless/192.168.1.21/etc/fstab , should look like this:

CODE slave的fstab示例
# these entries are essential
master:/diskless/192.168.1.21   /         nfs     sync,hard,intr,rw,nolock,rsize=8192,wsize=8192    0 0
master:/opt                     /opt      nfs     sync,hard,intr,ro,nolock,rsize=8192,wsize=8192    0 0
master:/usr                     /usr      nfs     sync,hard,intr,ro,nolock,rsize=8192,wsize=8192    0 0
master:/home                    /home     nfs     sync,hard,intr,rw,nolock,rsize=8192,wsize=8192    0 0
none                            /proc     proc    defaults                                     0 0
# useful but superfluous
master:/var/log                 /var/log  nfs     hard,intr,rw                                 0 0

In this example, master is just the hostname of the master but it could easily be the IP of the master. The first field indicates the directory to be mounted and the second field indicates where. The third field describes the filesystem and should be NFS for any NFS mounted directory. The fourth field indicates various options that will be used in the mounting process (see mount(1) for info on mount options). Some people have had difficulties with soft mount points so here they are made hard mounts, a look into various /etc/fstab options should be done to make the cluster more efficient.

The last file that should be edited is /etc/conf.d/nfs which describes a few options for nfs when it is initialised and looks like this:

CODE master的/etc/conf.d/nfs示例
# Config file for /etc/init.d/nfs
  
# Number of servers to be started up by default
RPCNFSDCOUNT=8
  
# Options to pass to rpc.mountd
RPCMOUNTDOPTS=""

The RPCNFSDCOUNT should be changed to the number of diskless nodes on the network.

启动NFS服务器

The nfs server should be started with its init script located in /etc/init.d by typing:

root #/etc/init.d/nfs start

If this script is to be started every time the system boots simply type:

root #rc-update add nfs default

完成slave的文件系统

复制缺失的文件

Now the slave's file system will be made in sync with the master's and provide the necessary binaries while still preserving slave specific files.

root #rsync -avz /bin /diskless/192.168.1.21
root #rsync -avz /sbin /diskless/192.168.1.21
root #rsync -avz /lib /diskless/192.168.1.21
Note
The reason for rsync -avz instead of cp is to maintain symlinks and permissions.

配置无盘网络

In order to prevent the networking initscript from killing the connection to the NFS server, an option needs to be added to /etc/conf.d/net on the diskless client's filesystem.

CODE 编辑/etc/conf.d/net
config_eth0=( "noop" )
Note
For more information, please read /usr/share/doc/openrc-*/net.example.bz2 .

初始化脚本

Init scripts for slaves are located under /diskless/192.168.1.21/etc/runlevels for services needed on the diskless nodes. Each slave can be set up and customized here, it all depends on what each slave is meant to do.

Warning
Do not use the rc-update program to add or remove scripts from the slave runlevels when logged on to the master. This would change the master runlevels. The links need to be manually created or by logging into the slave nodes using ssh or connecting a screen and keyboard to the slave.
CODE slave的典型runlevels
/diskless/192.168.1.21/etc/runlevels/:
total 16
drwxr-xr-x    2 root     root         4096 2003-11-09 15:27 boot
drwxr-xr-x    2 root     root         4096 2003-10-01 21:10 default
drwxr-xr-x    2 root     root         4096 2003-03-13 19:05 nonetwork
drwxr-xr-x    2 root     root         4096 2003-02-23 12:26 single
  
/diskless/192.168.1.21/etc/runlevels/boot:
total 0
lrwxrwxrwx    1 root     root           20 2003-10-18 17:28 bootmisc -> /etc/init.d/bootmisc
lrwxrwxrwx    1 root     root           19 2003-10-18 17:28 checkfs -> /etc/init.d/checkfs
lrwxrwxrwx    1 root     root           17 2003-10-18 17:28 clock -> /etc/init.d/clock
lrwxrwxrwx    1 root     root           22 2003-10-18 17:28 domainname -> /etc/init.d/domainname
lrwxrwxrwx    1 root     root           20 2003-10-18 17:28 hostname -> /etc/init.d/hostname
lrwxrwxrwx    1 root     root           22 2003-10-18 17:28 localmount -> /etc/init.d/localmount
lrwxrwxrwx    1 root     root           19 2003-10-18 17:28 modules -> /etc/init.d/modules
lrwxrwxrwx    1 root     root           18 2003-10-18 17:28 net.lo -> /etc/init.d/net.lo
lrwxrwxrwx    1 root     root           20 2003-10-18 17:28 netmount -> /etc/init.d/netmount
lrwxrwxrwx    1 root     root           21 2003-10-18 17:28 rmnologin -> /etc/init.d/rmnologin
lrwxrwxrwx    1 root     root           19 2003-10-18 17:28 urandom -> /etc/init.d/urandom
  
/diskless/192.168.1.21/etc/runlevels/default:
total 0
lrwxrwxrwx    1 root     root           23 2003-10-18 17:28 consolefont -> /etc/init.d/consolefont
lrwxrwxrwx    1 root     root           19 2003-10-18 17:28 distccd -> /etc/init.d/distccd
lrwxrwxrwx    1 root     root           19 2003-10-18 17:28 keymaps -> /etc/init.d/keymaps
lrwxrwxrwx    1 root     root           17 2003-10-18 17:28 local -> /etc/init.d/local
lrwxrwxrwx    1 root     root           16 2003-10-18 17:28 sshd -> /etc/init.d/sshd
lrwxrwxrwx    1 root     root           21 2003-10-18 17:28 syslog-ng -> /etc/init.d/syslog-ng
lrwxrwxrwx    1 root     root           17 2003-10-18 17:28 vixie-cron -> /etc/init.d/vixie-cron
  
/diskless/192.168.1.21/etc/runlevels/nonetwork:
total 0
lrwxrwxrwx    1 root     root           17 2003-10-18 17:28 local -> /etc/init.d/local
  
/diskless/192.168.1.21/etc/runlevels/single:
total 0

Now is a good time to boot the slave and cross some fingers. It works? Congratulations, you are now the proud owner of (a) diskless node(s).


This page is based on a document formerly found on our main website gentoo.org.
The following people contributed to the original document: Michael Andrews, Kristian Jerpetjoen, Xavier Neys
They are listed here because wiki history does not allow for any external attribution. If you edit the wiki article, please do not add yourself here; your contributions are recorded on each article's associated history page.