Output of "mount" and "cat /etc/mtab" inside install chroot?

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

Output of "mount" and "cat /etc/mtab" inside install chroot?

Walter Dnes
  I've got another thread going called...
"Strange behaviour with LILO on new install on old laptop".  Before I
file a bug report, I want to check first whether it's my fault.  Can
people here do me a favour?  If you have a Gentoo install CD or USB key
handy, and are willing to reboot, can you please do the following...

1) boot from the install ISO
2) chroot to a running environment
3) list the output from the 2 commands
 mount
 cat /etc/mtab

  I'm getting absolutely no output at all from those 2 commands in the
install chroot.  That screws up the lilo ebuild install process.  I want
to check whether blank /etc/mtab is my fault or not.

--
Walter Dnes <[hidden email]>
I don't run "desktop environments"; I run useful applications

Reply | Threaded
Open this post in threaded view
|

Re: Output of "mount" and "cat /etc/mtab" inside install chroot?

Tom H-4
On Sat, Apr 19, 2014 at 7:43 AM, Walter Dnes <[hidden email]> wrote:

>   I've got another thread going called...
> "Strange behaviour with LILO on new install on old laptop".  Before I
> file a bug report, I want to check first whether it's my fault.  Can
> people here do me a favour?  If you have a Gentoo install CD or USB key
> handy, and are willing to reboot, can you please do the following...
>
> 1) boot from the install ISO
> 2) chroot to a running environment
> 3) list the output from the 2 commands
>  mount
>  cat /etc/mtab
>
> I'm getting absolutely no output at all from those 2 commands in the
> install chroot.  That screws up the lilo ebuild install process.  I want
> to check whether blank /etc/mtab is my fault or not.

Are you mounting a proc filesystem within the to-be-chrooted
filesystem before chrooting?

Reply | Threaded
Open this post in threaded view
|

Re: Output of "mount" and "cat /etc/mtab" inside install chroot?

Peter Humphrey-3
In reply to this post by Walter Dnes
On Saturday 19 Apr 2014 07:43:18 Walter Dnes wrote:

>   I've got another thread going called...
> "Strange behaviour with LILO on new install on old laptop".  Before I
> file a bug report, I want to check first whether it's my fault.  Can
> people here do me a favour?  If you have a Gentoo install CD or USB key
> handy, and are willing to reboot, can you please do the following...
>
> 1) boot from the install ISO
> 2) chroot to a running environment
> 3) list the output from the 2 commands
>  mount
>  cat /etc/mtab
>
>   I'm getting absolutely no output at all from those 2 commands in the
> install chroot.  That screws up the lilo ebuild install process.  I want
> to check whether blank /etc/mtab is my fault or not.

The installation handbook used to include a command to write /etc/mtab in the
chroot by grepping the host mtab, but it's been removed and I haven't been
able to find it. Meanwhile, I think it's standard behaviour for mtab not to be
populated during the installation process.

So I'd also be interested to hear from anyone who knows what mtab should
contain.

--
Regards
Peter


Reply | Threaded
Open this post in threaded view
|

Re: Output of "mount" and "cat /etc/mtab" inside install chroot?

Mark David Dumlao-3
On Sat, Apr 19, 2014 at 8:54 PM, Peter Humphrey <[hidden email]> wrote:

> On Saturday 19 Apr 2014 07:43:18 Walter Dnes wrote:
>>   I've got another thread going called...
>> "Strange behaviour with LILO on new install on old laptop".  Before I
>> file a bug report, I want to check first whether it's my fault.  Can
>> people here do me a favour?  If you have a Gentoo install CD or USB key
>> handy, and are willing to reboot, can you please do the following...
>>
>> 1) boot from the install ISO
>> 2) chroot to a running environment
>> 3) list the output from the 2 commands
>>  mount
>>  cat /etc/mtab
>>
>>   I'm getting absolutely no output at all from those 2 commands in the
>> install chroot.  That screws up the lilo ebuild install process.  I want
>> to check whether blank /etc/mtab is my fault or not.
>
> The installation handbook used to include a command to write /etc/mtab in the
> chroot by grepping the host mtab, but it's been removed and I haven't been
> able to find it. Meanwhile, I think it's standard behaviour for mtab not to be
> populated during the installation process.
>
> So I'd also be interested to hear from anyone who knows what mtab should
> contain.
>

