AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-212827

user212827's questions

Martin Hope
user212827
Asked: 2024-05-13 05:06:02 +0800 CST

systemd networkd 可以配置为网络启动、PXE 启动吗?如果可以,如何配置?

  • 5

如果我理解这个“问题” (systemd-networkd DHCP 服务器忽略 SendOptions #15780),则可以配置 SystemD 来处理网络启动。但是,我无法找到有关该功能的更多信息。

我目前使用的是配置最少的 DHCPD 服务器,如果可以将其移动到 DHCPD 服务器就好了systemd-networkd,它可以处理我的环境中的所有其他网络功能。

# /etc/dhcpd.conf
allow booting; # How is this defined in systemd-networkd?
allow bootp;   # How is this defined in systemd-networkd?

# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
authoritative; # How is this defined in systemd-networkd?

option architecture code 93 = unsigned integer 16; # I think this corresponds to SendOption=93:uint16:architecture

host client_computer {
  hardware ethernet a1:b2:c3:d4:e5:f6; # This should be captured with [Match] MACAddress=a1:b2:c3:d4:e5:f6

  fixed-address 192.168.1.101; # I think this corresponds to something like SendOption=???:ipv4address:192.168.1.101
  next-server 192.168.1.100; # This should be defines as [Network] Address?

  option host-name "clientname"; # I think this corresponds to something like SendOption=12:string:clientname
  option root-path "/srv/tftp";  # I think this corresponds to something like SendOption=17:string:/srv/tftp

  if option architecture = 00:07 {
    filename "grub/x86_64-efi/core.efi"; # I think this corresponds to SendOption=67:string:grub/x86_64-efi/core.efi
  }
  else {
    filename "grub/i396-pc/core.0"; # I think this corresponds to SendOption=67:string:grub/i396-pc/core.0
  }
}

看来我需要“选项”代码,但是在哪里可以找到它们?有规格吗? - 找到他们 :)

  • 动态主机配置协议 (DHCP) 和引导协议 (BOOTP) 参数

SystemD NetworkD文档。

到目前为止我所拥有的:

#allow booting; = ? # Not necessary?
#allow bootp;   = ? # Not necessary?
#authoritative; = ? # Not necessary?

[Match]
MACAddress=a1:b2:c3:d4:e5:f6

[Network]
DHCP=no
DHCPServer=true

Address=192.168.1.100/24 # DHCP server IP

[DHCPv4]
ClientIdentifier=mac

[DHCPServer]
PoolOffset=3
PoolSize=7

BootServerAddress=192.168.1.100/24

#SendOption=93:uint16:architecture # Failed to parse DHCP uint16 data, ignoring assignment: architecture # Not necessary?

#SendOption=???:ipv4address:192.168.1.101

SendOption=12:string:clientname # 12 "Hostname"

SendOption=17:string:/srv/tftp  # 17 "Root Path"

# BootFilename=grub/i396-pc/core.0 # Sane as code 67
# SendOption=67:string:grub/x86_64-efi/core.efi
SendOption=67:string:grub/i396-pc/core.0

[DHCPServerStaticLease]
MACAddress=a1:b2:c3:d4:e5:f6
Address=192.168.1.101


更新#1

使用tcpdump -i <INTERFACE> -nn -s0 -v -A udp port 67我可以看到 SystemD NetworkD DCHP 服务器正在与客户端交互!

但是,系统无法启动,问题似乎是未将预期的静态 IP 地址分配给客户端。

该[DHCPServerStaticLease]部分似乎没有效果。我在 <= 253 中发现了一些有关错误的信息systemctl --version,并添加了解决方法ClientIdentifier=mac。不过,这应该不是必需的,因为我运行的是 255 版本。

  • DHCP 服务器未将静态 IP 地址分配给 systemd-networkd 网桥的某个接口上的主机

哦,我添加了Pool*参数,但 DHCP 服务器仍然分配相同的 IP (192.168.1.242)。

linux
  • 1 个回答
  • 26 Views
Martin Hope
user212827
Asked: 2017-12-09 08:21:43 +0800 CST

archlinux netboot 无盘节点/系统,NFS (v4) 上的 systemd 失败,rpc.idmapd

  • 5

更新:5 (20171209)

更新:5 (20171210)

  • mount -t nfs4 [SERVER IP]:/archlinux /mnt作品。
  • ss -ntp | grep 2049客户端在 systemd 开始之前建立与服务器的连接。
  • NSF4 id mapper 只能与 Kerberos 一起使用?

问题

我正在尝试设置无盘节点/工作站/系统。操作系统(4.13.12-1-ARCH)安装在 SERVER 上/srv/archlinux。从GRUB 成功网络引导到 NFSv4后,systemd 开始但在多个阶段失败,例如:

  • 无法挂载内核配置文件系统。
  • 无法挂载内核调试文件系统。
  • 挂载大页面文件系统失败
  • 无法启动加载/保存随机种子。
  • 无法挂载 /tmp。
  • 无法启动重建日志目录。
  • 然后以Not tainted 4.13.12-1-ARCH #1...

