Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 496054 - stage3 - add /dev/shm and /dev/pts
Summary: stage3 - add /dev/shm and /dev/pts
Status: RESOLVED NEEDINFO
Alias: None
Product: Gentoo Release Media
Classification: Unclassified
Component: Stages (show other bugs)
Hardware: All Linux
: Normal enhancement (vote)
Assignee: Gentoo's Team for Core System packages
URL: http://www.gentoo.org/doc/en/handbook...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-12-26 09:00 UTC by Guillaume ZITTA
Modified: 2014-08-01 10:45 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Guillaume ZITTA 2013-12-26 09:00:16 UTC
stage3 and openrc did great job for out-of-the-box compatibility of gentoo running in a conatiner.

that said, /dev/pts and /dev/shm dirs are still missing.
We still need to create them in our scripts.

I'm writing a lxc template for gentoo.
LXC and the ability for every one to run gentoo in seconds is great opportunity to propote our favorite distribution.

/dev/pts and /dev/shm are really often used even on bare-metal machines, could you add them to standard stage3 ?

Reproducible: Always
Comment 1 Jeroen Roovers (RETIRED) gentoo-dev 2013-12-26 16:10:54 UTC
Couldn't you simply mount --bind /dev to /path/to/chroot/dev?

= Mounting the necessary Filesystems
...
# mount --rbind /dev /mnt/gentoo/dev
Comment 2 Guillaume ZITTA 2013-12-26 16:57:10 UTC
Sorry, I think we misunderstand.

Nowadays /dev/shm and /dev/pts are standard entries of /dev like /dev/null.
every distribution have them in /dev, even LFS does.

A Linux container has is own /dev, it's not a chroot.
Container creation script or the container itself don't mount bind /dev.

I'm not just installing gentoo in a container, I'm writing the creation script in order to propose it to LXC team for inclusion.

Gentoo his perhaps the most LXC compliant distribution and is not available in LXC :(

OpenRC is mostly LXC compliant.
Stage3 is only missing 2 dirs to be LXC compliant.

If my work is accepted, anyone having post-2013 modern linux will have the opportunity to try gentoo in 2 commands.

So please add these 2 dirs, they are well-known, lxc-gentoo template will be cleaner.

Thanks
Comment 3 Jorge Manuel B. S. Vicetto (RETIRED) Gentoo Infrastructure gentoo-dev 2013-12-26 19:17:13 UTC
@base-system:

something to add to baselayout?
Comment 4 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2013-12-26 19:28:15 UTC
Both /etc/init.d/devfs and /etc/init.d/udev-mount already create & mount these directories as needed.

If the devfs script is safe for lxc, then we can remove the -lxc keyword for you.
Comment 5 SpanKY gentoo-dev 2013-12-26 22:30:47 UTC
yeah i'm not following.  why does lxc have a static /dev ?  why isn't it dynamic and use something like devtmpfs ?

if it is dynamic, then it should be using a script to create those dirs when they get booted up.
Comment 6 Guillaume ZITTA 2013-12-27 07:51:39 UTC
(In reply to Robin Johnson from comment #4)
> Both /etc/init.d/devfs and /etc/init.d/udev-mount already create & mount
> these directories as needed.
> 
> If the devfs script is safe for lxc, then we can remove the -lxc keyword for
> you.

Usualy it's lxc-start command who mounts this kind of things (dev/pts and dev/shm) but .
But I don't like lxc to manage to much things for the distribution.

I think removing "-lxc" keyword for devfs couldn't hurt.
if lxc-create did the mount already, init.d/devfs does nothing

for udev, I don't use it in my personnal containers, I'll study that (tests and see how other distro manage it), stay tuned...
Comment 7 Guillaume ZITTA 2013-12-27 16:56:59 UTC
for dev/pts, lxc-create mount it him self beforce launching init (and any kind ou udev stuff):
  https://github.com/lxc/lxc/blob/master/src/lxc/conf.c#L1566

One alternative is to give lxc the complete control over /dev management, but I think it's to much power for him :) gentoo's users like keeping control.

So we need /dev/pts to be present before init process is launched.

For udev other distro like debian con't use it in containers and it works perfectly in gentoo like this, We should let it like this.

For /dev/shm, init.d/devfs does it's job like a sharm :
- mounts /dev/shm and /dev/mqueue with mkdirs
- does nothing about /dev/pts because lxc already does

To resume, my proposal :
- add /dev/pts to stage3 
- remove -lxc keyword from init.d/devfs

Regards

If you want to see the template, https://github.com/gza/lxc-gentoo-template
Comment 8 Piotr Karbowski (RETIRED) gentoo-dev 2013-12-27 17:04:04 UTC
Regular, aka non-container, gentoo does mount either devtmpfs or tmpfs on /dev. Providing /dev/pts beside basic nodes is not needed bloat in my very opinion. If your's lxc scripts/templates require it, then add an extra mkdir there.

Whatsoever I also see no reason why lxc container would need a full-blown /dev or udev there, it's really not wise to let lxc access block devices and such, so basic nodes + devpts and shm is enough.
Comment 9 Guillaume ZITTA 2013-12-27 17:26:55 UTC
(In reply to Piotr Karbowski from comment #8)
> Regular, aka non-container, gentoo does mount either devtmpfs or tmpfs on
> /dev. Providing /dev/pts beside basic nodes is not needed bloat in my very
> opinion. If your's lxc scripts/templates require it, then add an extra mkdir
> there.
I did it already as a workaround. I use gentoo in LXC since 4 years I don't need this for me.

Whats going on here is not about how to script a lot to make gentoo working in a container.
It's about showing to the world how polyvalent gentoo is.

OpenRC already made their code LXC compliant (still little things but most of the is done).
I think it's a pity that gentoo itself is not compliant because of one missing directory in stage3 :(
> 
> Whatsoever I also see no reason why lxc container would need a full-blown
> /dev or udev there, it's really not wise to let lxc access block devices and
> such, so basic nodes + devpts and shm is enough.
+1 this is why I don't like the idea of dynamic dev in lxc
btw access to block and character devices is filtered by cgroups.
Comment 10 Jorge Manuel B. S. Vicetto (RETIRED) Gentoo Infrastructure gentoo-dev 2014-06-03 02:17:58 UTC
Is there anything we can do about this bug? Is there any point for release to stay CCed or should we be added again when a solution is found?
Comment 11 SpanKY gentoo-dev 2014-08-01 10:45:52 UTC
i'm not sure what you're looking for here.  adding those dirs to a stage3 root won't help because we mount /dev before we do anything else (it might be tmpfs or devtmpfs or something else).  at that point, anything that exists in /dev is now gone.

when a container starts, it needs a fully seeded /dev.  either you can manually provide one (like with static-dev), or you can do the same mounts as the rest of the system.  in the latter case, the dirs will still need to be created on the fly.