[Freedombox-discuss] Should we use LXC in Freedombox?
Petter Reinholdtsen
pere at hungry.com
Wed Oct 2 09:31:36 UTC 2013
[Rob van der Hoeven]
> Hi Petter,
Hi.
> I'm using LXC for 2.5 years and have written many articles about my
> setup which you can find at:
>
> http://freedomboxblog.nl/articles-tagged-software-architecture
Great. Very good to find a useful description. :)
> I think these articles answer many of your questions. The list of
> articles is in reverse order: start with the oldest article at the
> bottom and work your way to the top if you want to fully understand my
> setup. The articles describe a Squeeze setup - Wheezy needs a slightly
> modified LXC template which you can download at:
>
> http://freedomboxblog.nl/wp-content/uploads/lxc-debian-wheezy.gz
I compared your template with the one in Jessie, and these seem to be
the relevant changes. Did I get it right? Did you try to push these
changes to the Debian package or upstream?
--- lxc-templates/lxc-debian 2013-10-02 10:47:54.426557397 +0200
+++ lxc-templates/lxc-debian-freedombox 2013-10-02 11:14:33.945597708 +0200
@@ -20,6 +20,11 @@
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+# ==============================================================
+# This is a slightly modified version by Rob van der Hoeven
+# I use it for my FreedomBox project: http://freedomboxblog.nl
+# ==============================================================
+
SUITE=${SUITE:-squeeze}
MIRROR=${MIRROR:-http://cdn.debian.net/debian}
@@ -76,6 +81,12 @@
$hostname
EOF
+ # let dhcp client report the hostname to dnsmasq
+ cat <<EOF >> $rootfs/etc/dhcp/dhclient.conf
+send host-name "$hostname";
+send vendor-class-identifier "lxc.module";
+EOF
+
# reconfigure some services
if [ -z "$LANG" ]; then
chroot $rootfs locale-gen en_US.UTF-8 UTF-8
@@ -162,11 +173,11 @@
install_debian()
{
- cache="/var/cache/lxc/debian"
+ cache="/var/cache/lxc/debian-freedombox"
rootfs=$1
mkdir -p /var/lock/subsys/
(
- flock -x 200
+ flock -n -x 200
if [ $? -ne 0 ]; then
echo "Cache repository is busy."
return 1
@@ -191,7 +202,7 @@
return 0
- ) 200>/var/lock/subsys/lxc-debian
+ ) 200>/var/lock/subsys/lxc-debian-freedombox
return $?
}
@@ -230,7 +241,16 @@
# mounts point
lxc.mount.entry = proc proc proc nodev,noexec,nosuid 0 0
+lxc.mount.entry = devpts dev/pts devpts defaults 0 0
lxc.mount.entry = sysfs sys sysfs defaults 0 0
+
+# networking
+
+lxc.network.type = veth
+lxc.network.flags = up
+lxc.network.link = br0
+lxc.network.ipv4 = 0.0.0.0/24
+lxc.network.hwaddr = 00:1E:$(hex):$(hex):$(hex):$(hex)
EOF
if [ $? -ne 0 ]; then
@@ -241,9 +261,15 @@
return 0
}
+# nice trick from: http://mindref.blogspot.com/2011/01/debian-lxc-create.html
+hex()
+{
+ echo "`tr -dc A-F0-9 < /dev/urandom | head -c 2 | xargs`"
+}
+
clean()
{
- cache="/var/cache/lxc/debian"
+ cache="/var/cache/lxc/debian-freedombox"
if [ ! -e $cache ]; then
exit 0
@@ -261,7 +287,7 @@
rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1
exit 0
- ) 200>/var/lock/subsys/lxc-debian
+ ) 200>/var/lock/subsys/lxc-debian-freedombox
}
usage()
I've added it to the freedombox-setup package to make it easier to
test LXC with Freedombox.
> At the moment I'm working on my own software to isolate programs
> running on the FreedomBox. This software does not use LXC anymore
> and will be *much* more lightweight. So keep in mind that although
> my setup served me well over the past years it will be replaced in
> the near future.
What are you going to use instead? Perhaps the official Freedombox
from Debian should use this new mechanism instead?
--
Happy hacking
Petter Reinholdtsen
More information about the Freedombox-discuss
mailing list