Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
chroot [solved]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
idella4
Retired Dev
Retired Dev


Joined: 09 Jun 2006
Posts: 1600
Location: Australia, Perth

PostPosted: Wed Nov 18, 2009 12:30 pm    Post subject: chroot [solved] Reply with quote

This is quite odd. I have two instances of gentoo for reasons of my own. I want to chroot from the healthy one into the one that needs some maintenance. Out of the installation manual,

Code:

mount -t proc none /mnt/gentoo/proc
mount -o bind /dev /mnt/gentoo/dev
chroot /mnt/gentoo /bin/bash


which renders

Code:

idella@Gentoo ~/Documents $ sudo chroot /mnt/genny /bin/bash
Password:
chroot: cannot run command `/bin/bash': Permission denied


!!!!!!!!

It's a gentoo oddity. I boot into my suse, do the same and it goes straight in. Can anyone help on this?
_________________
idella4@aus


Last edited by idella4 on Wed Dec 02, 2009 2:10 pm; edited 1 time in total
Back to top
View user's profile Send private message
jormartr
Apprentice
Apprentice


Joined: 02 Jan 2008
Posts: 174

PostPosted: Wed Nov 18, 2009 12:36 pm    Post subject: Reply with quote

I guess you are running it as root, or as some user created on the chroot environment, right?
Back to top
View user's profile Send private message
idella4
Retired Dev
Retired Dev


Joined: 09 Jun 2006
Posts: 1600
Location: Australia, Perth

PostPosted: Wed Nov 18, 2009 12:39 pm    Post subject: Reply with quote

I don't know. As I posted

sudo chroot ....
_________________
idella4@aus
Back to top
View user's profile Send private message
Mike Hunt
Watchman
Watchman


Joined: 19 Jul 2009
Posts: 5287

PostPosted: Wed Nov 18, 2009 1:41 pm    Post subject: Reply with quote

You need to be loged in as root to do that stuff.

Or the sudoers file needs to be configured to keep env or delete env - or something - not sure, I think ALL does what you need.
Back to top
View user's profile Send private message
idella4
Retired Dev
Retired Dev


Joined: 09 Jun 2006
Posts: 1600
Location: Australia, Perth

PostPosted: Wed Nov 18, 2009 3:06 pm    Post subject: Reply with quote

Hi again Mike. Did you see the result of the first post you answered for me? I had to post another thread because the update had a couple of failsl. They are also within Portage and Programming.
On this one, I'm currently in suse because of this problem. I enter

Code:

idella@Susie:~> sudo chroot /mnt/genny /bin/bash
root's password:
Susie / #


Note suse strangely wants the root password where on gentoo you enter your username password.
The second is called genny. It demonstrates that it works with either sudo chroot or su into a root console. The point is it's fine in suse but plays up on gentoo which I would normally be using.
Yes I've tried both methods in gentoo.
_________________
idella4@aus
Back to top
View user's profile Send private message
Mike Hunt
Watchman
Watchman


Joined: 19 Jul 2009
Posts: 5287

PostPosted: Thu Nov 19, 2009 3:05 am    Post subject: Reply with quote

That is most likely because the sudoers files are configured differently on Gentoo and SUSE.

Did you remove the CONFIG_PROTECT="-*" line from your make.conf yet?
Back to top
View user's profile Send private message
idella4
Retired Dev
Retired Dev


Joined: 09 Jun 2006
Posts: 1600
Location: Australia, Perth

PostPosted: Thu Nov 19, 2009 3:31 am    Post subject: Reply with quote

Mike, yes you are right. They are configured differently. It's a trivial point. No I haven't yet but I will now on both. Any more ideas on why chroot is playing up in gentoo?
I've made a bit of progress on the other posts if you look. Getting there.
_________________
idella4@aus
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 44181
Location: 56N 3W

PostPosted: Sun Nov 29, 2009 12:39 pm    Post subject: Reply with quote

idella4,

I wonder what gives the permision denied error.

The chroot command itself or the /bin/bash bit.
Try other shells you will have busybox and its bb symlink. What error does
Code:
chroot  /mnt/gentoo /bin/bb
give.

Does it work for root and not a normal user ?
What are the permissions and ownership on /mnt/gentoo/bin/bash?
Code:
-rwxr-xr-x 1 root root 893208 Oct 29 20:46 /bin/bash
is correct.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
idella4
Retired Dev
Retired Dev


Joined: 09 Jun 2006
Posts: 1600
Location: Australia, Perth

PostPosted: Sun Nov 29, 2009 1:58 pm    Post subject: Reply with quote

neddy, thanks for looking. As I thought, the permission settings are ok.

Code:

Gentoo Documents # ls -l /bin/bash
-rwxr-xr-x 1 root root 667532 Feb 13  2008 /bin/bash


Code:

Gentoo Documents # ls -l /mnt/genny//bin/bash
-rwxr-xr-x 1 root root 723884 Nov 21 19:36 /mnt/genny//bin/bash


and as you expected,

Code:

Gentoo Documents # chroot /mnt/genny /bin/bb
chroot: cannot run command `/bin/bb': Permission denied


