Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 516780 - app-emulation/lxc-1.0.4 - /usr/share/lxc/templates/lxc-gentoo ? (x 4?)
Summary: app-emulation/lxc-1.0.4 - /usr/share/lxc/templates/lxc-gentoo ? (x 4?)
Status: RESOLVED INVALID
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Diego Elio Pettenò (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-07-09 15:56 UTC by Joakim Tjernlund
Modified: 2014-07-22 18:43 UTC (History)
5 users (show)

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


Attachments
Quick fix to improve usability (lxc-gentoo.diff,2.85 KB, patch)
2014-07-10 10:42 UTC, Joakim Tjernlund
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Joakim Tjernlund 2014-07-09 15:56:41 UTC
Decided to take lxc for a spin as I never tried it before. Took a  while
to figure out how to use teh gentoo template. Eventually I made a script
which illustrates the problems:

lxc_name=lxc_test2
lxc_rootfs=/jocke/roofs #defaults to /rootfs, perhaps not the bets place

#must create dir for rootfs and config or template BUGS
mkdir -p "${lxc_rootfs}"

#--path should default to this instead
mkdir -p /etc/lxc/"${lxc_name}"

#template suggested I added this
echo 'lxc.network.type = veth' > /etc/lxc/"${lxc_name}"/config
echo 'lxc.network.link = virbr0' >> /etc/lxc/"${lxc_name}"/config
echo 'lxc.network.flags = up' >> /etc/lxc/"${lxc_name}"/config
echo 'lxc.network.hwaddr = fe:11:22:33:44:55' >> /etc/lxc/"${lxc_name}"/config


/usr/share/lxc/templates/lxc-gentoo --password=root --name="${lxc_name}" --path=/etc/lxc/"${lxc_name}" --rootfs="${lxc_rootfs}"

## After template has create lxc_test2 it says:
#You could now use you container with: lxc-start -n lxc_test2

## That should be:
#You could now use you container with: lxc-start -n lxc_test2 -f /etc/lxc/"${lxc_name}"/config
Comment 1 Joakim Tjernlund 2014-07-09 15:59:17 UTC
Forgot one thing, if you dont supplay a --name , then the script errors out
with a mysterious error msg instead of a nice err msg telling you --name is
mandatory
Comment 2 Jeroen Roovers (RETIRED) gentoo-dev 2014-07-10 00:25:16 UTC
1) Please post your `emerge --info' output in a comment.
2) Please explain the steps you took exactly, by reproducing both the commands and their output in order of appearance, pointing out the precise issue along the way.
Comment 3 Joakim Tjernlund 2014-07-10 07:57:45 UTC
jocke@gentoo-jocke ~ $ emerge --info
Portage 2.2.10 (default/linux/amd64/13.0/desktop/gnome, gcc-4.7.3, glibc-2.17-r1, 3.12.21 x86_64)
=================================================================
System uname: Linux-3.12.21-x86_64-Intel-R-_Core-TM-_i7-2600_CPU_@_3.40GHz-with-gentoo-2.2
KiB Mem:    12308048 total,   1083820 free
KiB Swap:    4194300 total,   4103120 free
Timestamp of tree: Wed, 09 Jul 2014 15:45:01 +0000
ld GNU ld (GNU Binutils) 2.23.2
app-shells/bash:          4.2_p45
dev-java/java-config:     2.2.0
dev-lang/python:          2.7.7, 3.3.5, 3.4.1
dev-util/cmake:           2.8.12.2
dev-util/pkgconfig:       0.28-r1
sys-apps/baselayout:      2.2
sys-apps/openrc:          0.12.4
sys-apps/sandbox:         2.6-r1
sys-devel/autoconf:       2.13, 2.69
sys-devel/automake:       1.10.3, 1.11.6, 1.12.6, 1.13.4
sys-devel/binutils:       2.23.2
sys-devel/gcc:            4.5.4, 4.7.3-r1
sys-devel/gcc-config:     1.7.3
sys-devel/libtool:        2.4.2
sys-devel/make:           3.82-r4
sys-kernel/linux-headers: 3.12 (virtual/os-headers)
sys-libs/glibc:           2.17-r1::transmode
Repositories: gentoo transmode
ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="* -@EULA PUEL dlj-1.1 Oracle-BCLA-JavaSE AdobeFlash-11.x google-chrome"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -pipe -march=native"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /etc/entropy /usr/share/gnupg/qualified.txt /var/lib/hsqldb"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php5.5/ext-active/ /etc/php/cgi-php5.5/ext-active/ /etc/php/cli-php5.5/ext-active/ /etc/portage/package.keywords/zzzautounmask /etc/portage/package.unmask/zzzautounmask /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-O2 -pipe -march=native"
DISTDIR="/usr/portage/distfiles"
EMERGE_DEFAULT_OPTS="--quiet --jobs=8 --backtrack 1"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync news parallel-fetch preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="http://devsrv.transmode.se/portage http://devsrv.transmode.se/portage/local http://ftp.df.lth.se/pub/gentoo"
LANG="en_GB.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j9 -s"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/var/lib/layman/transmode"
SYNC="rsync://devsrv.transmode.se/portage"
USE="X a52 aac acl acpi ads alsa amd64 bash-completion berkdb bluetooth branding bzip2 cairo cdda cdr cli colord consolekit cracklib crypt cups cxx dbus device-mapper dhcpcd dri dts dvd dvdr eds emacs emboss encode evo exif fam ffmpeg firefox flac fontconfig fortran gdbm gif gnome gnome-keyring gnome-online-accounts gnutls gpm gstreamer gtk iconv icu infinality introspection ipv6 java jpeg kerberos kvm lcms ldap libnotify libsecret mad meanwhile mmx mng modules mp3 mp4 mpeg multilib nautilus ncurses networkmanager nis nls nptl ogg opengl openmp pam pango pcre pdf pdfimport perl png policykit ppds pulseaudio python qemu qt3support readline resolvconf samba sdl secure-delete session socialweb spell spice sqlite sse sse2 sse3 sse4 sse4_1 ssl ssse3 startup-notification subversion svg system-cairo system-icu system-jpeg system-sqlite tcpd tiff truetype udev udisks unicode upcall upower urandom usb virt-network virtualbox vorbis webdav winbind wxwidgets x264 xcb xinerama xml xv xvid zlib" ABI_X86="64" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="evdev synaptics" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="pdfimport" LINGUAS="en sv" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-4" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7 python3_3" QEMU_SOFTMMU_TARGETS="i386 x86_64 ppc" QEMU_USER_TARGETS="i386 x86_64 ppc" RUBY_TARGETS="ruby19 ruby20" USERLAND="GNU" VIDEO_CARDS="intel radeon" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
USE_PYTHON="2.7 3.3"
Unset:  CPPFLAGS, CTARGET, INSTALL_MASK, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS

jocke@gentoo-jocke ~ $
Comment 4 Joakim Tjernlund 2014-07-10 08:01:33 UTC
1) Cryptic error msg

gentoo-jocke ~ # /usr/share/lxc/templates/lxc-gentoo
### set_default_arch: default arch/variant autodetect...
 => Got: arch=amd64 variant=amd64
Attempting to obtain an exclusive lock (timeout: 60 sec) named "cache-amd64-amd64"...
 => done.
 => Executing "do_all"
##### container_setup(): starting container setup
### container_precheck(): doing some pre-start checks ...

[the last exit code leading to this death was: 1 ]
$name () IS EMPTY OR MADE OF ONLY DIRECTORY SEPERATORS, THIS IS *VERY* BAD!
Comment 5 Joakim Tjernlund 2014-07-10 08:03:52 UTC
2) fixing 1), you get next cryptic error msg

gentoo-jocke ~ # /usr/share/lxc/templates/lxc-gentoo --name=lxc_test2
### set_default_arch: default arch/variant autodetect...
 => Got: arch=amd64 variant=amd64
Attempting to obtain an exclusive lock (timeout: 60 sec) named "cache-amd64-amd64"...
 => done.
 => Executing "do_all"
##### container_setup(): starting container setup
### container_precheck(): doing some pre-start checks ...
#### container_rootfs(): copying rootfs /rootfs from cache /var/cache/lxc/gentoo/rootfs-amd64-amd64 ...
tar: /rootfs: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now

[the last exit code leading to this death was: 2 ]
Comment 6 Joakim Tjernlund 2014-07-10 08:09:15 UTC
3) After fixing 2):
  gentoo-jocke ~ # mkdir /rootfs
you get:
 
gentoo-jocke ~ # /usr/share/lxc/templates/lxc-gentoo --name=lxc_test2
### set_default_arch: default arch/variant autodetect...
 => Got: arch=amd64 variant=amd64
Attempting to obtain an exclusive lock (timeout: 60 sec) named "cache-amd64-amd64"...
 => done.
 => Executing "do_all"
##### container_setup(): starting container setup
### container_precheck(): doing some pre-start checks ...
#### container_rootfs(): copying rootfs /rootfs from cache /var/cache/lxc/gentoo/rootfs-amd64-amd64 ...
chroot test... OK
 => done
#### container_consoles(): setting container consoles ...
 => main console + 1 ttys
 => done
#### container_tz(): setting container timezone ...
 => host localtime copyed to container
#### container_portage(): setting container portage... 
Warnings are normal here, don't worry
!!! Section 'gentoo' in repos.conf has location attribute set to nonexistent directory: '/usr/portage'
!!! Section 'x-portage' in repos.conf has location attribute set to nonexistent directory: '/usr/portage'
!!! Invalid Repository Location (not a dir): '/usr/portage'
!!! Section 'x-portage' in repos.conf has location attribute set to nonexistent directory: '/usr/portage'
!!! Section 'gentoo' in repos.conf has location attribute set to nonexistent directory: '/usr/portage'
!!! Invalid Repository Location (not a dir): '/usr/portage'
trying to guess portage_dir from host...
 => portage stuff done, see /etc/portage/make.conf for additionnal tricks
container_net(): setting container network conf... 
#### container_hostname(): setting hostname... 
 => done.
#### container_auth(): setting authentification... 
 setting password for root ...
BAD PASSWORD: it is too short
BAD PASSWORD: is too simple
  => done. if you didn't specify , default is 'toor'
 => done.
#### container_sshd(): enabling sshd... 
 * service sshd added to runlevel sysinit
 => done.
container_configuration(): making lxc configuration file... 
 => done.
###### container_setup(): container should be ready to start!


You could now use you container with: lxc-start -n lxc_test2
little things you should know about your container:
=> rootfs of container is : /rootfs
=> config of container is : /config
=> timezone was staticly copyed from host
=> container has a shared portage from host's /usr/portage to usr/portage
=> No network interface for this container
It's a pitty, you have bridge, virbr0.
If it is for Lxc, use it next time by adding this to your default.conf :
lxc.network.type = veth
lxc.network.link = virbr0
lxc.network.flags = up
lxc.network.hwaddr = fe:xx:xx:xx:xx:xx
=> Connection user is root
=> root has the default password 'toor', please change it ASAP

------------------------
Above says:
  You could now use you container with: lxc-start -n lxc_test2
doing so:gentoo-jocke ~ # lxc-start -n lxc_test2
lxc-start: Executing '/sbin/init' with no configuration file may crash the host
Comment 7 Joakim Tjernlund 2014-07-10 08:15:16 UTC
4) to fix 3) you have figure out that msg is wrong, it should say:
 You could now use you container with: lxc-start -n lxc_test2 -f /config

gentoo-jocke ~ # lxc-start -n lxc_test2 -f /config
INIT: version 2.88 booting

   OpenRC 0.12.4 is starting up Gentoo Linux (x86_64)

 * Mounting /proc ... [ ok ]
 * Mounting /run ... * /run/openrc: creating directory
 * /run/lock: creating directory
 * /run/lock: correcting owner
 * Caching service dependencies ... [ ok ]
 * Mounting /dev/mqueue ... [ ok ]
 * Mounting /dev/shm ... [ ok ]
 * Creating list of required static device nodes for the current kernel ...Warning: /lib/modules/3.12.21/modules.devname not found - ignoring
 [ ok ]
ssh-keygen: generating new host keys: RSA1 RSA DSA ED25519 
 * Starting sshd ... [ ok ]
 * setting up tmpfiles.d entries for /dev ... [ ok ]
 * Creating user login records ... [ ok ]
 * Wiping /tmp directory ... [ ok ]
 * Bringing up network interface lo ... [ ok ]
 * Updating /etc/mtab ... [ ok ]
 * setting up tmpfiles.d entries ... [ ok ]
INIT: Entering runlevel: 3
 * Starting local
 [ ok ]


This is lxc_test2. (Linux x86_64 3.12.21) 10:10:58

lxc_test2 login:

--------------------------

Finally I have Gentoo's Template LXC running. It did take quite a long time to
figure out what to do since the error info from 
/usr/share/lxc/templates/lxc-gentoo is very terse.

Now I am done, please forward this to the LXC maintainer.
Comment 8 Joakim Tjernlund 2014-07-10 10:42:59 UTC
Created attachment 380544 [details, diff]
Quick fix to improve usability

This is improves the template creation for me.
Comment 9 Fedja Beader 2014-07-11 10:42:25 UTC
You can try the original lxc-gentoo template at https://github.com/globalcitizen/lxc-gentoo and join #gentoo-containers on freenode.

By default, LXC expects all container to be in some default directory (/var/lxc/somethinsomething?) where --name can find them.

LXC is notorious for cryptic and unhelpful error messages and all this is worsened by the fact that all LXC developers I know are ubuntu ones, thus support for Gentoo is lacking (though it usually works out of the box). But we are working on it.
Comment 10 Joakim Tjernlund 2014-07-13 14:54:44 UTC
I found out that one should use lxc-create -t gentoo instead of manually running
lxc-gentoo.
This will deal with a few shortcomings of this script.
I do wonder who manages the gentoo template? I figured gentoo did
but maybe upstream does?

I can think of a few improvents I would like to add.
Like creating a ppc container on am64, this works with a tweaks to the
chroot invocation.
See https://bugs.gentoo.org/show_bug.cgi?id=516454
Comment 11 Markos Chandras (RETIRED) gentoo-dev 2014-07-22 18:43:13 UTC
(In reply to Joakim Tjernlund from comment #10)
> I found out that one should use lxc-create -t gentoo instead of manually
> running
> lxc-gentoo.
> This will deal with a few shortcomings of this script.
> I do wonder who manages the gentoo template? I figured gentoo did
> but maybe upstream does?
> 
> I can think of a few improvents I would like to add.
> Like creating a ppc container on am64, this works with a tweaks to the
> chroot invocation.
> See https://bugs.gentoo.org/show_bug.cgi?id=516454

the template is managed upstream. Please open a bug to the lxc github issue tracker.

https://github.com/lxc/lxc/issues

As far as I understand there is nothing for us to do here right? And there is not a real bug so closing this as invalid