【发布时间】:2015-06-03 12:18:10
【问题描述】:
我正在为 Beagle Bone 板从底层构建一个 Linux 系统。我已经编译了 vanilla 内核并使用busybox 构建了一个基本的根文件系统。系统使用U-boot启动,rootfs位于Linux PC上,通过NFS导出:
/path/to/rootfs 10.42.0.17(rw,wdelay,no_root_squash,no_subtree_check,sec=sys,rw,secure,no_root_squash,no_all_squash)
U-boot bootargs 是:
bootargs console=ttyO0,115200n8 root=/dev/nfs rw nfsroot=${serverip}:/path/to/rootfs,v3,tcp ip=dhcp
我在尝试让su 为非root 用户工作时遇到了问题。为了解决这个问题,互联网上的人们建议为busybox 二进制文件设置suid 位。
这样做之后:
$ sudo chmod u+s busybox
并验证:
$ ls -la
...
-rwsr-xr-x 1 myuser myuser 1882976 Jan 13 21:47 busybox
...
$ stat -c "%a %n" busybox
4755 busybox
出了点问题。内核正在启动,所有常见的消息都显示出来了,但最后卡住了,没有显示login 行。以下是引导顺序的最后几行:
[ 3.776185] IP-Config: Complete:
[ 3.779656] device=eth0, hwaddr=c8:a0:30:c5:80:e9, ipaddr=10.42.0.17, mask=255.255.255.0, gw=10.42.0.1
[ 3.789877] host=10.42.0.17, domain=, nis-domain=(none)
[ 3.795822] bootserver=10.42.0.1, rootserver=10.42.0.1, rootpath=
[ 3.802492] nameserver0=10.42.0.1
[ 3.871575] VFS: Mounted root (nfs filesystem) on device 0:15.
[ 3.879903] devtmpfs: mounted
[ 3.883713] Freeing unused kernel memory: 380K (c07ef000 - c084e000)
如果去掉flag,一切就恢复正常了:
....
[ 3.862291] Freeing unused kernel memory: 380K (c07ef000 - c084e000)
10.42.0.17 login:
如果在 Beagle Bone 板本身的运行 shell 中设置标志,则 shell 在执行 chmod 后立即停止响应。
我怀疑这与 NFS 导出 rootfs 的方式有关,但这只是一个猜测,因此合格的解释和可能的解决方案会有所帮助。
【问题讨论】:
标签: linux embedded-linux boot nfs rootfs