oh well. That's a difficult one. A gentoo glitch, as far as I know the only thing wrong with this gentoo. It may be outdated but it still looks sharp and quick, nothing wrong with it.

Code:

Gentoo Documents # chroot /mnt/genny /bin/sh
chroot: cannot run command `/bin/sh': Permission denied


Code:
idella@Gentoo ~/Documents $ chroot /mnt/genny /bin/bash
chroot: cannot change root directory to /mnt/genny: Operation not permitted

_________________
idella4@aus
Back to top
View user's profile Send private message
Mike Hunt
Watchman
Watchman


Joined: 19 Jul 2009
Posts: 5287

PostPosted: Sun Nov 29, 2009 2:46 pm    Post subject: Reply with quote

Is the /mnt/gentoo mounted with exec permissions?
Back to top
View user's profile Send private message
idella4
Retired Dev
Retired Dev


Joined: 09 Jun 2006
Posts: 1600
Location: Australia, Perth

PostPosted: Mon Nov 30, 2009 3:42 am    Post subject: Reply with quote

Mike, thanks for your response. I don't know what you mean by exec permissions. I've just followed the handbook's code and it's worked until now. Can you set permissions in executing chroot? Please explain.
Just to clarify, you asked
Quote:

Is the /mnt/gentoo mounted

This is one gentoo accessing the other. I'm in hostname gentoo trying to chroot to hostname genny. genny is the one you've all been helping get upgraded and repaired. gentoo is the other. So you might mean Is the /mnt/genny mounted ....
This is a difficult one if neddy can't pick it. But anyway, it would be nice to have my gentoo perfect.
_________________
idella4@aus
Back to top
View user's profile Send private message
Mike Hunt
Watchman
Watchman


Joined: 19 Jul 2009
Posts: 5287

PostPosted: Mon Nov 30, 2009 6:33 am    Post subject: Reply with quote

Run
Code:
mount
or, the same thing this way
Code:
cat /proc/mounts

Is the partition, whatever it's named, mounted with a noexec option?
Back to top
View user's profile Send private message
idella4
Retired Dev
Retired Dev


Joined: 09 Jun 2006
Posts: 1600
Location: Australia, Perth

PostPosted: Mon Nov 30, 2009 3:20 pm    Post subject: Reply with quote

Muke, you might have it here. I will be impressed.

Code:

idella@gentoo ~/Documents $ mount
/dev/sda3 on / type ext3 (rw,noatime)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec)
udev on /dev type tmpfs (rw,nosuid,size=10240k,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,gid=5,mode=620)
/dev/sda1 on /mnt/suse-11 type reiserfs (rw,noexec,nosuid,nodev)
/dev/sda2 on /mnt/fedora type ext3 (rw,noexec,nosuid,nodev)
/dev/sda5 on /mnt/ubuntu type reiserfs (rw,noexec,nosuid,nodev)
/dev/sda6 on /mnt/genny type reiserfs (rw,noexec,nosuid,nodev)
shm on /dev/shm type tmpfs (rw,noexec,nosuid,nodev)
usbfs on /proc/bus/usb type usbfs (rw,noexec,nosuid,devmode=0664,devgid=85)



Code:

/dev/sda6 on /mnt/genny type reiserfs (rw,noexec,nosuid,nodev)


noexec, must in fstab?

/etc/fstab

Code:

/dev/sda7      none      swap      sw       0 0
/dev/sda1      /mnt/suse-11     reiserfs        rw,user         0 2
/dev/sda2               /mnt/fedora      ext3            rw,user         0 2
/dev/sda5               /mnt/ubuntu      reiserfs        rw,user         0 2
/dev/sda6               /mnt/genny       reiserfs        rw,user         0 2
/dev/sdb5               /mnt/windata2    vfat            rw,user         0 2



ok that's informative, where do these settings come from? Looks like you're close.
_________________
idella4@aus
Back to top
View user's profile Send private message
Mike Hunt
Watchman
Watchman


Joined: 19 Jul 2009
Posts: 5287

PostPosted: Mon Nov 30, 2009 5:25 pm    Post subject: Reply with quote

You may want to set the mount options to "defaults" in fstab, for reiserfs you can set "notail"

man mount wrote:
users Allow every user to mount and unmount the filesystem. This
option implies the options noexec, nosuid, and nodev (unless
overridden by subsequent options, as in the option line
users,exec,dev,suid).
Back to top
View user's profile Send private message
idella4
Retired Dev
Retired Dev


Joined: 09 Jun 2006
Posts: 1600
Location: Australia, Perth

PostPosted: Tue Dec 01, 2009 1:18 am    Post subject: Reply with quote

This is what makes linux difficult. I've tried adjusting things like this in the past with little success.
The man text suggests that it's overriden in the fstab setting, but it hasn't done so. I tried defaults and adding exec but it stubbornly resists.
You're implying the noexec option is causing this I take it. Can your gentoo chroot without this error?
_________________
idella4@aus
Back to top
View user's profile Send private message
Mike Hunt
Watchman
Watchman


Joined: 19 Jul 2009
Posts: 5287

PostPosted: Tue Dec 01, 2009 2:54 pm    Post subject: Reply with quote

Sure can. But I use the "defaults" mount option only.
man mount wrote:
defaults
Use default options: rw, suid, dev, exec, auto, nouser, and
async.

Code:
/dev/sda3         /                       ext3   defaults         0 1
Back to top
View user's profile Send private message
JeliJami
Veteran
Veteran


Joined: 17 Jan 2006
Posts: 1086
Location: Belgium

PostPosted: Tue Dec 01, 2009 3:16 pm    Post subject: Reply with quote

Maybe you could try to remount with exec turned on:
Code:
# mount -o remount,rw,exec /dev/sda6 /mnt/genny

_________________
Unanswered Post Initiative | Search | FAQ
Former username: davjel
Back to top
View user's profile Send private message
idella4
Retired Dev
Retired Dev


Joined: 09 Jun 2006
Posts: 1600
Location: Australia, Perth

PostPosted: Wed Dec 02, 2009 2:10 pm    Post subject: Reply with quote

Mike, this is interesting. I've browsed the man mount and found the entry. If you get to read this, could you clarify this. To me it's not clear. It cites default under
mount -o
Does this defaults mean the defaults in fstab? If it does, it appears to work. As you suggested,

Code:

/dev/sda3         /                       ext3   defaults         0 1


which becomes

Code:

/dev/sda6               /mnt/genny       reiserfs       defaultsl              0 2



[code]
gentoo Documents # umount /mnt/genny
gentoo Documents # mount /mnt/genny
gentoo Documents # chroot /mnt/genny /bin/bash
gentoo / #
[/code

I have twofold success mount -o remount,rw,exec /dev/sda6 /mnt/genny worked too. The defaults setting, is that set in the system somewhere or can you select default settings, and if so how. I've always wondered about that.
I've just been adjusting the cdrom setting which had a similar problem. The fstab file type was set to auto which generally always works. but it said
unknown filesystem type 'udf'

Where does it get it from? I got it to mount by replacing auto with iso0660.
I'll set this solved now but hope for a reply. Thanks for that.
_________________
idella4@aus
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 44181
Location: 56N 3W

PostPosted: Wed Dec 02, 2009 6:26 pm    Post subject: Reply with quote

idella4,

/etc/fstab is only consulted if its needed. Thats at boot time, which is similar to doing
Code:
mount -a
and when you give incomplete device and mount point informtion. Thus
Code:
mount /dev/sda1
mount /mnt/cdrom
cause /etc/fstab to be consulted but
Code:
mount /dev/fd0 /mnt/floppy
does not.

This can give you some odd permissions or file system type errors if you need mount to look at /etc/fstab to get the filesystem or determine that users are allowed to mount the device in question.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum