Sign up ×
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
/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
@Gilles, I think the original answer (before your edit) claims that /etc/mtab should be a separate regular file, not just symlink to /proc/mounts. AFAIK, it's now deprecated but was true some time ago because there were some applications depending on it. Probably they are still here, because /etc/mtab is not a symlink on my Gentoo yet. See discussion here:… So IMHO the edit should be reverted until we get the truth :) –  g-v Sep 30 at 14:31
@g-v /etc/mtab may be either updated by mount, or symlinked to /proc/mounts. Making a copy from /proc/mounts to /etc/mtab doesn't make much sense: if you want that, let mount update it — but the problem here seems to be that mount is not maintaining /etc/mtab properly, so making a copy that will go stale is not a good idea. –  Gilles Sep 30 at 14:43
@Gilles, making a copy at least did make sense some time ago: see and The second bug is fixed I think, but since /etc/mtab is still not a symlink on my one-year-old installation and the first bug above is not closed yet, the original answer is useful. It was a hint that before making it a symlink, you should ensure that it will not break anything (in Gentoo). –  g-v Sep 30 at 14:53

Your Answer


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.