如何让 kernel 和 initrd 支持 nfsroot

系统安装、升级讨论
版面规则
我们都知道新人的确很菜,也喜欢抱怨,并且带有浓厚的Windows习惯,但既然在这里询问,我们就应该有责任帮助他们解决问题,而不是直接泼冷水、简单的否定或发表对解决问题没有任何帮助的帖子。乐于分享,以人为本,这正是Ubuntu的精神所在。
回复
zhangjint5
帖子: 304
注册时间: 2011-01-02 12:31

如何让 kernel 和 initrd 支持 nfsroot

#1

帖子 zhangjint5 » 2017-08-22 18:45

最近构建了一个无盘工作站,操作思路如下:
1、dnsmasq 做 DHCP、TFTPD
2、debootstrap 构建最基础的 Linux 文件系统结构,并配置下 timezone、locale、hostname 和 root 帐号。
3、用 NFS 来 exports 上一步中的 base 系统文件。
4、使用 pxelinux.0 引导从 Ubuntu Desktop 光盘中 casper 文件夹里面拷贝出来的 kernel 和 initrd 。并用 root=/dev/nfs nfsroot=.... 参数成功引导系统。

工作基本正常,不过有个小问题,无盘客户端启动的时候 systemd 报告 systemd-modules-load.service 无法启动。

之后我自己手工安装了最新版本的 kernel 和 initrd 。将其拷贝出来,替代光盘里面提取的 kernel 和 initrd 用来引导,发现完全无法启动了,直接 kernel panic,貌似是自己安装的不支持 nfsroot ?

感觉光盘上 casper 里面的 kernel 和 initrd 好万能啊,通用于不同硬件,还支持 nfs 网络引导。

它是如何做到的呢?
头像
astolia
论坛版主
帖子: 6450
注册时间: 2008-09-18 13:11

Re: 如何让 kernel 和 initrd 支持 nfsroot

#2

帖子 astolia » 2017-08-22 19:56

你编译内核的时候,把需要的模块选成编译进内核(y),而不是编译成外部模块(m)

CONFIG_NFS_FS的说明
To configure a system which mounts its root file system via NFS at boot time, say Y here, select "Kernel level IP autoconfiguration" in the NETWORK menu, and select "Root file system on NFS" below. You cannot compile this file system as a module in this case.
上面两个选项分别是CONFIG_IP_PNP和CONFIG_ROOT_NFS
回复