/etc/mtab is practically outdated. It's supposed to contain the list
of currently
mounted filesystems and the corresponding options, to be updated by the mount
command when doing changes. You'll notice, of course, that this doesn't at all
sound anything like most of the files in /etc - that's because the
list of filesystems
in a modern Linux changes a lot more frequently than the original
Unixes. Instead
of a config file, /etc/mtab essentially holds system state, which is something
that is more appropriate for /var or /proc or /sys.

And that's what /etc/mtab today should contain. Linux automatically updates
/proc/self/mounts to hold what /etc/mtab used to hold, and a modern /etc/mtab
should essentially just be a symlink to that.

But of course, legacy. So the mount command will fail to function properly
if you are, for example, in a read-only filesystem, or in a chroot, or otherwise
in some situation where /etc/mtab was not updated by the mount command to
match the contents of /proc/self/mounts.

--
This email is:    [ ] actionable   [x] fyi        [ ] social
Response needed:  [ ] yes          [x] up to you  [ ] no
Time-sensitive:   [ ] immediate    [ ] soon       [x] none

Reply | Threaded
Open this post in threaded view
|

Re: Output of "mount" and "cat /etc/mtab" inside install chroot?

Tom H-4
In reply to this post by Peter Humphrey-3
On Sat, Apr 19, 2014 at 8:54 AM, Peter Humphrey <[hidden email]> wrote:

> On Saturday 19 Apr 2014 07:43:18 Walter Dnes wrote:
>>
>> I've got another thread going called...
>> "Strange behaviour with LILO on new install on old laptop". Before I
>> file a bug report, I want to check first whether it's my fault. Can
>> people here do me a favour? If you have a Gentoo install CD or USB key
>> handy, and are willing to reboot, can you please do the following...
>>
>> 1) boot from the install ISO
>> 2) chroot to a running environment
>> 3) list the output from the 2 commands
>> mount
>> cat /etc/mtab
>>
>> I'm getting absolutely no output at all from those 2 commands in the
>> install chroot. That screws up the lilo ebuild install process. I want
>> to check whether blank /etc/mtab is my fault or not.
>
> The installation handbook used to include a command to write /etc/mtab in the
> chroot by grepping the host mtab, but it's been removed and I haven't been
> able to find it. Meanwhile, I think it's standard behaviour for mtab not to be
> populated during the installation process.
>
> So I'd also be interested to hear from anyone who knows what mtab should
> contain.

I symlink "/proc/self/mounts" to "/etc/mtab".

But the handbook has "grep -v rootfs /proc/mounts > /etc/mtab".

Reply | Threaded
Open this post in threaded view
|

Re: Output of "mount" and "cat /etc/mtab" inside install chroot?

Walter Dnes
On Sat, Apr 19, 2014 at 10:24:17AM -0400, Tom H wrote

> I symlink "/proc/self/mounts" to "/etc/mtab".
>
> But the handbook has "grep -v rootfs /proc/mounts > /etc/mtab".

  I re-checked the AMD64 install docs in Firefox "{CTRL}F" "mtab" in...
http://www.gentoo.org/doc/en/handbook/handbook-amd64.xml?full=1

  The ***Default: Setting up GRUB using grub-install*** section has...

> Code Listing 4.5: Creating /etc/mtab
>
> # grep -v rootfs /proc/mounts > /etc/mtab

  The lilo install does not have these instructions, neither does grub-2,
just legacy grub.  I've installed Gentoo with lilo a lot of times over
the past several years (since November 2004), and I have never had to
tweak /etc/mtab.  This implies one of...

* either the behaviour of /etc/mtab has changed.
* or grepping "mount" output is a recent "new and improved feature" of
  the lilo ebuild.

--
Walter Dnes <[hidden email]>
I don't run "desktop environments"; I run useful applications

yac
Reply | Threaded
Open this post in threaded view
|

Re: Output of "mount" and "cat /etc/mtab" inside install chroot?

yac
In reply to this post by Peter Humphrey-3
On Sat, 19 Apr 2014 13:54:07 +0100
Peter Humphrey <[hidden email]> wrote:

> On Saturday 19 Apr 2014 07:43:18 Walter Dnes wrote:
> >   I've got another thread going called...
> > "Strange behaviour with LILO on new install on old laptop".  Before
> > I file a bug report, I want to check first whether it's my fault.
> > Can people here do me a favour?  If you have a Gentoo install CD or
> > USB key handy, and are willing to reboot, can you please do the
> > following...
> >
> > 1) boot from the install ISO
> > 2) chroot to a running environment
> > 3) list the output from the 2 commands
> >  mount
> >  cat /etc/mtab
> >
> >   I'm getting absolutely no output at all from those 2 commands in
> > the install chroot.  That screws up the lilo ebuild install
> > process.  I want to check whether blank /etc/mtab is my fault or
> > not.
>
> The installation handbook used to include a command to
> write /etc/mtab in the chroot by grepping the host mtab
It was part of grub-install, now grub legacy

https://www.gentoo.org/doc/en/handbook/handbook-amd64.xml?part=1&chap=10#doc_chap4

---
Jan Matějka        | Developer
https://gentoo.org | Gentoo Linux
GPG: A33E F5BC A9F6 DAFD 2021  6FB6 3EBF D45B EEB6 CA8B

signature.asc (501 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Output of "mount" and "cat /etc/mtab" inside install chroot?

Peter Humphrey-3
On Monday 21 Apr 2014 00:55:56 yac wrote:
> On Sat, 19 Apr 2014 13:54:07 +0100
> Peter Humphrey <[hidden email]> wrote:
> > The installation handbook used to include a command to
> > write /etc/mtab in the chroot by grepping the host mtab
>
> It was part of grub-install, now grub legacy
>
> https://www.gentoo.org/doc/en/handbook/handbook-amd64.xml?part=1&chap=10#doc
> _chap4

Yes, thanks, a couple of people posted what it says here the other day. Now
I'm puzzling over whether it's good advice.

For instance, suppose I want to reinstall the chroot in which I keep an image
of my Atom box here on my workstation. Then /etc/mtab has:
        /dev/md5 / [...]
but once I chroot into /mnt/atom, where the image lives, that's wrong and
should be:
        /dev/mapper/vg7-atom / [...]
because vg7-atom is now the root of the file system.

Does the handbook need an update? Or maybe it's right after all because when
grub runs its installer it's unconcerned with where it's invoked from.

[Wanders off stage-left, muttering and scratching his head...]

--
Regards
Peter


Reply | Threaded
Open this post in threaded view
|

Re: Output of "mount" and "cat /etc/mtab" inside install chroot?

Tom H-4
In reply to this post by Walter Dnes
On Sat, Apr 19, 2014 at 5:16 PM, Walter Dnes <[hidden email]> wrote:

> On Sat, Apr 19, 2014 at 10:24:17AM -0400, Tom H wrote
>>
>> I symlink "/proc/self/mounts" to "/etc/mtab".
>>
>> But the handbook has "grep -v rootfs /proc/mounts > /etc/mtab".
>
> I re-checked the AMD64 install docs in Firefox "{CTRL}F" "mtab" in...
> http://www.gentoo.org/doc/en/handbook/handbook-amd64.xml?full=1
>
> The ***Default: Setting up GRUB using grub-install*** section has...
>
>> Code Listing 4.5: Creating /etc/mtab
>>
>> # grep -v rootfs /proc/mounts > /etc/mtab
>
> The lilo install does not have these instructions, neither does grub-2,
> just legacy grub. I've installed Gentoo with lilo a lot of times over
> the past several years (since November 2004), and I have never had to
> tweak /etc/mtab. This implies one of...
>
> * either the behaviour of /etc/mtab has changed.
> * or grepping "mount" output is a recent "new and improved feature" of
> the lilo ebuild.

Sorry. I hadn't seen in which section the grep was.

Reply | Threaded
Open this post in threaded view
|

Re: Output of "mount" and "cat /etc/mtab" inside install chroot?

Walter Dnes
In reply to this post by Peter Humphrey-3
On Mon, Apr 21, 2014 at 09:38:44AM +0100, Peter Humphrey wrote

> On Monday 21 Apr 2014 00:55:56 yac wrote:
> > On Sat, 19 Apr 2014 13:54:07 +0100
> > Peter Humphrey <[hidden email]> wrote:
> > > The installation handbook used to include a command to
> > > write /etc/mtab in the chroot by grepping the host mtab
> >
> > It was part of grub-install, now grub legacy
> >
> > https://www.gentoo.org/doc/en/handbook/handbook-amd64.xml?part=1&chap=10#doc
> > _chap4
>
> Yes, thanks, a couple of people posted what it says here the other
> day. Now I'm puzzling over whether it's good advice.
>
> For instance, suppose I want to reinstall the chroot in which I keep
> an image of my Atom box here on my workstation. Then /etc/mtab has:
>         /dev/md5 / [...]
> but once I chroot into /mnt/atom, where the image lives, that's wrong and
> should be:
>         /dev/mapper/vg7-atom / [...]
> because vg7-atom is now the root of the file system.
>
> Does the handbook need an update? Or maybe it's right after all
> because when grub runs its installer it's unconcerned with where
> it's invoked from.
>
> [Wanders off stage-left, muttering and scratching his head...]

  *AFTER YOU CHROOT* what are the contents of /proc/self/mounts and
/proc/mounts ?  Can you copy either of them into /etc/mtab and have the
correct result?

--
Walter Dnes <[hidden email]>
I don't run "desktop environments"; I run useful applications

Reply | Threaded
Open this post in threaded view
|

Re: Output of "mount" and "cat /etc/mtab" inside install chroot?

Peter Humphrey-3
On Monday 21 Apr 2014 19:44:45 Walter Dnes wrote:

>   *AFTER YOU CHROOT* what are the contents of /proc/self/mounts and
> /proc/mounts ?  Can you copy either of them into /etc/mtab and have the
> correct result?

No, of course it's the same as outside the chroot, because before entering, I
do a 'mount -tproc proc /mnt/atom/proc'. I did check anyway to be sure.

--
Regards
Peter


Reply | Threaded
Open this post in threaded view
|

Re: Output of "mount" and "cat /etc/mtab" inside install chroot?

Tom H-4
In reply to this post by Walter Dnes
On Mon, Apr 21, 2014 at 7:44 PM, Walter Dnes <[hidden email]> wrote:

> On Mon, Apr 21, 2014 at 09:38:44AM +0100, Peter Humphrey wrote
>> On Monday 21 Apr 2014 00:55:56 yac wrote:
>>> On Sat, 19 Apr 2014 13:54:07 +0100
>>> Peter Humphrey <[hidden email]> wrote:
>>>>
>>>> The installation handbook used to include a command to
>>>> write /etc/mtab in the chroot by grepping the host mtab
>>>
>>> It was part of grub-install, now grub legacy
>>>
>>> https://www.gentoo.org/doc/en/handbook/handbook-amd64.xml?part=1&chap=10#doc
>>> _chap4
>>
>> Yes, thanks, a couple of people posted what it says here the other
>> day. Now I'm puzzling over whether it's good advice.
>>
>> For instance, suppose I want to reinstall the chroot in which I keep
>> an image of my Atom box here on my workstation. Then /etc/mtab has:
>>         /dev/md5 / [...]
>> but once I chroot into /mnt/atom, where the image lives, that's wrong and
>> should be:
>>         /dev/mapper/vg7-atom / [...]
>> because vg7-atom is now the root of the file system.
>>
>> Does the handbook need an update? Or maybe it's right after all
>> because when grub runs its installer it's unconcerned with where
>> it's invoked from.
>>
>> [Wanders off stage-left, muttering and scratching his head...]
>
> *AFTER YOU CHROOT* what are the contents of /proc/self/mounts and
> /proc/mounts ?  Can you copy either of them into /etc/mtab and have the
> correct result?

I duped a Gentoo VM on my laptop, launched it, and looked at the
output of "grep ' / ' /proc/mounts" in the "/mnt" chroot after
mounting "/mnt/proc" before and after the chroot, which is
unsurprisingly the same.

What are you trying to find out?

I haven't used lilo for 12 years at least. Does it operate using
"/proc/self/mounts" or "/etc/mtab"? mount/umount, for example, use
"/etc/mtab". grub-install, AFAIR, uses "/proc/self/mountinfo" as well
as the
"/sys/devices/" hierarchy.

localhost ~ # mount /dev/vdb1 /mnt

localhost ~ # mount -t proc proc /mnt/proc

localhost ~ # chroot /mnt

localhost / # grep ' / ' /proc/mounts
rootfs / rootfs rw 0 0
/dev/disk/by-uuid/fe087ffc-ccb6-48ce-a8f7-a3a6d0fb20e3 / xfs
rw,relatime,attr2,inode64,noquota 0 0
/dev/vdb1 / xfs rw,relatime,attr2,inode64,noquota 0 0

localhost / # exit
exit

localhost ~ # umount /mnt/proc

localhost ~ # chroot /mnt

localhost / # mount -t proc proc /proc

localhost / # grep ' / ' /proc/mounts
rootfs / rootfs rw 0 0
/dev/disk/by-uuid/fe087ffc-ccb6-48ce-a8f7-a3a6d0fb20e3 / xfs
rw,relatime,attr2,inode64,noquota 0 0
/dev/vdb1 / xfs rw,relatime,attr2,inode64,noquota 0 0

localhost / # exit
exit

localhost ~ # xfs_admin -u /dev/vda1
UUID = fe087ffc-ccb6-48ce-a8f7-a3a6d0fb20e3

localhost ~ #

Reply | Threaded
Open this post in threaded view
|

Re: Output of "mount" and "cat /etc/mtab" inside install chroot?

Jonathan Callen-2
In reply to this post by Peter Humphrey-3
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

On 04/22/2014 04:48 AM, Peter Humphrey wrote:
> On Monday 21 Apr 2014 19:44:45 Walter Dnes wrote:
>
>> *AFTER YOU CHROOT* what are the contents of /proc/self/mounts and /proc/mounts ?  Can you
>> copy either of them into /etc/mtab and have the correct result?
>
> No, of course it's the same as outside the chroot, because before entering, I do a 'mount
> -tproc proc /mnt/atom/proc'. I did check anyway to be sure.
>

You may want to check again: you likely won't see any /mnt/atom/* in /proc/mounts (which is a
symlink to /proc/self/mounts), as they will have their paths correctly output for inside the
chroot, but you *will* see mounts that only exist outside the chroot.  /proc/self/mountinfo will
only show mounts reachable from inside the chroot, but it is incompatible with the mtab format.
Newer versions of mount(8) will use /proc/self/mountinfo if it detects that the final target of
/etc/mtab (possibly /proc/self/mounts) is not writable.

