<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<atom:link href="https://dev1galaxy.org/extern.php?action=feed&amp;tid=617&amp;type=rss" rel="self" type="application/rss+xml" />
		<title><![CDATA[Dev1 Galaxy Forum / How to setup a devuan libvirt-lxc container]]></title>
		<link>https://dev1galaxy.org/viewtopic.php?id=617</link>
		<description><![CDATA[The most recent posts in How to setup a devuan libvirt-lxc container.]]></description>
		<lastBuildDate>Sun, 21 May 2017 17:11:41 +0000</lastBuildDate>
		<generator>FluxBB</generator>
		<item>
			<title><![CDATA[How to setup a devuan libvirt-lxc container]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=1591#p1591</link>
			<description><![CDATA[<h5>Install libvirt</h5><div class="codebox"><pre><code>daniel@colibri:/# apt-get install libvirt-bin libvirt0 libvirt-daemon cgroupfs-mount</code></pre></div><h5>Bootstrap your devuan container</h5><div class="codebox"><pre><code>root@colibri:~# mkdir /vm
root@colibri:~# cd /vm
root@colibri:/vm# debootstrap jessie my_lxc_container http://auto.mirror.devuan.org/merged</code></pre></div><h5>(chroot) Some necessary configuration changes inside the new container</h5><p>For the next steps, you must chroot into your lxc container:</p><div class="codebox"><pre><code>root@colibri:/# chroot my_lxc_container/</code></pre></div><p>Make sure you don&#039;t perform any of the following steps outside the chroot!</p><h5>(chroot) Change the password</h5><div class="codebox"><pre><code>root@colibri:/# passwd
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully</code></pre></div><h5>(chroot) Set your language</h5><div class="codebox"><pre><code>root@colibri:/# apt-get install locales
root@colibri:/# dpkg-reconfigure locales</code></pre></div><h5>(chroot) Set the host name</h5><div class="codebox"><pre><code>root@colibri:/# echo &quot;Your-new-hostname&quot; &gt; /etc/hostname</code></pre></div><h5>(chroot) Disable spawning of non-existant consoles</h5><p>We&#039;ll only define one console later in libvirt, which will only create one tty, namely /dev/pts/0, but the container tries to spawn 6 consoles. To change this, we need to comment out all lines which look like &quot;:23:respawn:/sbin/getty&quot;. Only the first line shouldn&#039;t be commented out. The following command will do that for you:</p><div class="codebox"><pre><code>root@colibri:/# sed -i &#039;s|.:23:respawn:/sbin/getty|#\0|&#039; /etc/inittab</code></pre></div><h5>(chroot) Disable pam_loginuid.so</h5><p>pam_loginuid.so tries try to write to /proc/self/loginuid on login if it is enabled in the kernel, but it&#039;s mounted readonly in libvirt-lxc, which may cause the login attemp to fail. So we just comment it out:</p><div class="codebox"><pre><code>root@colibri:/# sed -i &#039;s/session    required     pam_loginuid.so/#\0/&#039; /etc/pam.d/*</code></pre></div><h5>(chroot) Allow libvirts&#039; console (/dev/pts/0) for logins</h5><p>Just add pts/0 to /etc/securetty:</p><div class="codebox"><pre><code>root@colibri:/# echo &#039;pts/0&#039; &gt;&gt; /etc/securetty</code></pre></div><h5>(chroot) Disable checksum offloading &amp; configure dhcp</h5><p>UDP-Checksum offloading may cause invalid UDP checksums, which may cause dhclient to fail. Disable it using ethtool and /etc/network/interfaces:</p><div class="codebox"><pre><code>root@colibri:/# apt-get install ethtool
root@colibri:/# cat &gt; /etc/network/interfaces &lt;&lt;EOF
source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp
  pre-up ethtool --offload eth0 rx off tx off

EOF</code></pre></div><p>You can now leave the changeroot using &quot;exit&quot; or CTRL+D.</p><h5>Create the XML Config for your libvirt-lxc container</h5><p>Here is an example config. The rest of this tutorial assums it to be in /var/virt/my_lxc_container.xml The following config assums that you want to use the network config &quot;default&quot; for this domain and your LXC Countainer root directory is at /vm/my_lxc_container/. You may need to start the default network first, or change/add/remove settings if you want a different configuration.</p><div class="codebox"><pre><code>&lt;domain type=&#039;lxc&#039;&gt;
  &lt;name&gt;my_lxc_container&lt;/name&gt;
  &lt;memory unit=&#039;GiB&#039;&gt;1&lt;/memory&gt;
  &lt;os&gt;
    &lt;type&gt;exe&lt;/type&gt;
    &lt;init&gt;/sbin/init&lt;/init&gt;
  &lt;/os&gt;
  &lt;vcpu&gt;1&lt;/vcpu&gt;
  &lt;features&gt;
    &lt;privnet/&gt;
  &lt;/features&gt;
  &lt;clock offset=&#039;utc&#039;/&gt;
  &lt;on_poweroff&gt;destroy&lt;/on_poweroff&gt;
  &lt;on_reboot&gt;restart&lt;/on_reboot&gt;
  &lt;on_crash&gt;destroy&lt;/on_crash&gt;
  &lt;devices&gt;
    &lt;filesystem type=&#039;mount&#039;&gt;
      &lt;source dir=&#039;/vm/my_lxc_container/&#039; /&gt;
      &lt;target dir=&#039;/&#039; /&gt;
    &lt;/filesystem&gt;
    &lt;interface type=&#039;network&#039;&gt;
      &lt;mac address=&#039;00:f0:12:34:56:78&#039;/&gt;
      &lt;source network=&#039;default&#039;/&gt;
    &lt;/interface&gt;
    &lt;console type=&#039;pty&#039; /&gt;
  &lt;/devices&gt;
&lt;/domain&gt;</code></pre></div><h5>Define the domain for your libvirt LXC container using your XML config</h5><div class="codebox"><pre><code>root@colibri:/vm# virsh -c lxc:/// define /var/virt/my_lxc_container.xml
Domain my_lxc_container defined from /var/virt/my_lxc_container.xml</code></pre></div><h5>Start your default network interface &amp; set it as autostart</h5><div class="codebox"><pre><code>root@colibri:/vm# virsh net-start default
root@colibri:/vm# virsh net-autostart default
Network default marked as autostarted</code></pre></div><h5>Start your container</h5><div class="codebox"><pre><code>root@colibri:/vm# virsh -c lxc:/// start my_lxc_container
Domain my_lxc_container started</code></pre></div><h5>Open the console of your Container and login</h5><div class="codebox"><pre><code>root@colibri:/vm# virsh -c lxc:/// console my_lxc_container</code></pre></div><p>Congratulations, you just configured your first libvirt-lxc container.</p>]]></description>
			<author><![CDATA[dummy@example.com (Daniel Abrecht)]]></author>
			<pubDate>Sun, 21 May 2017 17:11:41 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=1591#p1591</guid>
		</item>
	</channel>
</rss>
