07.06.2014 Views

2 - Raspberry PI Community Projects

2 - Raspberry PI Community Projects

2 - Raspberry PI Community Projects

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

into a separate switch, with the containers also plugged into that switch. The host must then<br />

act as a gateway for the containers if they are meant to communicate with the outside world.<br />

In addition to bridge-utils, this “rich” configuration requires the vde2 package; the /etc/<br />

network/interfaces file then becomes:<br />

# Interface eth0 is unchanged<br />

auto eth0<br />

iface eth0 inet dhcp<br />

# Virtual interface<br />

auto tap0<br />

iface tap0 inet manual<br />

vde2-switch -t tap0<br />

# Bridge for containers<br />

auto br0<br />

iface br0 inet static<br />

bridge-ports tap0<br />

address 10.0.0.1<br />

netmask 255.255.255.0<br />

The network can then be either be set up statically in the containers, or dynamically with DHCP<br />

server running on the host. Such a DHCP server will need to be configured to answer queries<br />

on the br0 interface.<br />

12.2.2.3. Seing Up the System<br />

Let us now set up the filesystem to be used by the container. Since this “virtual machine” will not<br />

run directly on the hardware, some tweaks are required when compared to a standard filesystem,<br />

especially as far as the kernel, devices and consoles are concerned. Fortunately, the lxc includes<br />

scripts that mostly automate this configuration. For instance, the following commands<br />

(which require the debootstrap package) will install a Debian container:<br />

root@scouzmir:~# mkdir /var/lib/lxc/testlxc/<br />

root@scouzmir:~# /usr/lib/lxc/templates/lxc-debian -p /var/lib/lxc/testlxc/<br />

debootstrap is /usr/sbin/debootstrap<br />

Checking cache download in /var/cache/lxc/debian/rootfs-i386 ...<br />

Downloading debian minimal ...<br />

I: Retrieving Release<br />

I: Retrieving Packages<br />

[...]<br />

Removing any system startup links for /etc/init.d/hwclockfirst.sh ...<br />

/etc/rcS.d/S08hwclockfirst.sh<br />

Root password is 'root', please change !<br />

Chapter 12 — Advanced Administration<br />

329

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!