요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
===============================================
Mounting the root filesystem via NFS (nfsroot)
===============================================
:Authors:
Written 1996 by Gero Kuhlmann <gero@gkminix.han.de>
Updated 1997 by Martin Mares <mj@atrey.karlin.mff.cuni.cz>
Updated 2006 by Nico Schottelius <nico-kernel-nfsroot@schottelius.org>
Updated 2006 by Horms <horms@verge.net.au>
Updated 2018 by Chris Novakovic <chris@chrisn.me.uk>
In order to use a diskless system, such as an X-terminal or printer server for
example, it is necessary for the root filesystem to be present on a non-disk
device. This may be an initramfs (see
Documentation/filesystems/ramfs-rootfs-initramfs.rst), a ramdisk (see
Documentation/admin-guide/initrd.rst) or a filesystem mounted via NFS. The
following text describes on how to use NFS for the root filesystem. For the rest
of this text 'client' means the diskless system, and 'server' means the NFS
server.
Enabling nfsroot capabilities
=============================
In order to use nfsroot, NFS client support needs to be selected as
built-in during configuration. Once this has been selected, the nfsroot
option will become available, which should also be selected.
In the networking options, kernel level autoconfiguration can be selected,
along with the types of autoconfiguration to support. Selecting all of
DHCP, BOOTP and RARP is safe.
Kernel command line
===================
When the kernel has been loaded by a boot loader (see below) it needs to be
told what root fs device to use. And in the case of nfsroot, where to find
both the server and the name of the directory on the server to mount as root.
This can be established using the following kernel command line parameters:
root=/dev/nfs
This is necessary to enable the pseudo-NFS-device. Note that it's not a
real device but just a synonym to tell the kernel to use NFS instead of
a real device.
nfsroot=[<server-ip>:]<root-dir>[,<nfs-options>]
If the `nfsroot' parameter is NOT given on the command line,
the default ``"/tftpboot/%s"`` will be used.
<server-ip> Specifies the IP address of the NFS server.
The default address is determined by the ip parameter
(see below). This parameter allows the use of different
servers for IP autoconfiguration and NFS.
<root-dir> Name of the directory on the server to mount as root.
If there is a "%s" token in the string, it will be
replaced by the ASCII-representation of the client's
IP address.
<nfs-options> Standard NFS options. All options are separated by commas.
The following defaults are used::
port = as given by server portmap daemon
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>:<ntp0-ip>
This parameter tells the kernel how to configure IP addresses of devices
and also how to set up the IP routing table. It was originally called
nfsaddrs, but now the boot-time IP configuration works independently of
NFS, so it was renamed to ip and the old name remained as an alias for
compatibility reasons.
If this parameter is missing from the kernel command line, all fields are
assumed to be empty, and the defaults mentioned below apply. In general
this means that the kernel tries to configure everything using
autoconfiguration.
The <autoconf> parameter can appear alone as the value to the ip
parameter (without all the ':' characters before). If the value is
"ip=off" or "ip=none", no autoconfiguration will take place, otherwise
autoconfiguration will take place. The most common way to use this
is "ip=dhcp".
<client-ip> IP address of the client.
Default: Determined using autoconfiguration.
<server-ip> IP address of the NFS server.
If RARP is used to determine
the client address and this parameter is NOT empty only
replies from the specified server are accepted.
Only required for NFS root. That is autoconfiguration
will not be triggered if it is missing and NFS root is not
in operation.
Value is exported to /proc/net/pnp with the prefix "bootserver "
(see below).
Default: Determined using autoconfiguration.
The address of the autoconfiguration server is used.
<gw-ip> IP address of a gateway if the server is on a different subnet.
Default: Determined using autoconfiguration.
<netmask> Netmask for local network interface.
If unspecified the netmask is derived from the client IP address
assuming classful addressing.
Default: Determined using autoconfiguration.
<hostname> Name of the client.
If a '.' character is present, anything
before the first '.' is used as the client's hostname, and anything
after it is used as its NIS domain name. May be supplied by
autoconfiguration, but its absence will not trigger autoconfiguration.
If specified and DHCP is used, the user-provided hostname (and NIS
domain name, if present) will be carried in the DHCP request; this
may cause a DNS record to be created or updated for the client.
Default: Client IP address is used in ASCII notation.
<device> Name of network device to use.
Default: If the host only has one device, it is used.
Otherwise the device is determined using
autoconfiguration. This is done by sending
autoconfiguration requests out of all devices,
and using the device that received the first reply.
<autoconf> Method to use for autoconfiguration.
In the case of options
which specify multiple autoconfiguration protocols,
requests are sent using all protocols, and the first one
to reply is used.
Only autoconfiguration protocols that have been compiled
into the kernel will be used, regardless of the value of
this option::
off or none: don't use autoconfiguration
(do static IP assignment instead)
on or any: use any protocol available in the kernel
(default)
dhcp: use DHCP
bootp: use BOOTP
rarp: use RARP
both: use both BOOTP and RARP but not DHCP
(old option kept for backwards compatibility)
if dhcp is used, the client identifier can be used by following
format "ip=dhcp,client-id-type,client-id-value"
Default: any
<dns0-ip> IP address of primary nameserver.
Value is exported to /proc/net/pnp with the prefix "nameserver "
(see below).
Default: None if not using autoconfiguration; determined
automatically if using autoconfiguration.
<dns1-ip> IP address of secondary nameserver.
See <dns0-ip>.
<ntp0-ip> IP address of a Network Time Protocol (NTP) server.
Value is exported to /proc/net/ipconfig/ntp_servers, but is
otherwise unused (see below).
Default: None if not using autoconfiguration; determined
automatically if using autoconfiguration.
After configuration (whether manual or automatic) is complete, two files
are created in the following format; lines are omitted if their respective
value is empty following configuration:
- /proc/net/pnp:
#PROTO: <DHCP|BOOTP|RARP|MANUAL> (depending on configuration method)
domain <dns-domain> (if autoconfigured, the DNS domain)
nameserver <dns0-ip> (primary name server IP)
nameserver <dns1-ip> (secondary name server IP)
nameserver <dns2-ip> (tertiary name server IP)
bootserver <server-ip> (NFS server IP)
- /proc/net/ipconfig/ntp_servers:
<ntp0-ip> (NTP server IP)
<ntp1-ip> (NTP server IP)
<ntp2-ip> (NTP server IP)
<dns-domain> and <dns2-ip> (in /proc/net/pnp) and <ntp1-ip> and <ntp2-ip>
(in /proc/net/ipconfig/ntp_servers) are requested during autoconfiguration;
they cannot be specified as part of the "ip=" kernel command line parameter.
Because the "domain" and "nameserver" options are recognised by DNS
resolvers, /etc/resolv.conf is often linked to /proc/net/pnp on systems
that use an NFS root filesystem.
Note that the kernel will not synchronise the system time with any NTP
servers it discovers; this is the responsibility of a user space process
(e.g. an initrd/initramfs script that passes the IP addresses listed in
/proc/net/ipconfig/ntp_servers to an NTP client before mounting the real
root filesystem if it is on NFS).
nfsrootdebug
This parameter enables debugging messages to appear in the kernel
log at boot time so that administrators can verify that the correct
NFS mount options, server address, and root path are passed to the
NFS client.
rdinit=<executable file>
To specify which file contains the program that starts system
initialization, administrators can use this command line parameter.
The default value of this parameter is "/init". If the specified
file exists and the kernel can execute it, root filesystem related
kernel command line parameters, including 'nfsroot=', are ignored.
A description of the process of mounting the root file system can be
found in Documentation/driver-api/early-userspace/early_userspace_support.rst
Boot Loader
===========
To get the kernel into memory different approaches can be used.
They depend on various facilities being available:
- Booting from a floppy using syslinux
When building kernels, an easy way to create a boot floppy that uses
syslinux is to use the zdisk or bzdisk make targets which use zimage
and bzimage images respectively. Both targets accept the
FDARGS parameter which can be used to set the kernel command line.
e.g::
make bzdisk FDARGS="root=/dev/nfs"
Note that the user running this command will need to have
access to the floppy drive device, /dev/fd0
For more information on syslinux, including how to create bootdisks
for prebuilt kernels, see https://syslinux.zytor.com/
.. note::
Previously it was possible to write a kernel directly to
a floppy using dd, configure the boot device using rdev, and
boot using the resulting floppy. Linux no longer supports this
method of booting.
- Booting from a cdrom using isolinux
When building kernels, an easy way to create a bootable cdrom that
uses isolinux is to use the isoimage target which uses a bzimage
image. Like zdisk and bzdisk, this target accepts the FDARGS
parameter which can be used to set the kernel command line.
e.g::
make isoimage FDARGS="root=/dev/nfs"
The resulting iso image will be arch/<ARCH>/boot/image.iso
This can be written to a cdrom using a variety of tools including
cdrecord.
e.g::
cdrecord dev=ATAPI:1,0,0 arch/x86/boot/image.iso
For more information on isolinux, including how to create bootdisks
for prebuilt kernels, see https://syslinux.zytor.com/
- Using LILO
When using LILO all the necessary command line parameters may be
specified using the 'append=' directive in the LILO configuration
file.
However, to use the 'root=' directive you also need to create
a dummy root device, which may be removed after LILO is run.
e.g::
mknod /dev/boot255 c 0 255
For information on configuring LILO, please refer to its documentation.
- Using GRUB
When using GRUB, kernel parameter are simply appended after the kernel
specification: kernel <kernel> <parameters>
- Using loadlin
loadlin may be used to boot Linux from a DOS command prompt without
requiring a local hard disk to mount as root. This has not been
thoroughly tested by the authors of this document, but in general
it should be possible configure the kernel command line similarly
to the configuration of LILO.
Please refer to the loadlin documentation for further information.
- Using a boot ROM
This is probably the most elegant way of booting a diskless client.
With a boot ROM the kernel is loaded using the TFTP protocol. The
authors of this document are not aware of any no commercial boot
ROMs that support booting Linux over the network. However, there
are two free implementations of a boot ROM, netboot-nfs and
etherboot, both of which are available on sunsite.unc.edu, and both
of which contain everything you need to boot a diskless Linux client.
- Using pxelinux
Pxelinux may be used to boot linux using the PXE boot loader
which is present on many modern network cards.
When using pxelinux, the kernel image is specified using
"kernel <relative-path-below /tftpboot>". The nfsroot parameters
are passed to the kernel by adding them to the "append" line.
It is common to use serial console in conjunction with pxelinux,
see Documentation/admin-guide/serial-console.rst for more information.
For more information on isolinux, including how to create bootdisks
for prebuilt kernels, see https://syslinux.zytor.com/
Credits
=======
The nfsroot code in the kernel and the RARP support have been written
by Gero Kuhlmann <gero@gkminix.han.de>.
The rest of the IP layer autoconfiguration code has been written
by Martin Mares <mj@atrey.karlin.mff.cuni.cz>.
In order to write the initial version of nfsroot I would like to thank
Jens-Uwe Mager <jum@anubis.han.de> for his help.
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
문서 정보와 저자
1-16제목은 `Mounting the root filesystem via NFS (nfsroot)`입니다. Gero Kuhlmann `<gero@gkminix.han.de>`가 1996년에 작성했고 Martin Mares `<mj@atrey.karlin.mff.cuni.cz>`가 1997년, Nico Schottelius `<nico-kernel-nfsroot@schottelius.org>`와 Horms `<horms@verge.net.au>`가 2006년, Chris Novakovic `<chris@chrisn.me.uk>`가 2018년에 갱신했습니다.
Diskless system의 root filesystem
17-25X terminal이나 printer server 같은 diskless system은 root filesystem을 disk가 아닌 device에 두어야 합니다. 선택지는 initramfs(`Documentation/filesystems/ramfs-rootfs-initramfs.rst`), ramdisk(`Documentation/admin-guide/initrd.rst`), 또는 NFS로 mount한 filesystem입니다.
이 문서는 NFS를 root filesystem으로 쓰는 방법을 설명합니다. 이하에서 `client`는 diskless system, `server`는 NFS server를 뜻합니다.
nfsroot 기능 활성화
26-40Kernel configuration에서 NFS client support를 built-in으로 선택해야 합니다. 그러면 `nfsroot` option이 나타나며 이것도 선택합니다.
Networking option에서는 kernel level autoconfiguration과 지원할 protocol을 선택할 수 있습니다. DHCP, BOOTP, RARP를 모두 선택해도 안전합니다.
root와 nfsroot kernel parameter
41-87Boot loader가 kernel을 memory에 올린 뒤에는 사용할 root filesystem device, NFS server 위치, root로 mount할 server directory를 kernel command line으로 알려야 합니다.
| Parameter | 의미 |
|---|---|
| `root=/dev/nfs` | 실제 device가 아닌 pseudo-NFS-device를 선택해 kernel이 NFS root를 사용하도록 함 |
| `nfsroot=[<server-ip>:]<root-dir>[,<nfs-options>]` | Server, root directory, 표준 NFS option 지정. 생략 시 기본 root directory는 `"/tftpboot/%s"` |
`root=/dev/nfs`는 실제 device가 아니라 kernel에 real device 대신 NFS를 쓰라고 알리는 synonym입니다.
`nfsroot`를 생략하면 기본값 `"/tftpboot/%s"`를 사용합니다. `<server-ip>` 기본값은 아래 `ip` parameter가 정하며, IP autoconfiguration server와 NFS server를 다르게 지정할 수도 있습니다.
`<root-dir>`의 `%s` token은 client IP address의 ASCII representation으로 치환됩니다. `<nfs-options>`는 comma로 구분한 표준 NFS option이며 기본값은 다음과 같습니다.
port = as given by server portmap daemon
rsize = 4096
wsize = 4096
timeo = 7
retrans = 3
acregmin = 3
acregmax = 60
acdirmin = 30
acdirmax = 60
flags = hard, nointr, noposix, cto, ac
ip parameter와 autoconfiguration
88-105`ip=<client-ip>:<server-ip>:<gw-ip>:<netmask>:<hostname>:<device>:<autoconf>:<dns0-ip>:<dns1-ip>:<ntp0-ip>`는 device IP와 routing table을 구성합니다.
이 parameter의 원래 이름은 `nfsaddrs`였지만 boot-time IP configuration이 NFS와 독립적으로 동작하게 되면서 `ip`로 바뀌었고, 옛 이름은 호환성을 위한 alias로 남았습니다.
Kernel command line에 `ip`가 없으면 모든 field가 빈 것으로 간주되어 아래 기본값을 적용하며, 일반적으로 kernel이 autoconfiguration으로 모든 항목을 구성합니다.
`<autoconf>`만 `ip`의 값으로 단독 지정할 수도 있습니다. `ip=off` 또는 `ip=none`이면 자동 구성을 하지 않고, 그 밖의 값이면 수행합니다. 가장 흔한 형식은 `ip=dhcp`입니다.
주소·hostname·device field
106-150| Field | 설명 |
|---|---|
| `<client-ip>` | Client IP. 기본값은 autoconfiguration 결과 |
| `<server-ip>` | NFS server IP. RARP 사용 시 값이 있으면 해당 server의 reply만 수락하며 `/proc/net/pnp`에 `bootserver ` prefix로 export |
| `<gw-ip>` | 다른 subnet의 server로 가는 gateway. 기본값은 자동 결정 |
| `<netmask>` | Local interface netmask. 생략 시 classful addressing을 가정해 client IP에서 유도 |
| `<hostname>` | `.` 앞은 hostname, 뒤는 NIS domain. DHCP request에 포함될 수 있으며 기본값은 client IP의 ASCII 표기 |
| `<device>` | 사용할 network device. 하나뿐이면 그것을 쓰고, 여러 개면 첫 autoconfiguration reply를 받은 device를 선택 |
`<server-ip>`는 NFS root에만 필수입니다. NFS root를 사용하지 않을 때 이 값이 없다는 이유만으로 autoconfiguration을 시작하지는 않습니다. 기본값은 autoconfiguration server의 address입니다.
`<hostname>`에 `.`이 있으면 첫 `.` 앞은 client hostname, 뒤는 NIS domain name입니다. DHCP를 쓰면서 사용자가 값을 지정하면 hostname과 NIS domain이 DHCP request에 실리며 client의 DNS record가 생성되거나 갱신될 수 있습니다.
Autoconfiguration·DNS·NTP field
151-191`<autoconf>`가 여러 protocol을 지정하면 모두 request를 보내고 첫 reply를 사용합니다. Option 값과 무관하게 kernel에 compile된 protocol만 사용할 수 있습니다.
off or none: don't use autoconfiguration
(do static IP assignment instead)
on or any: use any protocol available in the kernel
(default)
dhcp: use DHCP
bootp: use BOOTP
rarp: use RARP
both: use both BOOTP and RARP but not DHCP
(old option kept for backwards compatibility)
DHCP를 쓸 때 client identifier는 `ip=dhcp,client-id-type,client-id-value` 형식으로 지정할 수 있습니다. 기본 autoconfiguration 방법은 `any`입니다.
| Field | 설명 |
|---|---|
| `<autoconf>` | `off`, `none`, `on`, `any`, `dhcp`, `bootp`, `rarp`, `both` 중 방법 선택 |
| `<dns0-ip>` | Primary nameserver. `/proc/net/pnp`에 `nameserver ` prefix로 export |
| `<dns1-ip>` | Secondary nameserver. 동작은 `<dns0-ip>`와 동일 |
| `<ntp0-ip>` | NTP server. `/proc/net/ipconfig/ntp_servers`에 export되지만 kernel 자체는 사용하지 않음 |
`<dns0-ip>`와 `<ntp0-ip>`의 기본값은 autoconfiguration을 쓰지 않을 때 `None`, 사용할 때 자동 결정입니다. `<dns1-ip>`는 `<dns0-ip>`와 같은 규칙을 따릅니다.
구성 결과 file과 resolver·NTP 동작
192-224수동 또는 자동 구성이 끝나면 다음 두 file이 만들어집니다. 구성 뒤 값이 비어 있는 항목의 line은 생략됩니다.
`/proc/net/pnp` 형식은 다음과 같습니다.
#PROTO: <DHCP|BOOTP|RARP|MANUAL> (depending on configuration method)
domain <dns-domain> (if autoconfigured, the DNS domain)
nameserver <dns0-ip> (primary name server IP)
nameserver <dns1-ip> (secondary name server IP)
nameserver <dns2-ip> (tertiary name server IP)
bootserver <server-ip> (NFS server IP)
`/proc/net/ipconfig/ntp_servers` 형식은 다음과 같습니다.
<ntp0-ip> (NTP server IP)
<ntp1-ip> (NTP server IP)
<ntp2-ip> (NTP server IP)
`<dns-domain>`, `<dns2-ip>`, `<ntp1-ip>`, `<ntp2-ip>`는 autoconfiguration 중 요청되며 `ip=` kernel command line parameter로 직접 지정할 수 없습니다.
`domain`과 `nameserver` option은 DNS resolver가 인식하므로 NFS root system에서는 `/etc/resolv.conf`를 `/proc/net/pnp`에 link하는 경우가 많습니다.
Kernel은 발견한 NTP server와 system time을 동기화하지 않습니다. 실제 root가 NFS에 있다면 mount 전에 `/proc/net/ipconfig/ntp_servers`의 IP를 NTP client에 넘기는 initrd/initramfs script 같은 userspace process가 이 일을 맡아야 합니다.
Debug와 초기화 program
225-243| Parameter | 의미 |
|---|---|
| `nfsrootdebug` | Boot 중 NFS option, server address, root path를 확인할 debug message 활성화 |
| `rdinit=<executable file>` | System initialization program 지정. 기본값은 `/init` |
`nfsrootdebug`는 boot 때 kernel log에 debug message를 출력해 올바른 NFS mount option, server address, root path가 NFS client로 전달됐는지 확인하게 합니다.
`rdinit=<executable file>`은 system initialization을 시작할 program file을 지정하며 기본값은 `/init`입니다. 지정 file이 존재하고 kernel이 실행할 수 있으면 `nfsroot=`를 포함한 root filesystem 관련 kernel command line parameter는 무시됩니다.
Root filesystem mount 과정은 `Documentation/driver-api/early-userspace/early_userspace_support.rst`를 참고하십시오.
syslinux floppy와 isolinux CD
244-296Kernel을 memory에 올리는 방법은 사용 가능한 facility에 따라 달라집니다. syslinux boot floppy를 만들 때 `zimage`를 쓰는 `zdisk` 또는 `bzimage`를 쓰는 `bzdisk` make target을 사용할 수 있고, 두 target 모두 `FDARGS`로 kernel command line을 지정합니다.
make bzdisk FDARGS="root=/dev/nfs"
이 command를 실행하는 user는 floppy device `/dev/fd0`에 접근할 수 있어야 합니다.
과거에는 `dd`로 kernel을 floppy에 직접 쓰고 `rdev`로 boot device를 설정해 boot할 수 있었지만 Linux는 더 이상 이 방법을 지원하지 않습니다.
isolinux boot CD는 `bzimage`를 쓰는 `isoimage` target으로 만들 수 있으며, 역시 `FDARGS`로 kernel command line을 설정합니다.
make isoimage FDARGS="root=/dev/nfs"
결과 ISO image는 `arch/<ARCH>/boot/image.iso`에 생기며 `cdrecord`를 포함한 여러 도구로 CD에 기록할 수 있습니다.
cdrecord dev=ATAPI:1,0,0 arch/x86/boot/image.iso
LILO·GRUB·loadlin
297-326LILO에서는 configuration file의 `append=` directive로 필요한 command line parameter를 지정합니다. `root=` directive를 쓰려면 LILO 실행 전에 dummy root device를 만들고 실행 뒤 제거할 수 있습니다.
mknod /dev/boot255 c 0 255
LILO 구성의 자세한 내용은 LILO documentation을 참고하십시오. GRUB에서는 kernel specification 뒤에 `kernel <kernel> <parameters>` 형식으로 parameter를 붙입니다.
loadlin은 local hard disk를 root로 mount하지 않고 DOS command prompt에서 Linux를 boot할 수 있습니다. 문서 저자들이 충분히 시험하지는 않았지만 일반적으로 LILO와 비슷하게 kernel command line을 구성할 수 있으며 자세한 내용은 loadlin documentation을 참고합니다.
Boot ROM과 pxelinux
327-350Boot ROM은 diskless client를 boot하는 가장 세련된 방법으로, TFTP protocol을 사용해 kernel을 load합니다. 원문은 Linux network boot를 지원하는 commercial boot ROM을 알지 못한다고 밝히며, 무료 구현 `netboot-nfs`와 `etherboot`가 `sunsite.unc.edu`에 있고 diskless Linux client boot에 필요한 것을 포함한다고 설명합니다.
Pxelinux는 현대 network card에 흔히 있는 PXE boot loader로 Linux를 boot할 수 있습니다. Kernel image는 `"kernel <relative-path-below /tftpboot>"`로 지정하고 `nfsroot` parameter는 `"append"` line에 추가합니다.
Pxelinux와 serial console을 함께 쓰는 경우가 많으며 자세한 내용은 `Documentation/admin-guide/serial-console.rst`를 참고하십시오.
기여자
351-364Kernel의 nfsroot code와 RARP support는 Gero Kuhlmann `<gero@gkminix.han.de>`가 작성했고, 나머지 IP layer autoconfiguration code는 Martin Mares `<mj@atrey.karlin.mff.cuni.cz>`가 작성했습니다.
Gero Kuhlmann은 nfsroot 초기 version 작성에 도움을 준 Jens-Uwe Mager `<jum@anubis.han.de>`에게 감사를 전합니다.
운영 핵심
nfsroot.rst:1-364NFS client와 nfsroot를 kernel built-in으로 준비한 뒤 `root=`, `nfsroot=`, `ip=`를 조합해 root 위치와 초기 network를 지정합니다.