[Lxc-users] Regarding creating a LXC container in fedora 17

Shridhar Daithankar ghodechhap at ghodechhap.net
Sun May 19 03:56:59 UTC 2013


On Saturday, May 18, 2013 04:06:30 PM Michael H. Warfield wrote:
> On Sun, 2013-05-19 at 00:02 +0530, Shridhar Daithankar wrote:
> > I ran into the same lxc-console issue and managed to solve it by
> > commenting
> > out ConditionPathExists line in
> > /etc/systemd/system/getty.target.wants/getty\@tty1.service
> > 
> > first I had to start the container in foreground, login, comment out
> > aforementioned line and restart it in daemon mode. After that lxc-console
> > worked.
> > 
> > If I changed the systemd unit from the chroot itself, it didn't reflect
> > somehow. Also the line referred to /dev/tty0 but only /dev/tty and
> > /dev/tty1 were available in the container.
> > 
> > I don't understand systemd enough to comment on the reasons of it working
> > or not-working. I just experimented around to get a working tty.
> 
> Oh, I understand why it's working and that's VERY interesting.  I hadn't
> dug into that realm of the systemd files as yet.  They're using the mere
> existence of /dev/tty0 as a logic switch to determine if they are going
> to start a getty on %I (/dev/tty1 in this case).  Which is yet another
> case of them burying a magic cookie switch in the logic.  They
> conditionalize it on a hard coded /dev/tty0 but then start a getty
> "/sbin/agetty --noclear %I 38400".  the %I is the unit name.  Cute.
> Cheeky bastards.
> 
> So, it basically means that if we create a tty0 under autodev, that
> should then enable any listed vty consoles we set up using systemd
> links.  That could be a key to making that work without modifying files
> in the container but would require a (relatively minor but non trivial)
> change to the lxc source code, as opposed to merely a template.  I'll
> run this up the flagpole on the -devel list and with Serge and get their
> opinions.  This is doable.  I think I'll try this out in my sources
> first and then post a request for comments over on -devel.  The problem
> is in the routine "setup_tty" in conf.c that's going to need some
> massaging to make it 0 based instead of 1 based and adjust for the
> additional tty count.  :-/

digging a bit deeper in this and quoting from

http://www.freedesktop.org/software/systemd/man/systemd-getty-generator.html
and http://0pointer.de/blog/projects/serial-console.html

It looks like systemd is generating that unit file on demand during boot(thats 
why editing it before starting the container did not work for me) and it is 
looking into /sys/class/tty/console/active which indeed reports tty0 inside a 
container.

So the real question is how can lxc/kernel make the container report tty1
there so that systemd would work out of the box.

or.. as you have proposed, lxc could expose tty0.


-- 
Regards
 Shridhar




More information about the lxc-users mailing list