Linux containers and btrfs snapshots.

I quite like Linux Containers (lxc) but have been looking for a nice way to create and destroy them quickly. I don’t use LVM on my laptop which seems to be the suggested way so I converted my rootfs to btrfs and using that instead. This should allow me to create a new test machine quickly and use very little disk space as the snapshots are copy-on-write.

I will not go into how to install lxc and setup an inital machine as there are much better guides on the web out there.

The lxc systems are created in /var/lib/lxc by default so this is what I will be working with. I assume you have created a base container as /var/lib/lxc/base-debian and want to create a new machine called debian-1 and that you have a single filesystem / that is all btrfs.

First off create a subvolume for your base image to live on. First move your current base-debian out the way then create the snapshot. Then move the content back in.

cd /var/lib/lxc

mv base-debian base-debian.tmp

btrfs subvolume create /var/lib/lxc/base-debian

mv base-debian.tmp/* base-debian/

rm -rf base-debian.tmp

Now check what you have

btrfs subvolume list /

Now we can create our first clone.

btrfs subvolume snapshot /var/lib/lxc/base-debian /var/lib/lxc/debian-1

Then fix the config files

sed -i “s+/lxc/base-debian/rootfs+/lxc/debian-1/rootfs+” /var/lib/lxc/debian-1/config

echo “debian-1” >/var/lib/lxc/debian-1/rootfs/etc/hostname

Now start it up

lxc-start —name debian-1

Simple as that!

You can delete them when you are finished using

btrfs subvolume delete /var/lib/lxc/debian-1

Chrome password encryption on Linux or lack there of.

Password

Currently on Linux chrome and chromium browsers store your passwords in a sqlite database in plain text. This is not a great idea. On Mac and Windows they use the systems password storage facilities to store them. The code to support Gnome and KDE password storage is there and has been for some time but it is just not enabled. Below are some instructions for enabling it on Debain/Ubuntu based systems. I have done these for chromium but if you just replace it with chrome it should be pretty much the same.

First off backup your profile in .config/chromium-browser/Default ( better encrypt it as it contains all your passwords in plain text )

$ cd .config/chromium-browser/
$ tar cf - Default |gpg  --symmetric  --output profile.tar.gpg -

Then we need to setup chromium to use the gnome-password first move the actual package command to one side using dpkg-divert so that it does not get overwritten on the next upgrade.

# dpkg-divert --add --rename /usr/bin/chromium-browser

Then create a new script to run the newly moved file. Note: you can use detect rather than gnome here to make it guess if you have gnome or KDE running. ( Lets hope they learn to share some time soon!)

Create /usr/bin/chromium-browser

#!/bin/sh
exec /usr/bin/chromium-browser.distrib --password-store=gnome $@

Then make it executable with

# chmod 0755 /usr/bin/chromium-browser

Then close all browser windows and start up the browser again. It may take a little while to port all your passwords across but at the end they should all be stored in you gnome keyring. You can check this by going to System->Preferences->Passwords & Encryption Keys in the main menu and the login keyring should now contain all your web passwords. These are stored encrypted and unlocked as you log in.

If you now type “about:” into the location bar it should show that the browser is running with the “—password-store=gnome” parameter.

At the end the file $HOME/.config/chromium-browser/Default/Login Data should be approx 12k

You can look at it contents with the following 

$ sqlite3 Login\ Data
sqlite> .tables
logins  meta  
sqlite> select * from logins;
0 Rows
sqlite>.quit
$

If everything now looks okay, you have passwords remembered, you can see them in the gnome keyring. Then go ahead and delete that backup that you made.

Note: To restore the backup run the following:

gpg --decrypt profile.tar.gpg |tar xf -

There is also a chromium bug, 25404  that looks to be fixed as of 5th Feb 2011 that should set this to the default so you may want to just wait.

RadioParadise HD photos as a desktop background on Linux.

We have been listening to Radio Paradise a lot recently in the office and they do a nice HD photo backdrop that displays what they are playing. 

I thought it might be nice to have it running as a background so added a devilspie recipe in ~/.devilspie/rphd.ds with the following in:

(if
(matches (window_name) "Radio Paradise HD - Iceweasel")
(begin
(below)
(undecorate)
(skip_pager)
(skip_tasklist)
(wintype "normal")
(maximize)
(stick)
(wintype "utility")
)
)

Fire up your browser and click on the link to the HD picture player on the radio paradise front page. Then run “devilspie -a” to apply it. And it should magically become your background.

Seems to work quite well. You may have to install devilspie and change the Iceweasel to Firefox or whatever your browser is.

Breakfast of kings.

Breakfast of kings.

Final guess for the pin code on my upgraded phone.

Final guess for the pin code on my upgraded phone.

All fruit juice should come with wholly hats.

All fruit juice should come with wholly hats.

A small warming up with the blow tourch and I have a new phone stand.

A small warming up with the blow tourch and I have a new phone stand.

Great Wild Planet display lit up down the Moor, Sheffield.

Great Wild Planet display lit up down the Moor, Sheffield.

Had a go at fixing my bike grip using some Sugru.

Had a go at fixing my bike grip using some Sugru.