LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 2095|回复: 16

About /dev/null (Problem solved)

[复制链接]
发表于 2005-7-8 23:47:48 | 显示全部楼层 |阅读模式
In a bash shell, if I run:

d00m3d@Xen#ls
.......(list of files)...
d00m3d@Xen#ls > /dev/null
d00m3d@Xen#

So, this is normal.

However, under a chroot environment, e.g.

d00m3d@Xen#mount -t ext3 /dev/hda8 /mnt/hda8
d00m3d@Xen#chroot /mnt/hda8 /bin/sh
sh-3.00#ls > /dev/null
sh: /dev/null: Permission denied
sh-3.00#

Why is that?

How can I use /dev/null under a chroot environment?
发表于 2005-7-9 08:53:19 | 显示全部楼层
在chroot后执行
ls -l /dev/null
看看/dev/null的权限是否是crw-rw-rw-
回复 支持 反对

使用道具 举报

发表于 2005-7-9 11:07:34 | 显示全部楼层
-bash-2.05b# ls -l /dev/null
c---------    1 root     root       1,   3  5ÔÂ 30  2004 /dev/null
-bash-2.05b# echo abc > /dev/null
-bash-2.05b#
7dehao兄,我觉得可能没那么简单,我连接的机器上/dev/null 什么权限也没有 c---------
但也是可以把输出重定向到/dev/null
回复 支持 反对

使用道具 举报

发表于 2005-7-9 16:49:51 | 显示全部楼层
Post by 弥敦路九号
-bash-2.05b# ls -l /dev/null
c---------    1 root     root       1,   3  5ÔÂ 30  2004 /dev/null
-bash-2.05b# echo abc > /dev/null
-bash-2.05b#
7dehao兄,我觉得可能没那么简单,我连接的机器上/dev/null 什么权限也没有 c---------
但也是可以把输出重定向到/dev/null

哦,这个我确实没注意到。google了一些发现这个问题还相当普遍,
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-7-10 05:51:45 | 显示全部楼层
Post by 7dehao
在chroot后执行
ls -l /dev/null
看看/dev/null的权限是否是crw-rw-rw-
Yes. Still not work :confused:
Post by 7dehao
哦,这个我确实没注意到。google了一些发现这个问题还相当普遍,
Any solutions?
回复 支持 反对

使用道具 举报

发表于 2005-7-10 14:47:10 | 显示全部楼层
网上的解决方案就是我写的那个。兄弟你的那个linux是不是装在Xen虚拟机中的?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-7-11 10:46:52 | 显示全部楼层
Oh, dear!  I misled you, sorry.

Well, I am a great fan of the Half Life first person shooter game.

My desktop computer is named as BlackMesa, which the origin of the game.  Xen is the alien world in Half Life.  I choose this name because I installed Linux in a USB HDD which mean I am working in mobile sense.  There is nothing related to the Xen virtual machine monitor developed by Cambridge U.

Back to my case, I installed Kanotix successfully on a USB HDD, everything is working fine and no problems in booting.  I have installed another source based distro in it but this time I got trouble.  When I chroot into it, I am unable to build the initrd under a chroot environment because of the /dev/null permission problem.

Please help!
回复 支持 反对

使用道具 举报

发表于 2005-7-11 12:27:24 | 显示全部楼层
我怀疑你chroot后是否拥有对/dev目录的写和执行的权限。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-7-11 13:16:52 | 显示全部楼层
That's the problem.

I am root.  Well, of course, normally only root can chroot. /dev/null权限是crw-rw-rw- but I still receive "permission denied" error!  What's happening??? :confused:
回复 支持 反对

使用道具 举报

发表于 2005-7-14 09:26:26 | 显示全部楼层
and 'whoami' after chroot...
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表