- --
Jonathan Callen
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCgAGBQJTVzHvAAoJELHSF2kinlg41ssP/1JO8FTHrGt6NPZm39BvMOrm
GEAcQ5ZlHuzVjNc9lImYHrsiWpVXfikTqecR1P9sXZa98eZfrqXhlzpe+vZQxLu0
x/zki3wA29htlfvpRV+Bi8yieWVenNBhWkRq09nzLgglQWBsRFJUU+kIAtDX5Ynf
E2MmZsa6K7uhy1Lrg4LVyqEjb1671fVvphQiB1zvjIjWc08tEqB/v4BMPuODbtJS
Ame4AgvA89EFr0K1kw0NAOtxgmcpVjof1onwda8g6V84tIaq98279ratmM+knJFg
586+YKF9Ffd41twtYF3ANYgy9ruFLSZ/jlnV78IbH3FqPvzxqWmfNvET030Oq0q0
A67t4fwYO62PEwCcOlSnVLLfAQhFPKTv+Yqj1hI8l/64o52CHXIQzhnADJouw8aL
i4OBkYAaFDv/uQsydsa3hQ519OG058nQZ/Sr+AN1qyp6Axum9GFqOvIzMEHpEH4P
tb8Prvp+drNU+AC8uIEvCsaSSUC4wLpywwV23iAzrOQdG14SAkkz8Znrty1tSHc1
Y4lmiS4U9xRMGx1Mvz8Xat3yBOl/bRS0mAejKqjSDdZ+6Rtq1gZ7LhdBeG5Nokla
Kdx1JO+QvcQDDnIj64qq6Hq1MY3zu+WYRiacx7KvpsuyIDM+Pc6qCJaRYGYveWW9
aDWZ2siL8DaOwYeRT48L
=jgV4
-----END PGP SIGNATURE-----