Jump to content
xisto Community
Sign in to follow this  
jedipi

/dev/null Permission Problem under a chroot environment

Recommended Posts

Hello Dear,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.In a bash shell, if I run:

CONSOLE
jedipi@Xen#ls.......(list of files)...jedipi@Xen#ls > /dev/nulljedipi@Xen#
So, this is normal.However, under a chroot environment, e.g.
CONSOLE
jedipi@Xen#mount -t ext3 /dev/hda8 /mnt/hda8jedipi@Xen#chroot /mnt/hda8 /bin/shsh-3.00#ls > /dev/nullsh: /dev/null: Permission deniedsh-3.00#
Why is that?How can I use /dev/null under a chroot environment?

Share this post


Link to post
Share on other sites

I would assume because /dev/null is owned by root, you could try su-ing to root and then performing this, or changing permissions of /dev/null but I would go for the former.Cheers,MC

Share this post


Link to post
Share on other sites

I did try login as root.But still got this problem#mount -t ext3 /dev/hda8 /mnt/hda8#chroot /mnt/hda8 /bin/shsh-3.00#whoamirootsh-3.00#ls -l /dev/nullcrw-rw-rw- 1 root root 1, 3 May 30 17:18 /dev/nullsh-3.00#ls > /dev/nullsh: /dev/null: Permission deniedsh-3.00#any ideas????

Share this post


Link to post
Share on other sites

try chmod 0777 /dev/null

1 = execute
2 = write
4 = read.

1+2+4=7

you are setting /dev/null as read/write/execute for all users.
the correct access rights for /dev/null are 222.

there is no reason to read or execute /dev/null :)

the following code should fix it.
chmod 222 /dev/null

Share this post


Link to post
Share on other sites

The error appear when a filesystem is mounted with the "nodev"
mount option and then chrooting into it.
This option can be overrided by editting /etc/fstab and appending ",dev" to the options column.

In my /etc/fstab,
I added the "users" option in order to allow normal user to mount the specific partition:

CONSOLE

#cat /etc/fstab |grep /dev/hda8
/dev/hda8 /mnt/hda8 ext3 noauto,users,exec 0 0


However, the "users" mount option implies "noexec", "nosuid" and "nodev" (unless overridden by subsequent options). Therefore, when I attempt to mount /dev/hda8, I got:
CONSOLE

#mount /dev/hda8
#mount |grep /dev/hda8
/dev/hda8 on /mnt/hda8 type ext3 (rw,nosuid,nodev)


Here, noexec is overridden by my exec option in /etc/fstab

To solve the problem, I must get rid of the nodev option.
I may append a ",dev" option to my /etc/fstab or mount my chroot filesystem as below:

#mount /dev/hda8 /mnt/hda8 -o rw

Now, the mount option is changed:

#mount |grep /dev/hda8
/dev/hda8 on /mnt/hda8 type ext3 (rw)

#chroot /mnt/hda8 /bin/sh
sh-3.00#ls > /dev/null
sh-3.00#

Problem solved. Cheers!

Further reference:
http://knoppix.net/wiki3/index.php?title=Dev_null_permission_denied

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.