<?xml version="1.0" encoding="UTF-8"?>

<rss version="2.0"
 xmlns:blogChannel="http://backend.userland.com/blogChannelModule"
>

<channel>
<title><![CDATA[Dobrica Pavlinušić's random unstructured stuff: LXC]]></title>
<link>https://saturn.ffzg.hr/rot13/index.cgi?lxc</link>
<description></description>
<pubDate>Wed, 18 May 2011 07:12:31 -0000</pubDate>
<webMaster>root@saturn.ffzg.hr</webMaster>
<generator>Socialtext Workspace v2.19.0.2</generator>

<item>
<title><![CDATA[LXC]]></title>
<link>https://saturn.ffzg.hr/rot13/index.cgi?lxc</link>
<description><![CDATA[<div>Creator: Dobrica Pavlinušić</div><hr/><div class="wiki">
<span class="nlw_phrase"><img alt="linux-containers.png" src="https://saturn.ffzg.hr/rot13/index.cgi/linux-containers.png?action=attachments_download;page_name=lxc;id=20110518071231-0-24684" /><!-- wiki: {image: linux-=containers.png} --></span><br /><br /><p>
This are notes for my LXC workshop, in state of flux</p>
<div class="nlw_phrase"><table class="wafl_container">
  <tr>
    <td>
      <div class="wafl_box">
        
          <div class="wafl_titlebox">
            <div class="wafl_title">
              
                Contents: [Dobrica Pavlinušić's random unstructured stuff]
              
            </div>
          </div>
          <div class="wafl_items">
            
              <div class="wiki">
<ul>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#cgroups">Dobrica Pavlinušić's random unstructured stuff (Cgroups)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] Cgroups} --></span></li>

<ul>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#systemd">Dobrica Pavlinušić's random unstructured stuff (Systemd)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] Systemd} --></span></li>
</ul>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#lxc">Dobrica Pavlinušić's random unstructured stuff (LXC)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] LXC} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#lxc_inside_kvm_for_testing">Dobrica Pavlinušić's random unstructured stuff (LXC inside KVM for testing)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] LXC inside KVM for testing} --></span></li>

<ul>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#setup_kvm_lxc_test_machine">Dobrica Pavlinušić's random unstructured stuff (setup KVM LXC test machine)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] setup KVM LXC test machine} --></span></li>

<ul>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#step_1_create_a_root_filesystem_for_the_kvm_system">Dobrica Pavlinušić's random unstructured stuff (Step 1: Create a root filesystem for the KVM system.)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] Step 1: Create a root filesystem for the KVM system.} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#step_2_build_a_kernel_for_kvm_with_container_support">Dobrica Pavlinušić's random unstructured stuff (Step 2: Build a kernel for KVM, with container support.)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] Step 2: Build a kernel for KVM, with container support.} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#step_3_boot_the_result_under_qemu_or_kvm">Dobrica Pavlinušić's random unstructured stuff (Step 3: Boot the result under QEMU or KVM)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] Step 3: Boot the result under QEMU or KVM} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#step_4_ssh_into_the_kvm_instance">Dobrica Pavlinušić's random unstructured stuff (Step 4: ssh into the KVM instance.)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] Step 4: ssh into the KVM instance.} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#step_5_set_up_a_simple_busybox_based_container_under_the_kvm_system">Dobrica Pavlinušić's random unstructured stuff (Step 5: Set up a simple busybox-based container under the KVM system.)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] Step 5: Set up a simple busybox-=based container under the KVM system.} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#step_6_launch_the_container">Dobrica Pavlinušić's random unstructured stuff (Step 6: Launch the container)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] Step 6: Launch the container} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#step_7_stop_the_container_and_the_kvm_system">Dobrica Pavlinušić's random unstructured stuff (Step 7: Stop the container, and the KVM system.)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] Step 7: Stop the container, and the KVM system.} --></span></li>
</ul>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#setup_networking">Dobrica Pavlinušić's random unstructured stuff (Setup networking)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] Setup networking} --></span></li>

<ul>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#step_1_add_a_tap_interface_to_the_laptop">Dobrica Pavlinušić's random unstructured stuff (Step 1: Add a TAP interface to the Laptop.)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] Step 1: Add a TAP interface to the Laptop.} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#step_2_launch_kvm_with_two_ethernet_interfaces">Dobrica Pavlinušić's random unstructured stuff (Step 2: Launch KVM with two ethernet interfaces.)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] Step 2: Launch KVM with two ethernet interfaces.} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#step_3_set_up_a_new_container_in_the_kvm_system">Dobrica Pavlinušić's random unstructured stuff (Step 3: Set up a new container in the KVM system.)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] Step 3: Set up a new container in the KVM system.} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#step_4_fun_with_routing">Dobrica Pavlinušić's random unstructured stuff (Step 4: Fun with routing.)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] Step 4: Fun with routing.} --></span></li>
</ul></ul>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#network_hints">Dobrica Pavlinušić's random unstructured stuff (network hints)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] network hints} --></span></li>

<ul>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#prepare_host_machine">Dobrica Pavlinušić's random unstructured stuff (prepare host machine)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] prepare host machine} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#macvlan">Dobrica Pavlinušić's random unstructured stuff (macvlan)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] macvlan} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#veth">Dobrica Pavlinušić's random unstructured stuff (veth)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] veth} --></span></li>

<ul>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#host_only_bridge">Dobrica Pavlinušić's random unstructured stuff (host-only bridge)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] host-=only bridge} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#pseudo_random_mac">Dobrica Pavlinušić's random unstructured stuff (pseudo-random mac?)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] pseudo-=random mac?} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#slow_network">Dobrica Pavlinušić's random unstructured stuff (slow network?)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] slow network?} --></span></li>
</ul>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#phys">Dobrica Pavlinušić's random unstructured stuff (phys)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] phys} --></span></li>
</ul>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#limit_container_resources">Dobrica Pavlinušić's random unstructured stuff (limit container resources)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] limit container resources} --></span></li>

<ul>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#cpuset_cpus">Dobrica Pavlinušić's random unstructured stuff (cpuset.cpus)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] cpuset.cpus} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#cpu_shares">Dobrica Pavlinušić's random unstructured stuff (cpu.shares)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] cpu.shares} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#memory">Dobrica Pavlinušić's random unstructured stuff (memory)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] memory} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#disk">Dobrica Pavlinušić's random unstructured stuff (disk)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] disk} --></span></li>

<ul>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#usage">Dobrica Pavlinušić's random unstructured stuff (usage)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] usage} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#limit_disk_bandwith_using_cgroup_blkio">Dobrica Pavlinušić's random unstructured stuff (limit disk bandwith using cgroup blkio)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] limit disk bandwith using cgroup blkio} --></span></li>
</ul>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#network">Dobrica Pavlinušić's random unstructured stuff (network)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] network} --></span></li>
</ul>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#lxc_commands">Dobrica Pavlinušić's random unstructured stuff (LXC commands)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] LXC commands} --></span></li>

<ul>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#lxc_create">Dobrica Pavlinušić's random unstructured stuff (lxc-create)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] lxc-=create} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#lxc_execute">Dobrica Pavlinušić's random unstructured stuff (lxc-execute)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] lxc-=execute} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#lxc_attach">Dobrica Pavlinušić's random unstructured stuff (lxc-attach)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] lxc-=attach} --></span></li>
</ul>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#devices">Dobrica Pavlinušić's random unstructured stuff (devices)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] devices} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#monitoring">Dobrica Pavlinušić's random unstructured stuff (monitoring)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] monitoring} --></span></li>

<ul>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#htop">Dobrica Pavlinušić's random unstructured stuff (htop)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] htop} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#procfs">Dobrica Pavlinušić's random unstructured stuff (procfs)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] procfs} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#debugging">Dobrica Pavlinušić's random unstructured stuff (debugging)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] debugging} --></span></li>
</ul>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#kernel_patches">Dobrica Pavlinušić's random unstructured stuff (kernel patches)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] kernel patches} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#are_we_in_container">Dobrica Pavlinušić's random unstructured stuff (Are we in container?)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] Are we in container?} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#32_bit_guest_on_64_bit_kernel">Dobrica Pavlinušić's random unstructured stuff (32-bit guest on 64-bit kernel)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] 32-=bit guest on 64-=bit kernel} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#container_tweaks">Dobrica Pavlinušić's random unstructured stuff (Container tweaks)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] Container tweaks} --></span></li>

<ul>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#udev">Dobrica Pavlinušić's random unstructured stuff (udev)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] udev} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#nfs">Dobrica Pavlinušić's random unstructured stuff (nfs)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] nfs} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#chromium">Dobrica Pavlinušić's random unstructured stuff (chromium)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] chromium} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#pam">Dobrica Pavlinušić's random unstructured stuff (pam)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] pam} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#x_server">Dobrica Pavlinušić's random unstructured stuff (X-server)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] X-=server} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#virtual_pci_network_cards">Dobrica Pavlinušić's random unstructured stuff (Virtual PCI network cards)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] Virtual PCI network cards} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#don_t_delete_files">Dobrica Pavlinušić's random unstructured stuff (don't delete files)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] don't delete files} --></span></li>
</ul></ul>
</div>

            
            
          </div>
        
      </div>
    </td>
  </tr>
</table>
<!-- wiki: {toc: }
--></div><br /><br /><h1 id="cgroups">Cgroups</h1>
<ul>
<li><a target="_blank" title="(external link)" href="http://www.kernel.org/doc/Documentation/cgroups/cgroups.txt">http://www.kernel.org/doc/Documentation/cgroups/cgroups.txt</a></li>
<li><a target="_blank" title="(external link)" href="http://www.webupd8.org/2010/11/alternative-to-200-lines-kernel-patch.html">http://www.webupd8.org/2010/11/alternative-to-200-lines-kernel-patch.html</a></li>
<li><a target="_blank" title="(external link)" href="http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Resource_Management_Guide/ch01.html">http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Resource_Management_Guide/ch01.html</a></li>
</ul>
<ul>
<li>Resource allocation using cgroups <a target="_blank" title="(external link)" href="http://blip.tv/file/4773168">http://blip.tv/file/4773168</a></li>
</ul>
<h2 id="systemd">Systemd</h2>
<ul>
<li>systemd, beyond init <a target="_blank" title="(external link)" href="http://www.youtube.com/watch?v=TyMLi8QF6sw">http://www.youtube.com/watch?v=TyMLi8QF6sw</a></li>
</ul>
<p>
launchd alterntive, somilar to inetd, but for unix sockets (mostly)</p>
<h1 id="lxc">LXC</h1>
<p>
Virtual Servers and Checkpoint/Restart in Mainstream Linux <a target="_blank" title="(external link)" href="http://lxc.sourceforge.net/doc/sigops/appcr.pdf">http://lxc.sourceforge.net/doc/sigops/appcr.pdf</a></p>
<ul>
<li>you don't have hardware virtualization (netbooks, anyone?)</li>

<ul>
<li><a target="_blank" title="(external link)" href="http://lxc.teegra.net/">http://lxc.teegra.net/</a></li>
<li><a target="_blank" title="(external link)" href="http://en.gentoo-wiki.com/wiki/LXC">http://en.gentoo-wiki.com/wiki/LXC</a></li>
<li><a target="_blank" title="(external link)" href="http://sysadvent.blogspot.com/2010/12/day-1-linux-containers-lxc.html">http://sysadvent.blogspot.com/2010/12/day-1-linux-containers-lxc.html</a></li>
</ul>
<li>Amazon EC2</li>

<ul>
<li><a target="_blank" title="(external link)" href="http://www.phenona.com/blog/using-lxc-linux-containers-in-amazon-ec2/">http://www.phenona.com/blog/using-lxc-linux-containers-in-amazon-ec2/</a></li>
</ul>
<li>Running X</li>

<ul>
<li><a target="_blank" title="(external link)" href="http://blog.ikibiki.org/2011/04/05/Running_X_from_LXC/">http://blog.ikibiki.org/2011/04/05/Running_X_from_LXC/</a></li>
</ul>
<li>LVM integration</li>

<ul>
<li><a target="_blank" title="(external link)" href="http://s3hh.wordpress.com/2011/03/30/one-more-lxc-clone-update/">http://s3hh.wordpress.com/2011/03/30/one-more-lxc-clone-update/</a></li>
</ul></ul>
<h1 id="lxc_inside_kvm_for_testing">LXC inside KVM for testing</h1>
<ul>
<li><a target="_blank" title="(external link)" href="http://sysadmin-cookbook.rot13.org/#lxc_kvm">http://sysadmin-cookbook.rot13.org/#lxc_kvm</a></li>
</ul>
<h2 id="setup_kvm_lxc_test_machine">setup KVM LXC test machine</h2>
<ul>
<li><a target="_blank" title="(external link)" href="http://www.landley.net/lxc/01-setup.html">http://www.landley.net/lxc/01-setup.html</a></li>
</ul>
<h3 id="step_1_create_a_root_filesystem_for_the_kvm_system">Step 1: Create a root filesystem for the KVM system.</h3>
<ul>
<li><a target="_blank" title="(external link)" href="http://sysadmin-cookbook.rot13.org/#01_create_kvm_root_sh">http://sysadmin-cookbook.rot13.org/#01_create_kvm_root_sh</a> 3m12.426s</li>
</ul>
<h3 id="step_2_build_a_kernel_for_kvm_with_container_support">Step 2: Build a kernel for KVM, with container support.</h3>
<ul>
<li><a target="_blank" title="(external link)" href="http://sysadmin-cookbook.rot13.org/#02_build_kvm_kernel_sh">http://sysadmin-cookbook.rot13.org/#02_build_kvm_kernel_sh</a> 8m22.248s</li>
</ul>
<h3 id="step_3_boot_the_result_under_qemu_or_kvm">Step 3: Boot the result under QEMU or KVM</h3>
<ul>
<li><a target="_blank" title="(external link)" href="http://sysadmin-cookbook.rot13.org/#03_boot_kvm_sh">http://sysadmin-cookbook.rot13.org/#03_boot_kvm_sh</a></li>
</ul>
<h3 id="step_4_ssh_into_the_kvm_instance">Step 4: ssh into the KVM instance.</h3>
<pre>
ssh root@127.0.0.1 -p 9876
</pre>
<br /><h3 id="step_5_set_up_a_simple_busybox_based_container_under_the_kvm_system">Step 5: Set up a simple busybox-based container under the KVM system.</h3>
<pre>
wget http://busybox.net/downloads/binaries/latest/busybox-i686 -O busybox
chmod +x busybox
echo -e &quot;lxc.utsname = container\nlxc.network.type = empty&quot; &gt; container.conf
PATH=$(pwd):$PATH lxc-create -f container.conf -t busybox -n container
</pre>
<br /><h3 id="step_6_launch_the_container">Step 6: Launch the container</h3>
<pre>
lxc-start -n container

# console is broken, so start another

lxc-console -n container
</pre>
<br /><h3 id="step_7_stop_the_container_and_the_kvm_system">Step 7: Stop the container, and the KVM system.</h3>
<pre>
lxc-stop -n container

# remove container
lxc-destroy -n container
</pre>
<br /><h2 id="setup_networking">Setup networking</h2>
<ul>
<li><a target="_blank" title="(external link)" href="http://www.landley.net/lxc/02-networking.html">http://www.landley.net/lxc/02-networking.html</a></li>
</ul>
<h3 id="step_1_add_a_tap_interface_to_the_laptop">Step 1: Add a TAP interface to the Laptop.</h3>
<pre>
# FIXME change username
tunctl -u dpavlin -t kvm0
ifconfig kvm0 192.168.254.1 netmask 255.255.255.0
echo 1 &gt; /proc/sys/net/ipv4/ip_forward

# iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
</pre>
<br /><h3 id="step_2_launch_kvm_with_two_ethernet_interfaces">Step 2: Launch KVM with two ethernet interfaces.</h3>
<pre>
kvm -m 1024 -kernel ../01-setup/linux-2.6.*/arch/x86/boot/bzImage -no-reboot \
    -hda ../01-setup/squeeze.ext3 -append &quot;root=/dev/hda rw panic=1&quot; \
    -net nic,model=e1000 -net user -redir tcp:9876::22 \
    -net nic,model=e1000 -net tap,ifname=kvm0,script=no
</pre>
<br /><h3 id="step_3_set_up_a_new_container_in_the_kvm_system">Step 3: Set up a new container in the KVM system.</h3>
<pre>
root@kvm:~# cat &gt; busybox.conf &lt;&lt; EOF
lxc.utsname = busybox
lxc.network.type = phys
lxc.network.flags = up
lxc.network.link = eth1
#lxc.network.name = eth0
EOF

PATH=$(pwd):$PATH lxc-create -f busybox.conf -t busybox -n busybox
lxc-start -n busybox
</pre>
<br /><pre>
root@kvm:~# lxc-console -n busybox

ifconfig eth1 192.168.254.2 netmask 255.255.255.0
route add default gw 192.168.254.1
</pre>
<br /><h3 id="step_4_fun_with_routing">Step 4: Fun with routing.</h3>
<p>
On host, bring up loopback alias in KVM network:</p>
<pre>
dpavlin@x200:~$ sudo ifconfig lo:1 10.0.2.200 netmask 255.255.255.0
</pre>
<br /><p>
busybox container can reach it, while KVM can't !</p>
<h1 id="network_hints">network hints</h1>
<h2 id="prepare_host_machine">prepare host machine</h2>
<h2 id="macvlan">macvlan</h2>
<ul>
<li>aliased IP at eth devel</li>
<li>new device with own mac <strong>with</strong> offloading</li>
<li>can't communicate with other containers or host (&lt; 2.6.33)</li>
</ul>
<p>
lxc.network.type=macvlan<br />
lxc.network.link=eth0<br />
lxc.network.flags=up</p>
<p>
ip link add link &lt;phys&gt; name &lt;vif&gt; address &lt;mac address&gt; type macvlan mode (bridge|vepa|private)</p>
<p>
ip link add link bond200 name bond200:0 address 00:aa:bb:cc:dd:ee type macvlan mode bridge</p>
<p>
ip -d show link bond200:0</p>
<p>
lxc.network.type = macvlan<br />
lxc.network.macvlan.mode = bridge<br />
lxc.network.flags = up<br />
lxc.network.link = bond200<br />
lxc.network.name = eth7<br />
lxc.network.mtu = 1500<br />
lxc.network.ipv4 = 192.168.90.11/24<br />
lxc.network.hwaddr = 4a:49:43:49:79:0B</p>
<h2 id="veth">veth</h2>
<pre>
sudo apt-get install bridge-utils dnsmasq


# setup hints

sysctl -w net.ipv4.ip_forward=1

ptables -t nat -A POSTROUTING -o wlan0 -j SNAT --to-source=WLAN0_IP

# or for nat
iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
</pre>
<br /><p>
lxc.network.type=veth<br />
lxc.network.link=br0<br />
lxc.network.flags=up</p>
<ol>
<li>name inside container</li>
</ol>
<p>
lxc.network.name = eth0.12<br />
lxc.network.mtu = 1500<br />
lxc.network.ipv4 = 10.60.0.12/23<br />
lxc.network.hwaddr = AC:DE:48:00:00:0C</p>
<ol>
<li>name host interface for bridge</li>
</ol>
<p>
lxc.network.veth.pair = veth12</p>
<h3 id="host_only_bridge">host-only bridge</h3>
<pre>
$ cat /etc/network/interfaces

auto br0
iface br0 inet static
        bridge_ports dummy0
        bridge_maxwait 0
        address 172.16.16.1
        netmask 255.255.255.0
</pre>
<br /><h3 id="pseudo_random_mac">pseudo-random mac?</h3>
<p>
<a target="_blank" title="(external link)" href="http://en.wikipedia.org/wiki/Mac_address">http://en.wikipedia.org/wiki/Mac_address</a></p>
<p>
&nbsp;&nbsp;&nbsp;&nbsp;x2:xx:xx:xx:xx:xx<br />
&nbsp;&nbsp;&nbsp;&nbsp;x6:xx:xx:xx:xx:xx<br />
&nbsp;&nbsp;&nbsp;&nbsp;xA:xx:xx:xx:xx:xx<br />
&nbsp;&nbsp;&nbsp;&nbsp;xE:xx:xx:xx:xx:xx</p>
<p>
IP=192.168.0.50 # container nic IP<br />
HA=<tt>printf &quot;02:00:%x:%x:%x:%x&quot; ${IP//./ }</tt> # generate a MAC from the IP</p>
<h3 id="slow_network">slow network?</h3>
<p>
/usr/sbin/ethtool -K br0 sg off<br />
/usr/sbin/ethtool -K br0 tso off</p>
<h2 id="phys">phys</h2>
<p>
kernel &gt; 2.6.35</p>
<p>
lxc.network.type=phys<br />
lxc.network.link=eth1<br />
lxc.network.name=eth1</p>
<h1 id="limit_container_resources">limit container resources</h1>
<h2 id="cpuset_cpus">cpuset.cpus</h2>
<p>
echo 1 &gt; /cgroup/&lt;name&gt;/cpuset.cpus	# 2nd CPU!</p>
<p>
echo 1,2,3 &gt; /cgroup/&lt;name&gt;/cpuset.cpus</p>
<p>
echo 0-7 &gt; /cgroup/&lt;name&gt;/cpuset.cpus</p>
<p>
lxc-execute -n foo -s lxc.cgroup.cpuset.cpus=&quot;1,2,3&quot; myforks</p>
<h2 id="cpu_shares">cpu.shares</h2>
<p>
lxc-execute -n foo -s lxc.cgroup.cpu.shares=1 /bin/bash</p>
<p>
lxc-execute -n bar -s /bin/bash</p>
<p>
while $(true); do echo -n . ; done</p>
<p>
lxc-cgroup -n foo cpu.shares=1024</p>
<h2 id="memory">memory</h2>
<p>
lxc.cgroup.memory.limit_in_bytes = 256M<br />
lxc.cgroup.memory.memsw.limit_in_bytes = 1G</p>
<h2 id="disk">disk</h2>
<h3 id="usage">usage</h3>
<p>
standard Linux tools:</p>
<ul>
<li>LVM</li>
<li>quota (it can be bypassed if the container runs with CAP_SYS_ADMIN and/or CAP_SYS_RESOURCE capabilities)</li>
</ul>
<h3 id="limit_disk_bandwith_using_cgroup_blkio">limit disk bandwith using cgroup blkio</h3>
<ul>
<li><a target="_blank" title="(external link)" href="http://www.mjmwired.net/kernel/Documentation/cgroups/blkio-controller.txt">http://www.mjmwired.net/kernel/Documentation/cgroups/blkio-controller.txt</a></li>
</ul>
<p>
Required kernel configuration</p>
<p>
CONFIG_BLK_CGROUP=y<br />
CONFIG_CFQ_GROUP_IOSCHED=y<br />
CONFIG_BLK_DEV_THROTTLING=y</p>
<p>
create containers for test</p>
<pre>
#!/bin/sh -xe

lxc-ls | xargs -i sh -c &quot;lxc-stop -n {} ; lxc-destroy -n {}&quot;

echo &quot;lxc.network.type = empty&quot; &gt; blkio.conf

PATH=$(pwd):$PATH lxc-create -f blkio.conf -t busybox -n disk1
PATH=$(pwd):$PATH lxc-create -f blkio.conf -t busybox -n disk2
PATH=$(pwd):$PATH lxc-create -f blkio.conf -t busybox -n disk3

lxc-ls | xargs -i dd if=/dev/zero of=/var/lib/lxc/{}/rootfs/tmp/zero bs=1M count=100

cat &gt; /tmp/speed.sh &lt;&lt;EOF
#!/bin/sh
while true ; do
        sync ; echo 3 &gt; /proc/sys/vm/drop_caches
        dd if=/tmp/zero of=/dev/null 2&gt;&amp;1
done | grep MB
EOF

chmod +x /tmp/speed.sh

lxc-ls | xargs -i cp /tmp/speed.sh /var/lib/lxc/{}/rootfs/tmp/speed.sh

lxc-ls | xargs -i lxc-start -d -n {}
</pre>
<br /><p>
login into each container and run test</p>
<pre>
root@kvm:~# lxc-console -n disk1

Type &lt;Ctrl+a q&gt; to exit the console

disk1 login: root
~ # /tmp/speed.sh 
104857600 bytes (100.0MB) copied, 0.958453 seconds, 104.3MB/s
</pre>
<br /><p>
Test limits (be careful not to enter 1000, you might oops kernel!)</p>
<pre>
root@kvm:~# echo 100 &gt; /mnt/cgroup/disk1/blkio.weight
root@kvm:~# echo 200 &gt; /mnt/cgroup/disk2/blkio.weight
root@kvm:~# echo 500 &gt; /mnt/cgroup/disk3/blkio.weight

root@kvm:~# cat /mnt/cgroup/disk?/blkio.weight
100
200
500
</pre>
<br /><p>
Limit /dev/hda to 1Mb/s read</p>
<pre>
root@kvm:~# ls -al /dev/hda
brw-rw---- 1 root disk 3, 0 May 15 00:10 /dev/hda

root@kvm:~# echo &quot;3:0 1048576&quot; &gt; /mnt/cgroup/disk1/blkio.throttle.read_bps_device
</pre>
<br /><h2 id="network">network</h2>
<ul>
<li><a target="_blank" title="(external link)" href="http://vger.kernel.org/netconf2009_slides/Network%20Control%20Group%20Whitepaper.odt">http://vger.kernel.org/netconf2009_slides/Network%20Control%20Group%20Whitepaper.odt</a></li>
</ul>
<pre>
# mkdir -p /dev/cgroup
# mount -t cgroup net_cls -o net_cls /dev/cgroup
# mkdir /dev/cgroup/A
# mkdir /dev/cgroup/B

# cd /dev/cgroup
# echo 0x1001 &gt; A/net_cls.classid # 10:1
# echo 0x1002 &gt; B/net_cls.classid # 10:2

# tc qdisc add dev eth0 root handle 10: htb

# tc class add dev eth0 parent 10: classid 10:1 htb rate 40mbit
# tc class add dev eth0 parent 10: classid 10:2 htb rate 30mbit

# tc filter add dev eth0 parent 10: protocol ip prio 10 handle 1: cgroup

</pre>
<br /><h1 id="lxc_commands">LXC commands</h1>
<h2 id="lxc_create">lxc-create</h2>
<p>
/usr/lib/lxc/templates/</p>
<p>
export MIRROR=<a target="_blank" title="(external link)" href="http://192.168.1.20:3142/ftp.debian.org">http://192.168.1.20:3142/ftp.debian.org</a><br />
export SUITE=lenny</p>
<p>
cat &gt; /tmp/lenny.conf<br />
lxc.network.type=veth<br />
lxc.network.link=br0<br />
lxc.network.flags=up</p>
<ol>
<li>&lt;ctrl+d&gt;</li>
</ol>
<p>
t61p:~# lxc-create -n lenny -t debian -f /tmp/lenny.conf</p>
<h2 id="lxc_execute">lxc-execute</h2>
<p>
application container (shares filesystem!)</p>
<p>
lxc-ssh</p>
<p>
lxc-execute -n foo -s lxc.utsname=foo /bin/bash<br />
lxc-execute -n bar -s lxc.utsname=bar /bin/bash</p>
<h2 id="lxc_attach">lxc-attach</h2>
<p>
Needs kernel patch</p>
<p>
lxc-attach <del>n n0 -</del> /usr/sbin/tcpdump -i eth0</p>
<h1 id="devices">devices</h1>
<p>
<a target="_blank" title="(external link)" href="http://lwn.net/Articles/273208/">http://lwn.net/Articles/273208/</a></p>
<p>
lxc.cgroup.devices.allow = &lt;type&gt; &lt;major&gt;:&lt;minor&gt; &lt;perm&gt;</p>
<p>
&lt;type&gt; : b (block), c (char), etc ...<br />
&lt;major&gt; : major number<br />
&lt;minor&gt; : minor number (wildcard is accepted)<br />
&lt;perms&gt; : r (read), w (write), m (mapping)</p>
<h1 id="monitoring">monitoring</h1>
<h2 id="htop">htop</h2>
<p>
htop - cgroups &gt; r192</p>
<p>
t61p:/tmp# apt-get source htop<br />
t61p:/tmp# apt-get build-dep htop<br />
t61p:/tmp# dpkg-source -x htop_0.9-2.dsc<br />
t61p:/tmp# cd htop-0.9/</p>
<p>
t61p:/tmp/htop-0.9# DEB_BUILD_OPTIONS=&quot;--enable-cgroup&quot; fakeroot debian/rules binary</p>
<ol>
<li>sigh, no work, patch debian/rules to add --enable-cgroup</li>
</ol>
<p>
t61p:/tmp/htop-0.9# fakeroot debian/rules binary<br />
t61p:/tmp/htop-0.9# dpkg -i ../htop_0.9-2_i386.deb</p>
<h2 id="procfs">procfs</h2>
<p>
<a target="_blank" title="(external link)" href="http://lxc.sourceforge.net/download/procfs/procfs.tar.gz">http://lxc.sourceforge.net/download/procfs/procfs.tar.gz</a> (fuse, defunct)<br />
<a target="_blank" title="(external link)" href="http://www.tinola.com/lxc/">http://www.tinola.com/lxc/</a> (somewhat newer)</p>
<h2 id="debugging">debugging</h2>
<p>
lxc-start --logpriority=TRACE -o /tmp/trace.log --name my_container</p>
<p>
(must have redirect to file!)</p>
<h1 id="kernel_patches">kernel patches</h1>
<p>
<a target="_blank" title="(external link)" href="http://lxc.sourceforge.net/patches/linux/">http://lxc.sourceforge.net/patches/linux/</a></p>
<h1 id="are_we_in_container">Are we in container?</h1>
<p>
on host:</p>
<p>
dpavlin@stage:~$ cat /proc/$$/cgroup<br />
1:net_cls,freezer,devices,cpuacct,cpu,ns,cpuset:/</p>
<p>
inside container:</p>
<p>
dpavlin@narada:~$ cat /proc/$$/cgroup<br />
1:net_cls,freezer,devices,cpuacct,cpu,ns,cpuset:/narada</p>
<h1 id="32_bit_guest_on_64_bit_kernel">32-bit guest on 64-bit kernel</h1>
<p>
(lxc &gt;= 0.7.3)</p>
<p>
lxc.arch=x86</p>
<h1 id="container_tweaks">Container tweaks</h1>
<h2 id="udev">udev</h2>
<p>
echo udev hold | dpkg --set-selections</p>
<h2 id="nfs">nfs</h2>
<p>
kernel doesn't have nfs namespaces yet, use user-space nfs servers:</p>
<ul>
<li><a target="_blank" title="(external link)" href="http://unfs3.sourceforge.net">http://unfs3.sourceforge.net</a></li>
<li><a target="_blank" title="(external link)" href="http://sourceforge.net/apps/trac/nfs-ganesha">http://sourceforge.net/apps/trac/nfs-ganesha</a></li>
</ul>
<h2 id="chromium">chromium</h2>
<ul>
<li><a target="_blank" title="(external link)" href="http://www.chromium.org/chromium-os/chromiumos-design-docs/system-hardening">http://www.chromium.org/chromium-os/chromiumos-design-docs/system-hardening</a></li>
<li><a target="_blank" title="(external link)" href="http://git.chromium.org/gitweb/?p=chromiumos/platform/minijail.git;a=summary">http://git.chromium.org/gitweb/?p=chromiumos/platform/minijail.git;a=summary</a></li>
</ul>
<h2 id="pam">pam</h2>
<ul>
<li><a target="_blank" title="(external link)" href="http://pam-netns.sourceforge.net/">http://pam-netns.sourceforge.net/</a></li>
</ul>
<p>
pam_netns allows to setup a private network namespace for every user<br />
session (comparable with pam_namespace for filesystem namespaces). This<br />
is especially useful on multiseat environments.</p>
<h2 id="x_server">X-server</h2>
<ul>
<li><a target="_blank" title="(external link)" href="http://box.matto.nl/lxcxserver.html">http://box.matto.nl/lxcxserver.html</a> (Xnest example)</li>
</ul>
<ul>
<li><a target="_blank" title="(external link)" href="https://launchpad.net/arkose">https://launchpad.net/arkose</a> - Arkose - Desktop Application Sandboxing (using aufs2)</li>
</ul>
<h2 id="virtual_pci_network_cards">Virtual PCI network cards</h2>
<ul>
<li><a target="_blank" title="(external link)" href="http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Virtualization/sect-Para-virtualized_Windows_Drivers_Guide-How_SR_IOV_Libvirt_Works.html">http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Virtualization/sect-Para-virtualized_Windows_Drivers_Guide-How_SR_IOV_Libvirt_Works.html</a></li>
</ul>
<h2 id="don_t_delete_files">don't delete files</h2>
<p>
dpkg-divert --rename /etc/init/theinitfile.conf</p>
.pre
</div>
<hr/><div>Attachments: linux-containers.png</div>]]></description>
<author>Dobrica Pavlinu&#x161;i&#x107;</author>
<category></category>
<guid isPermaLink="true">https://saturn.ffzg.hr/rot13/index.cgi?lxc</guid>
<pubDate>Wed, 18 May 2011 07:12:31 -0000</pubDate>
</item>
</channel>
</rss>