或者,

  • 无法挂载 POSIX 消息队列文件系统。
  • 无法启动重新挂载根和内核文件系统。
  • 无法挂载 Huge Pages 文件系统。
  • 无法挂载内核调试文件系统。
  • 无法挂载内核配置文件系统。
  • 然后以Not tainted 4.13.12-1-ARCH #1...

我怀疑这些故障是由 NFSv4 或本地网络的错误配置引起的。

rpc.idmapd

/etc/idmapd.conf
  [General]
  Verbosity = 7
  Pipefs-Directory = /var/lib/nfs/rpc_pipefs
  Domain = localdomain
  [Mapping]
  Nobody-User = nobody
  Nobody-Group = nobody
  [Translation]
  Method = nnswitch

/etc/exports
(printed using # exportfs -v)
  /srv            <world>(rw,sync,wdelay,hide,no_subtree_check,fsid=0,sec=sys,no_root_squash,no_all_squash)
  /srv/archlinux  <world>(rw,sync,wdelay,hide,no_subtree_check,sec=sys,no_root_squash,no_all_squash)

(Exposed to "world" for debugging purposes)

rpc.idmapd -fvvv在启动期间单独运行tty会记录以下内容:

rpc.idmapd: libnfsidmap: using domain: localdomain
rpc.idmapd: libnfsidmap: Realms list: 'LOCALDOMAIN'
rpc.idmapd: libnfsidmap: processing 'Method' list
rpc.idmapd: libnfsidmap: loaded plugin /usr/lib/libnfsidmap/nsswitch.so for method nsswitch
rpc.idmapd: Expiration time is 600 seconds.
rpc.idmapd: Opened /proc/net/rpc/nfs4.nametoid/channel
rpc.idmapd: Opened /proc/net/rpc/nfs4.idtoname/channel
rpc.idmapd: nfsdcb: authbuf=* authtype=user
rpc.idmapd: nfs4_uid_to_name: calling nsswitch->uid_to_name
rpc.idmapd: nfs4_uid_to_name: nsswitch->uid_to_name returned 0
rpc.idmapd: nfs4_uid_to_name: final return value is 0
rpc.idmapd: Server : (user) id "0" -> name "root@localdomain"

如果exportfs sec=sys,则继续如下:

rpc.idmapd: nfsdch: authbuf=* authtype=user
rpc.idmapd: nfs4_name_to_uid: calling nsswitch->name_to_uid
rpc.idmapd: nss_getpwnam: name '0' domain 'localdomain': resulting localname '(null)'
rpc.idmapd: nss_getpwnam: name '0' does not map into domain 'localdomain'
rpc.idmapd: nfs4_name_to_uid: nsswitch->name_to_uid returned -22
rpc.idmapd: nfs4_name_to_uid: final return value is -22
rpc.idmapd: Server : (user) name "0" -> id "99"
(stops here)

+(20171209) 确保/etc/hostnameCLIENT 的 设置为client2(duh) 后,如果exportfs sec=none 或 sec=sys,则继续如下:

rpc.idmapd: nfsdch: authbuf=* authtype=group
rpc.idmapd: nfs4_gid_to_name: calling nsswitch->gid_to_name
rpc.idmapd: nfs4_gid_to_name: nsswitch->gid_to_name returned 0
rpc.idmapd: nfs4_gid_to_name: final return value is 0
rpc.idmapd: Server : (group) id "190" -> name "systemd-journal@localdomain"
rpc.idmapd: nfsdch: authbuf=* authtype=user
rpc.idmapd: nfs4_name_to_uid: calling nsswitch->name_to_uid
rpc.idmapd: nss_getpwnam: name '0' domain 'localdomain': resulting localname '(null)'
rpc.idmapd: nss_getpwnam: name '0' does not map into domain 'localdomain'
rpc.idmapd: nfs4_name_to_uid: nsswitch->name_to_uid returned -22
rpc.idmapd: nfs4_name_to_uid: final return value is -22
rpc.idmapd: Server : (user) name "0" -> id "99"
(stops here)

如果我改为将方法从更改nsswitch为static(NFS 中的 UID 映射)

/etc/idmapd.conf
  ...
  [Translation]
  Method = static
  [Static]
  root@localdomain = root

在启动期间rpc.idmapd -fvvv单独tty记录以下内容:

rpc.idmapd: libnfsidmap: using domain: localdomain
rpc.idmapd: libnfsidmap: Realms list: 'LOCALDOMAIN'
rpc.idmapd: libnfsidmap: processing 'Method' list
rpc.idmapd: static_getpwnam: name 'root@localdomain' mapped to 'root'
rpc.idmapd: static_getpwnam: group 'root@localdomain' mapped to ' root'
rpc.idmapd: libnfsidmap: loaded plugin /usr/lib/libnfsidmap/static.so for method static
rpc.idmapd: Expiration time is 600 seconds.
rpc.idmapd: Opened /proc/net/rpc/nfs4.nametoid/channel
rpc.idmapd: Opened /proc/net/rpc/nfs4.idtoname/channel
rpc.idmapd: nfsdcb: authbuf=* authtype=user
rpc.idmapd: nfs4_uid_to_name: calling static->uid_to_name
rpc.idmapd: nfs4_uid_to_name: static->uid_to_name returned 0
rpc.idmapd: nfs4_uid_to_name: final return value is 0
rpc.idmapd: Server : (user) id "0" -> name "root@localdomain"

如果exportfs sec=sys,则继续如下:

rpc.idmapd: nfsdch: authbuf=* authtype=user
rpc.idmapd: nfs4_name_to_uid: calling static->name_to_uid
rpc.idmapd: nfs4_name_to_uid: static->name_to_uid returned -2
rpc.idmapd: nfs4_name_to_uid: final return value is -2
rpc.idmapd: Server : (user) name "0" -> id "99"
(stops here)

如果exportfs sec=none,则继续如下:

rpc.idmapd: nfsdch: authbuf=* authtype=group
rpc.idmapd: nfs4_gid_to_name: calling static->gid_to_name
rpc.idmapd: nfs4_gid_to_name: static->gid_to_name returned -2
rpc.idmapd: nfs4_gid_to_name: final return value is -2
rpc.idmapd: Server : (group) id "190" -> name "nobody"
rpc.idmapd: nfsdch: authbuf=* authtype=user
rpc.idmapd: nfs4_name_to_uid: calling static->name_to_uid
rpc.idmapd: nfs4_name_to_uid: static->name_to_uid returned -2
rpc.idmapd: nfs4_name_to_uid: final return value is -2
rpc.idmapd: Server : (user) name "0" -> id "99"
(stops here)

用户 ID 映射的类似问题:

  • NFSv4 用户映射
  • NFS 用户映射
  • 将本地用户的 UID 和 GID 映射到挂载的 NFS 共享
  • 还有更多……通常与从 NFSv3 到 NFSv4 的切换有关,很少与网络启动有关。

故障排除

  • 没有防火墙
  • 没有 Kerberos、LDAP 等。
  • 没有 SELinux
  • 用户root同时存在于 SERVER 和 CLIENT 上,具有相同的密码。

服务器

我可以在服务器上识别的 NFSv4 的所有其他相关配置文件。

/etc/nsswitch.conf
  passwd: compat mymachines systemd
  group: compat mymachines systemd
  shadow: compat
  publickey: files
  hosts: files mymachines resolve [!UNAVAIL=return] dns myhostname
  networks: files
  protocols: files
  services: files
  ethers: files
  rpc: files
  netgroup: files

/etc/nfs.conf
  (all settings commented out)
/etc/conf.d/nfs-common.conf
  (all settings commented out)

网络配置

  • 如何在 GNU/Linux 上设置域名?
  • Archlinux Wiki 网络配置:设置主机名
  • Archlinux Wiki 网络配置:本地网络主机名解析

SERVER 主机名是server并且有 3 个网络设备 (nd[1-3])。网关default via 192.168.0.1 nd1。

/etc/hosts
  127.0.0.1      localhost.localdomain  localhost
  ::1            ip6.localhost          localhost
  192.168.0.101  nd1.localdomain        server servernd1
  192.168.1.101  nd2.localdomain        server servernd2
  192.168.2.101  nd3.localdomain        server servernd2
  192.168.1.102  client1.localdomain    client1
  192.168.2.102  client2.localdomain    client2

/etc/resolveconf.conf
  name_servers=192.168.0.1

# hostname -f
# nd1.localdomain

# hostname -i
192.168.0.101 192.168.1.101 192.168.2.101

# getent hosts IP -> the corresponding line in /etc/hosts
# getent ahosts HOSTNAME -> the corresponding line in /etc/hosts

# ping -c 3 server.localdomain -> 0% packet loss

# id -u root -> 0
# id -un 0 -> root

Display the system's effective NFSv4 domain name on stdout.
# nfsidmap -d -> localdomain

Display on stdout all keys currently in the keyring used to cache ID mapping results. These keys are visible only to the superuser.
# nfsidmap -l -> nfsidmap: '.id_resolver' keyring was not found.

客户

/etc/hostname +(20171209)
  client2
/etc/hosts
  (exactly the same as the hosts file on the server)
/etc/resolveconf.conf
  name_servers=192.168.0.1
/etc/idmapd.conf
  (exactly the same as the idmapd.conf file on the server)
/etc/fstab
  # sys=sec or sys=none to correspond to server export settings. 
  /dev/nfs  /  nfs  rw,hard,rsize=9151,sec=sys,clientaddr=192.168.2.102  0  0
  devtmpfs  /dev   devtmpfs  defaults
  proc      /proc  proc      defaults
  none      /run   tmpfs     defaults
  sys       /sys   sysfs     defaults
  run       /run   tmpfs     defaults
  tmp       /tmp   tmpfs     defaults

是通过fstab使用findmnt -A.

net_nfs4

  • +(20171210) SERVER 和 CLIENT 上的 NFS 版本cat /proc/fs/nfsd/versions -> -2 +3 +4 +4.1 +4.2
  • 在 SERVER 和 CLIENTcat /sys/module/nfsd/parameters/nfs4_disable_idmapping -> N上。
  • 在服务器上echo "options nfsd nfs4_disable_idmapping=0" > /etc/modprobe.d/nfsd.conf。
  • 在 CLIENT/sys/module/nfs/parameters/nfs4_disable_idmapping上不存在,并且不确定如何手动创建它,因为它/sys是只读的。
  • +(20171210) 在客户上 echo "options nfs nfs4_disable_idmapping=0" > /etc/modprobe.d/nfs.conf。

客户端 IP 是192.168.2.102/24。CLIENT 网络设备连接到 SERVER nd2 192.168.2.101/24(主机名:servernd2)。

开机时的网络信息:

:: running early hook [udev]
starting version 235
:: running hook [udev]
:: Triggering uevents...
:: running hook [net_nfs4]
IP-Config: eth0 hardware address [CLIENT NETWORK DEVICE MAC] mtu 1500 DHCP
hostname client2 IP-Config: eth0 guessed broadcast address 192.168.2.255
IP-Config: eth0 complete (from 192.168.0.101):
 address: 192.168.2.102     broadcast: 192.168.2.255     netmask: 255.255.255.0
 gateway: 192.168.2.101     dns0     : 192.168.0.1       dns1   : 0.0.0.0
 host   : client2
 domain : localdomain
 rootserver: 192.168.0.101 rootpath: /srv/archlinux
 filename  : /netboot/grub/i386-pc/core.0
NFS-Mount: 192.168.2.101:/archlinux
Waiting 10 seconds for device /dev/nfs ...
(systemd takes over from here)

为什么会出现 NSFv4 错误?

Server : (group) id "190" -> name "nobody"

在 NFSv4 中,情况发生了变化:用户由用户名映射,用户名和用户 ID 之间的映射由称为“ID 映射守护程序”(idmapd) 的进程处理。特别是,NFSv4 客户端和服务器应该使用相同的域以使映射正常工作,否则请求将被映射到匿名用户/组。--试用 NFSv4(在 Linux 和 Solaris 上) -- 2012 年 3 月 15 日 - 13:03 / bronto


在理想情况下,请求客户端的用户和组将确定返回数据的权限。我们不是生活在一个理想的世界里。两个现实世界的问题介入:

  1. 您可能不信任对服务器文件具有 root 访问权限的客户端的 root 用户。
  2. 客户端和服务器上相同的用户名可能具有不同的数字 ID

问题 1 在概念上很简单。John Q. Programmer 获得了一台测试机器,他对其具有 root 访问权限。这绝不意味着 John Q. Programmer 应该能够更改服务器上的根拥有的文件。因此 NFS 提供了根压缩,该功能将 uid 0(根)映射到匿名 (nfsnobody) uid,默认为 -2(16 位数字为 65534)。-- NFS: Overview and Gotchas -- 版权所有 (C) 2003 by Steve Litt

+(20171209)rpc.idmapd: nss_getpwnam: name '0' domain 'localdomain': resulting localname '(null)'

根据Steve Dickson 在对 Red Hat Bugzilla 的评论 (2011-08-12 16:01:55 EDT) 中的评论 – 错误 715430 报告

[error] 语句解释了问题。本地机器上的 DNS 未设置(或返回 NULL),并且 /etc/idmapd.conf 中的 Domain= 变量未设置。

nss_getpwnam: name '0' does not map into domain

在 Debian 邮件列表中,Jonas Meurer 和 Christian Seiler (20150722) 之间有关“Kerberos-secured NFSv4”的电子邮件通信中详细解释了该错误。我对讨论的总结:

当 NFS 客户端发送nss_getpwnam: name '8' domain 'freesources.org': resulting localname '(null)'

NFS 客户端在某些情况下只发送转换为字符串的 uid,而不是正确转换的 NFS 用户名,然后服务器会拒绝该用户名。

客户应该发送nss_getpwnam: name 'mail@freesources.org' domain 'freesources.org': resulting localname 'mail'

在这里,您可以看到 NFS 客户端传输的所有者名称是“mail@freesources.org”(而不仅仅是“8”),所以它确实包含一个 @;nss_getpwname 可以看到域名匹配,然后将其剥离,产生一个用户名“mail”,它在 /etc/passwd 中查找,返回用户 id(在本例中为 8,因为它在客户端和服务器),服务器非常高兴。

那么为什么客户端会发送错误的用户名呢?...每隔一段时间,idmapping 就会失败,所以内核只会发送一个数字。但是这个数字会导致 chown 命令失败,因为服务器不会把它翻译回来。

简短的回答:我不知道。

更长的答案:...

如果我正确理解较长的答案,则可能会出现问题,因为 NFS 客户端依赖于“内核的密钥缓存”。对于 NFS 服务器,这永远不会成为问题,因为从未使用过“内核的密钥缓存”。

尽管如此,

由于您只是通过 /etc/passwd 使用常规 nsswitch,因此 nss_getpwnam在您的情况下永远不会失败,除非您同时使用 /etc/passwd 做一些奇怪的事情。

答案还提到了 idmapd 的替代方法;nfsidmap,虽然阅读man我不太明白它将如何取代idmapd.

+(20171209) nss_getpwnam: name 'root@domain.com' does not map into domain 'localdomain'

我似乎没有出现此错误消息,但是我包含了来自SUSE 支持知识库的答案 - 10-DEC-13 修改日期:12-OCT-17 -因为原因描述和建议的补救措施与其他发现的讨论形成鲜明对比。

NFSv4 处理用户身份的方式与 NFSv3 不同。在 v3 中,nfs 客户端只需在 chown(和其他请求)中传递一个 UID 号,nfs 服务器会接受它(即使 nfs 服务器不知道具有该 UID 号的帐户)。但是,v4 旨在以@ 的形式传递身份。为了正常运行,通常需要 idmapd(id 映射守护程序)在客户端和服务器上处于活动状态,并且每个都将自己视为同一 id 映射域的一部分。

像上面记录的那样,chown 失败或 idmapd 错误通常是以下任一原因的结果:

  1. 客户端知道用户名但服务器不知道用户名,或者
  2. idmapd 域名在客户端的设置与在服务器上的设置不同。

因此,可以通过确保 nfs 服务器和客户端配置有相同的 idmapd 域名 (/etc/idmapd.conf) 并且都知道相关的用户名/帐户来解决此问题。

但是,确保双方具有相同的用户帐户知识通常并不方便,尤其是在 nfs 服务器是文件管理器的情况下。NFS 社区已经认识到,NFSv4 的这个 idmapd 特性通常更麻烦,因此值得采取一些步骤和修改,以使 NFSv3 行为即使在 NFSv4 下也能正常工作。

建议的补救措施是禁用 idmapd。

nfs.nfs4_disable_idmapping=1

+(20171209) Wireshark

Analyzing the Wireshark log, it is quite extensive but begins with something like:

[IP CLIENT] -> [IP SERVER] NFS 226 V4 Call ACCESS FH: [HEX VALUE], [Check: RD LU MD XT DL]
[IP SERVER] -> [IP CLIENT] NFS 238 V4 Reply (Call In 34) ACCESS, [Allowed: RD LU MD XT DL]
[IP CLIENT] -> [IP SERVER] NFS 246 V4 Call LOOKUP DH: [HEX VALUE]/archlinux

where a similar pattern [A HEX VALUE]/[PATH] can be discerned for /sbin, /usr, /bin, /init, /lib, /systemd, /dev, /proc, /sys, /run, /, /lib64.

When the CLIENT requests /Id-linux-x86-64.so.2 the first errors start to appear:

[IP CLIENT] -> [IP SERVER] NFS 342 V4 Call OPEN DH: [HEX VALUE]/Id-linux-x86-64.so.2
[SERVER IP] -> [CLIENT IP] NFS 166 V4 Reply (Call In 124) OPEN Status: NFS4ERR_SYMLINK

The pattern more or less repeats itself with more frequent errors, for example, LOOKUP Status; and OPEN Status: reporting NFS4ERR_NOENT.

Interestingly, it is at the very end of the log where to first and only reference to user permission is made,

[SERVER IP] -> [CLIENT IP] NFS 182 V4 Reply (Call In 9562) SETATTR Status: NFS4ERR_BADOWNER

RFC

According to

  • RFC7530 (Network File System (NFS) Version 4 Protocol, 201503, PROPOSED STANDARD) -- Updated by RFC7931
  • RFC5661 (Network File System (NFS) Version 4 Minor Version 1 Protocol, 201001, PROPOSED STANDARD) -- Updated by RFC8178
  • RFC7862 (Network File System (NFS) Version 4 Minor Version 2 Protocol, 201001, PROPOSED STANDARD) -- Updated by RFC8178 -- which refers back to [RFC5661].

NFS4ERR_BADOWNER (Error Code 10039)

This error is returned when an owner or owner_group attribute value or the who field of an ACE within an ACL attribute value cannot be translated to a local representation.

The specifications discuss in Section 5.9. Interpreting owner and owner_group, I am not sure what to cite as relevant however.

NFS4ERR_SYMLINK (Error Code 10029)

The current filehandle designates a symbolic link when the current operation does not allow a symbolic link as the target.

NFS4ERR_NOENT (Error Code 2)

This indicates no such file or directory. The file system object referenced by the name specified does not exist.

The error could however be expected ...

The current filehandle is assumed to refer to a regular directory a named attribute directory. LOOKUPP assigns the filehandle for its parent directory to be the current filehandle. If there is no parent directory, an NFS4ERR_NOENT error must be returned. Therefore, NFS4ERR_NOENT will be returned by the server when the current filehandle is at the root or top of the server's file tree.

+(20171210) mount -t nfs4 [SERVER IP]:/archlinux /mnt

On the client computer, using the Archlinux "LiveUSB" I was able to mount the network drive, download the latest kernel (4.14-4-1-ARCH) via the SERVER internet connection, and install archlinux on the [SERVER IP]/archlinux.

During install rpc.idmapd -fvvv indicated a successful mapping of usernames, for example,

rpc.idmapd: Server : (user) id "0" -> name "root@localdomain"
rpc.idmapd: Server : (group) id "99" -> name "nobody@localdomain"
... -> name "tty@localdomain"
... -> name "systemd-journal-upload@localdomain"
... -> name rpc@localdomain
... -> name systemd-journal@localdomain
... -> name utmp@localdomain

The result of genfstab was also different:

[SERVER IP]:/archlinux  /  nfs4 rw,relatime,vers=4.2,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,times=600,retrans=2,sec=sys,clientaddr=[CLIENT IP],local_lock=none,addr=[SERVER IP]  0 0

Nevertheless, after reboot systemd failed again with the same failures as described at the beginning of the post.

+(20171210) Is the remote directory on the server mounted to /new_root?

The mkinitcpio script uses the variable mount_handler to carry an assigned "mounting function", in this case nfs_mount_handler(), to which the "root path" is passed $1 at a later stage; /new_root.

I am trying to verify that the client has mounted the [SERVER IP]:/archlinux to the /new_root. On the server, I can only observe that the client has established a connection but not if the directory is mounted and to where?

showmount -a server -> All mount points on server: (empty)

ss -ntp | grep 2049 ->
ESTAB  0    0   192.168.2.101:2049  192.168.2.102:809 (random port)

+(20171210) NFS4, sec=sys and id mapper are incompatible?

Reading the doco, it looks like sec=sys and the id mapper can be used to correctly map uid/gid to name where the client and server have different mappings in /etc/passwd and /etc/group. This simply isn't true.

That's because with sec=sys the id mapper doesn't come into play in the authentication part of the nfs protocol, only the file attributes part. With sec=sys authentication, nfs just passes the client uid/gid which is used directly by the server. So permissions checks will be screwed if client and server uid and gid don't align. To confuse things further, when the client creates a new file it is the authentication credentials that are used, so the file gets created at the server with the client's uid/gid. After that nfs uses idmap to get the file attributes, so the uid/gid (which originally came from the client) gets mapped at the server, and you end up seeing the server's name for a client uid/gid. Borkage! On the other hand, if the file was originally created at the server, you will see the correct name at the client, even if the uid/gid differs. But permissions checking will still be broken. -- kimmie -- Posted: Wed Feb 20, 2013 3:14 am Post subject: -- Emphasis in original

arch-linux systemd
  • 1 个回答
  • 1475 Views
Martin Hope
user212827
Asked: 2017-12-03 18:26:53 +0800 CST

archlinux efi netboot 内核“ip”不起作用?systemd "启动 Switch Root 失败。"

  • 2

我正在尝试使用指南Diskless system for archlinux (4.13.12-1-ARCH)中提供的说明设置无盘节点/工作站/系统。

问题

客户端成功连接到 TFTP ( atftp ),传输所有文件并显示 GRUB 选择菜单(相关摘录自grub.cfg):

load_video
set gfxpayload=keep
insmod gzip
insmod ext3
insmod net
insmod tftp
insmod efinet

set root=(tftp,192.168.0.101)
set prefix=(tftp,192.168.0.101)/netboot/grub

linux /netboot/vmlinuz-linux add_efi_memmap root=/dev/nfs rootfstype=nfs nfsroot=192.168.0.101:/srv/[CLIENT OS] nfsrootdebug rw ip=dhcp
initrd /netboot/initramfs-linux.img

我尝试了ip(https://www.kernel.org/doc/Documentation/filesystems/nfs/nfsroot.txt)的各种任务

 ip=:::::efinet0:dhcp
 ip=:::::eno1s0:dhcp
 ip=:::::eth0:dhcp
 ip=[CLIENT IP]:[SERVER IP]:[GATEWAY IP]:[NETMASK]:[HOSTNAME]:[DEVICE]:dhcp

在同时加载linux和initrd时,继续导致

[FAILED] "Failed to start Switch Root."
See 'systemctl status initrd-switch-root.service' for details.
You are in emergency mode. After logging in, type "journalctl -xb" to view
system logs, "systemctl reboot" to reobot, "systemctl default or ^D to enter into default mode.
Press Enter for maintenance
(or press Control-D to continue):

故障排除

删除 add_efi_mmap

而不是Failed to start Switch Root.,内核恐慌:

[    1.114386] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,255)
[    1.114458] CPU: 3 PID: 1 Comm: swapper/0 Not tainted 4.13.12-1-ARCH #1 
[    1.114509] Hardware name: ASUSTeK COMPUTER INC. UX51V2A/UX51VZA, BIOS UX51VZA.204 12/03/2012
[    1.114573] Call Trace:
[    1.114604]  dump_stack+0x63/0x8b
[    1.114637]  panic+0xe4/0x23d
[    1.114667]  mount_block_root+0x1f4/0x2ab
[    1.114703]  ? set_debug_rodata+0x17/0x17
[    1.114737]  mount_root+0x6a/0x6d
[    1.114767]  prepare_namespace+0x134/0x16c
[    1.114802]  kernel_init_freeable+0x1ec/0x205
[    1.114840]  ? rest_init+0xe0/0xe0
[    1.114872]  kernel_init+0xc/0xfc
[    1.114904]  ret_from_fork+0x25/0x30
[    1.114957] Kernel Offset: 0x3000000 from 0xffffffff81000000 (relocation range: 0xffffffff80000000-0xffffffffbfffffff)
[    1.115040] ---[ end Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,255)

系统调试

我无法访问 journalctl。未检测到键盘或系统冻结,因为我既不能按Enter也不能^D继续。

尝试通过向内核 CLI 添加systemd.unit=emergency.target或直接引导进入紧急模式emergency似乎不起作用。

+(UPDATE 2)mkinitcpio参数break=premount不会改变systemd启动。

网络

使用 Wireshark,在初始 PXE 引导后没有网络活动,也就是说,当linux和initrd加载时,客户端和服务器之间不再有通信。

SERVER IP: 192.168.2.101/24
CLIENT IP: 192.168.2.102/24

格鲁布

GRUB net_*命令和环境变量似乎表明一切正常;tftp 工作。

net_ls_cards  efinet0 [CLIENT NETWORK DEVICE MAC]
net_ls_addr   efinet0 [CLIENT NETWORK DEVICE MAC] 192.168.2.102
net_ls_routes efinet0:local 192.168.2.0/24 efinet0
              efinet0:default 0.0.0.0/0 gw 192.168.2.101

echo $net_default_ip               192.168.2.102
echo $net_default_mac              [CLIENT NETWORK DEVICE MAC]
echo $net_default_server           192.168.2.101
echo $net_efinet0_ip               192.168.2.102
echo $net_efinet0_mac              [CLIENT NETWORK DEVICE MAC]
echo $net_efinet0_hostname         (empty)
echo $net_efinet0_domain           (empty)
echo $net_efinet0_dhcp_server_name (empty
echo $net_efinet0_next_server      192.168.0.101
echo $net_efinet0_root_path        102.168.0.101:/srv/[CLIENT OS]
echo $net_efinet0_extensionpath    (empty)

内核支持nfsroot和ip

鉴于没有网络活动,我假设ipornfsroot没有被执行。

事实上,我遇到的问题在Build the kernel with NFS support but not getting /dev/nfs问题中有所描述。

该问题的答案指出(Andreas Wiese 2014 年 7 月 1 日 14:58)

...确保将 NFS 支持内置到您的内核二进制文件中,而不是作为一个模块(或有一个initramfs,它负责这个)。网络驱动程序也是如此:您很可能希望将以太网 NIC 的驱动程序内置到内核映像中,否则您必须从initramfs.

简而言之,有几种可能性:

1. 按照上面的链接告诉您:已root=/dev/nfs设置,提供正确的nfsroot参数并通过参数告诉您的内核您的网络配置ip(这将是确保它完全正常工作的最佳方法,即以排除配置错误的 DHCP 服务器)。

2.拥有CONFIG_IP_PNP和CONFIG_IP_PNP_DHCP启用并设置一个 DHCP 守护程序来告诉您的客户端使用哪个 IP 地址以及在哪里可以找到它的 NFS-root。

3. 构建一个 initramfs,它可以进行正确的配置和 NFS 挂载。

研究archlinux内核

zgrep CONFIG_NFS_FS= /proc/config.gz -> CONFIG_NFS_FS=m
zgrep DHCP /proc/config.gz           -> (nothing)
zgrep _IP_PNP_ /proc/config.gz       -> CONFIG_IP_PNP is not set

表示archlinux不支持ip用内核编译。

在错误报告 (2006) FS#5056 的评论中 - 默认内核已禁用 NFS 根安装

mkinitcpio 已经支持 netbooting 而无需更改内核

可以将其与对所引用问题中已接受答案的评论进行比较。

大约 10 年以来,内核并没有直接引导 nfs,而是安装了一个初始 ramdisk,它重新解释了内核命令行并从您想要的位置引导。– 彼得 2016 年 6 月 17 日在 13:54

mkinitcpio

来自lsinitcpio -a

...
Created with mkinitcpio 24
Kernel: 4.13.12-1-ARCH
Size: 55,63 MiB
Compressed with: gzip
  ...

Included modules:
... nfs ... nfsv3 nfsv4 [explicit] ...

Included binaries:
... ipconfig ... mount.nsf4 ... nfsmount ...  

Early hook run order:
udev

Hook run order:
udev net net_nsf4 nbd

Cleanup hook order:
udev

对网络设备的 mkinitcpio 支持(更新 #1)

虽然应该加载网卡的驱动程序,但我想在阅读[SOLVED] Diskless - ipconfig: no devices to configure后确定。

将网络模块驱动器放在 /etc/mkinitcpio.conf 中。

MODULES=(atl1c nbd nfsv4)

无论是明确声明模块还是在客户端上构建整个模块都initramfs.img没有改变。

如果图像应该在不同的机器上运行,不要使用自动检测。自动检测会删除在当前运行的系统上启动不需要的所有驱动程序。

从钩子中移除autodetect会产生一个有趣的结果;之前观察到的删除add_efi_mmap时发生的内核恐慌。add_efi_mmap加载 no- 时删除autodetect initramfs没有进一步的影响。

mkinitcpio 支持nfs

Archlinux 可能支持也可能不支持 nsf4。

  • mkinitcpio 运行时定制 使用 net
  • FS#28287 - [mkinitpio-nfs-utils] NFS4 支持

据我所知,这是次要问题;在尝试挂载 nfs 之前,网络必须工作。

mkinitcpio 支持ip

我刚刚发现

  • mkinitcpio-nfs-utils (0.3-5)包括一个“ipconfig”,
  • 有一个mkinitcpio-netconf 0.0.4-2。

附加信息

这可能相关也可能不相关。

使用“UEFI PXE 引导”而不是“BIOS PXE 引导”的原因是因为 GRUB i386-pc 无法加载 grub.cfg。计算机要么重新启动,要么冻结在“欢迎使用 GRUB!”。并且可能会用彩色像素使屏幕混乱;结果似乎是随机的。Wireshark 日志显示tftp有时会加载所有 grub 模块,有时则不会。最后一个日志条目通常是客户端请求服务器网络设备;ARP 60 Who has [SERVER IP]? Tell [CLIENT IP]?

arch-linux linux-kernel
  • 1 个回答
  • 1315 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    模块 i915 可能缺少固件 /lib/firmware/i915/*

    • 3 个回答
  • Marko Smith

    无法获取 jessie backports 存储库

    • 4 个回答
  • Marko Smith

    如何将 GPG 私钥和公钥导出到文件

    • 4 个回答
  • Marko Smith

    我们如何运行存储在变量中的命令?

    • 5 个回答
  • Marko Smith

    如何配置 systemd-resolved 和 systemd-networkd 以使用本地 DNS 服务器来解析本地域和远程 DNS 服务器来解析远程域?

    • 3 个回答
  • Marko Smith

    dist-upgrade 后 Kali Linux 中的 apt-get update 错误 [重复]

    • 2 个回答
  • Marko Smith

    如何从 systemctl 服务日志中查看最新的 x 行

    • 5 个回答
  • Marko Smith

    Nano - 跳转到文件末尾

    • 8 个回答
  • Marko Smith

    grub 错误:你需要先加载内核

    • 4 个回答
  • Marko Smith

    如何下载软件包而不是使用 apt-get 命令安装它?

    • 7 个回答
  • Martin Hope
    user12345 无法获取 jessie backports 存储库 2019-03-27 04:39:28 +0800 CST
  • Martin Hope
    Carl 为什么大多数 systemd 示例都包含 WantedBy=multi-user.target? 2019-03-15 11:49:25 +0800 CST
  • Martin Hope
    rocky 如何将 GPG 私钥和公钥导出到文件 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Evan Carroll systemctl 状态显示:“状态:降级” 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim 我们如何运行存储在变量中的命令? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S 为什么 /dev/null 是一个文件?为什么它的功能不作为一个简单的程序来实现? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 如何从 systemctl 服务日志中查看最新的 x 行 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - 跳转到文件末尾 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla 为什么真假这么大? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis 在一个巨大的(70GB)、一行、文本文件中替换字符串 2017-12-30 06:58:33 +0800 CST

热门标签

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve