Booting a Linux system with NFS (Nfsroot)

Source: Internet
Author: User

Mounting the root filesystem via NFS (Nfsroot)

The original English text is located in the Inux kernel source code "Documentation/filesystems/nfs/nfsroot.txt".

1996 by Gero Kuhlmann <[email protected]> first written,

1997 by Martin Mares <[email Protected]>

2006 by Nico Schottelius <[email protected]> and horms <[email protected]> update.

In order to use a disk-free system (such as an X terminal or printer), it is necessary to store the root file system on a non-disk device. It can be a Initramfs file mounted via NFS (refer to documentation/filesystems/ Ramfs-rootfs-initramfs.txt), or a RAMDisk file (refer to Documentation/initrd.txt) or a file system. The following describes how to get the root file system for Linux from NFS to boot the system. The following client (' client ') represents a disk-free system, and the server-side (' Server ') represents an NFS server.

1.) start Nfsroot function

In order to use the Nfsroot feature, when compiling the configuration, the NFS client must be selected as a built-in (built-in, non-modular) file system. The NFS client is set to built-in, the Nfsroot option becomes optional, and the Nfsroot feature is supported after selection (translator Note: The Nfsroot option is not visible when the NFS client is not set to the built-in file system).

For network configuration options, select Kernel Auto-configuration and the corresponding auto-configuration type. It is most reliable to select all three types of DHCP,BOOTP and Rarp.

2.) kernel command line parameters

When the boot loader (bootloader) loads a Linux kernel, it needs to know what root file device is used (root FS devices). When using Nfsroot, you need to know where to get the server address and the directory name that can be mounted as the root file. You can set nfsroot with the following kernel command line parameters:

Root=/dev/nfs

The required parameters for starting the virtual NFS device (pseudo-nfs-device). Note that/dev/nfs is not a real device, it's just a sign that tells the kernel to replace the real device with the NFS feature.

nfsroot=[<server-ip>:]<root-dir>[,<nfs-options>]

If the ' nfsroot ' parameter is not specified on the kernel boot command line, the kernel will use the default "/tftpboot/%s" parameter.

<server-ip> Specifies the IP address of the NFS server. The default IP address is obtained from the ' IP ' parameter (see next parameter). This parameter allows IP autoconfiguration to use a different Server than NFS.

<root-dir> will mount as the server-side directory name for the root file system. If there is a "%s" tag in the configuration string, it will be substituted for the client IP address represented by ASCII.

<nfs-options> Specifications for NFS options. All options are delimited by commas (', '). The following configuration is used by default

Port

Given by the server-side port mapping process

(Centos7 previous version called Portmap, later called Rpcbind)

Rsize 4096
Wsize 4096
Timeo 7
Retrans 3
Acregmin 3
Acregmax 60
Acdirmin 30
Acdirmax 60
Flags Hard, Nointr, Noposix, CTO, AC
ip=<client-ip>:<server-ip>:<gw-ip>:<netmask>:<hostname>:<device>: <autoconf>:<dns0-ip>:<dns1-ip>

This line parameter tells the kernel how to configure the IP address of the device and how to configure the IP routing table. Initially called ' Nfsaddrs ', but now that the IP configuration is already independent of NFS at startup, it is renamed ' IP ' and for compatibility the old name ' Nfsaddrs ' will exist as an alias.

If the parameter is not set in the kernel command-line arguments, all items are treated as empty, and all default values are described in the following specific items. Typically, the kernel attempts to automatically configure all items.

Where the <autoconf> item can exist separately in the ' IP ' parameter (without any ': '). If the value is set to "Ip=off" or "Ip=none", it will not be replaced with automatic configuration, otherwise it will be replaced with automatic configuration. The most used setting is "IP=DHCP".

<client-ip> the IP address of the client. Default: Obtained through automatic configuration.

<server-ip> the IP address of the NFS server. If you use Rarp to obtain the client address, and the parameter is not empty, the server that you specify is accepted.

This parameter is required only for NFS root. If this parameter is not set or NFS root is not used, the automatic configuration will not be triggered.

Default: Obtained through automatic configuration. The server address used for automatic configuration will be used.

<gw-ip> if the server is in a different network segment, you need a gateway to the IP address. Default: Obtained through automatic configuration.

<netmask> Subnet mask for local network devices. If not specified, the device's subnet mask is fetched from the client IP address's derived address. Default: Obtained through automatic configuration.

The name of the network device used by <device>. Default: If there is only one device locally, it will be used directly. Otherwise, it will be determined by automatic configuration. It sends an automatic configuration request through all devices, and then uses the device that received the reply first.

<autoconf> Use automatic configuration. If the device has more than one automatic Configuration Protocol (DHCP/BOOTP/RARP), the automatic configuration request is sent using all protocols, and then the protocol that receives the reply is used first.

The protocol set in this option can only be used if it is compiled into the kernel.

Off or None: Automatic configuration (using the specified IP address) is not used

On or any: use any of the available protocols in the kernel

DHCP: Using DHCP

BOOTP: Using BOOTP

Rarp: Using Rarp

Both: Using BOOTP and RARP but not using DHCP (Legacy options reserved for backward compatibility)

If you use the DHCP protocol, clients can use "Ip=dhcp,client-id-type,client-id-value" in the following format. Default: Any

<dns0-ip> the first named server for the IP address. Gets the exported value from/PROC/NET/PNP (typically linked to/et/resolv.conf in an embedded system).

<dns1-ip> the second named server for the IP address. Ditto.

Nfsrootdebug

This option turns on the kernel output debugging information. At startup, the administrator can check the NFS mount options for the incoming NFS client through the output information, whether the server address and root path are correct.

file>

This parameter allows an administrator to specify the name of the file that contains the system initialization program. The default value is "/init". If the specified file is valid and the kernel can run, then the kernel command-line arguments (including ' nfsroot= ') associated with the root file system are ignored.

A description of handling the mounted root file system can be obtained in this file: Documentation/early-userspace/readme

3.) Boot program

There are many different ways to load kernel programs into memory. Mainly depends on the available facilities:

3.1) booting from floppy disk using Syslinux

When compiling the kernel, the simple way to use syslinux to create a bootable floppy disk is to use Zdisk or bzdisk to generate a target file that uses Zimage or bzimage images. Both catalog files can receive the Fdargs parameter, which can be used to specify kernel command-line parameters. For example:

 make Bzdisk fdargs="root=/dev/nfs"

Note that running the command in requires access to the disk device/dev/fd0.

For more details on syslinux and how to create a disk-based precompiled kernel, refer to http://syslinux.zytor.com/.

Note: You can use the DD command to write the kernel directly to a floppy disk, start the device through Rdev management, and then start the system using the resulting floppy disk. Linux no longer supports the kernel boot of this method.

3.2) start with isolinux from CDROM

When compiling the kernel, a simple way to use Isolinux to create a bootable CDROM is to use the Isoimage target file for bzimage mirroring. Similar to Zdisk and Bzdisk, a catalog file can receive the Fdargs parameter, which can be used to specify kernel command-line parameters. For example:

 make isoimage fdargs="root=/dev/nfs"

The resulting ISO image file is located in Arch/<arch>/boot/image.iso. ISO files can be written to CDROM using a tool like Cdrecord. For example:

Cdrecord Dev=atapi:1,0,0 Arch/x86/boot/image.iso

For more details on Isolinux, and how to create a disk-based precompiled kernel, refer to http://syslinux.zytor.com/.

3.3) using Lilo

When using LILO, all required command-line arguments can be set through the ' append= ' entry in the Lilo configuration file.

However, in order to use ' root= ' to specify kernel command-line startup parameters, you still need to create a temporary root device that can be deleted after Lilo runs.

Mknod 0 255

For more information about configuring Lilo, refer to its related files.

3.4) using Grub

When using grub, kernel parameters can simply be added to the back of the kernel settings:

Kernel <kernel> <parameters>

3.5) Use Loadlin

Loadin can be used to start Linux from a DOS command prompt without the need to mount the local disk as root. Although this method is not validated by the author, it should be configured in a manner similar to Lilo.

Please refer to the Loadin documentation for more details.

3.6) using the boot ROM

This may be the most elegant way to boot without disk. You can use the TFTP protocol to load the kernel based on the boot ROM. The document author does not know of any non-commercial boot ROM that supports loading Linux over the network. However, there are two free implementations of the boot ROM, Netboot-nfs and Etherboot, both located in sunsite.unc.edu and both contain all the information that is initiated by the Diskless Linux client.

3.7) use Pxelinux

Pxelinux can start Linux with the PXE boot program, which is included with many modern network cards.

When Pxelinux is used, the kernel image can be specified by "Kernel <relative-path-below/tftpboot>". The Nfsroot parameter is added to the kernel through the "append" entry. You typically use the serial console to connect to the Pxelinux, for more details, refer to Documentation/serial-console.txt.

For more details on Pxelinux and how to create a disk-based precompiled kernel, refer to http://syslinux.zytor.com/.

4.) acknowledgements

Support for Nfsroot code and RARP in the kernel has been written by Gero Kuhlmann <[email protected].han.de>.

The remaining IP layer autoconfiguration code has been written by Martin Mares <[email protected]>.

In order to write the original version of Nfsroot, the author also thanked Jens-uwe Mager <[email protected]> for help.

Booting a Linux system with NFS (Nfsroot)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.