Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Installing gentoo in chroot I found that commands like mount and df doesn't work: they try to read file /etc/mtab (which of course is empty).

Can I (for future use) setup or even recompile them so, that they won't read /etc/mtab, taking all needed info from /proc?

share|improve this question

2 Answers 2

df and mount are based on *mntent (ex getmntent) functions, based on /etc/mtab and /etc/fstab. You can patch these tools, but you should simply copy or symlink /proc/mounts to /etc/mtab.

share|improve this answer
    
Indeed: I look at /etc/mtab in my archlinux, it is a symlink to /proc/self/mounts. Is there any difference between /proc/self/mounts and /proc/mounts? –  Eddy_Em Mar 27 '13 at 8:01
1  
/proc/self is a symlink to /proc/CURPID/. So if you do an ls /proc, it's link to ls current PID. And /proc/mounts is a symlink to /proc/self/mounts. So basicly it's the same file. –  GHugo Mar 27 '13 at 10:47
    
thanks for explanation. If I'd have look at /proc/mounts, I wouldn't ask previous question. –  Eddy_Em Mar 27 '13 at 10:53

Don't do that: instead, symlink /proc/mounts to /etc/mtab instead, that solve your problem as well.

And notice that in a chrooted environment, you only need a minimal mount table, i.e /sys, /proc, / etc.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.