Fr 11. Dez 18:22:55 CET 2009
Access partitions in loopback devices under linux
Ever needed to access a partition inside a block device not supporting partitions like /dev/loop or software raid? There exists multiple solutions like specifying the offset via losetup or patching the kernel. But this is error-prone and not very user friendly.
An easy and more user friendly way of supporting partition tables in any block device is kpartx. Besides the name, is has nothing to do with kde but is a tool from multipath tools to map partition tables to the device mapper.
After you installed kpartx you can easily create mappings from a block device with kpartx -a and delete them via kpartx -d. For example:
# echo p | fdisk /dev/loop0 Command (m for help): Disk /dev/loop0: 102 MB, 102400000 bytes 255 heads, 63 sectors/track, 12 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0x00000000 Device Boot Start End Blocks Id System /dev/loop0p1 1 5 40131 83 Linux /dev/loop0p2 6 12 56227+ 83 Linux # kpartx -a /dev/loop0 # ls /dev/mapper/loop0p* /dev/mapper/loop0p1 /dev/mapper/loop0p2 # kpartx -d /dev/loop0 # ls /dev/mapper/loop0* ls: cannot access /dev/mapper/loop0*: No such file or directoryTo make a long story short: kpartx is a easy and handy solution for using partitions from any block device under linux making management of images for virtual machines quite simple.
Fr 18. Sep 15:50:44 CEST 2009
Bootstrapping Fedora to directories
As mentioned in the comments and another blog entry there exist several other simpler solutions.
febootstrap allows you to
install centos/fedora really easily just like deboostrap.
Example to install centos in directory c5:
# febootstrap centos-5 c5 http://mirror.eunet.at/5.3/os/i386/ # ..... # chroot c5 cat /etc/redhat-release # CentOS release 5.3 (Final)
mach is another more generic way to bootstrap rpm based distributions to a directory. For an overview of the features just have a look at the README Example to install centos:
$ mach -r centos-5-i386-os setup base
If you just want to install Fedora/Centos into some directory use febootstrap as it is
quite simple and does the job.
But if you want to rebuild rpms or bootstrap
any other rpm based distribution like SuSE, Yellowdog use mach
Fr 18. Sep 14:14:13 CEST 2009
Unit testing for shell scripts with shunit2
Recently I stumbled upon a bug of an funtion in a shellscript and wanted to make sure that this bug never happens again. So i searched around and found shunit2 a nice xUnit based test framework for shell scripts.
If you ever had thought about writing unit tests for your shell scripts, do it! Its really easy, and shunit2 also supports zsh
Example test sript:
#! /bin/sh testEquality() { assertEquals 1 1 } . shunit2For more examples have a look at the tests for grml-autoconfig or at the example directory of the shunit2 package
Sa 29. Aug 19:45:30 CEST 2009
cdn for debian or location aware entry in /etc/apt/sources.list
The upcoming grml release will use cdn.debian.net per default in /etc/apt/sources.list to always use a mirror near to your location.
To use it, just replace existing host names with cdn.debian.net.Example:
deb http://cdn.debian.net/debian stable main contrib non-free
Sa 20. Jun 03:38:59 CEST 2009
Automatic security updates for Debian based systems
unattend-upgrades is a debian package providing automatic security upgrades.
To use it, just install unattended-upgrades, modify /etc/apt/apt.conf.d/50unattended-upgrades to your needs like:
Unattended-Upgrade::Allowed-Origins { "Debian stable"; };To automatically and unattended install security updates you also have to set
APT::Periodic::Update-Package-Lists "1"; APT::Periodic::Unattended-Upgrade "1";in /etc/apt/apt.conf or in a file located in /etc/apt/apt.conf.d/ (I use /etc/apt/apt.conf.d/60security)
For further details have a look at /usr/share/doc/unattended-upgrades/README or https://wiki.ubuntu.com/AutomaticUpdates Just setup unattended-upgrades and life becomes more easy as you dont have to remember to upgrade each of your machines.
Sa 20. Jun 03:10:56 CEST 2009
One command line interface for multiple RDBMS systems
sqlline a java based console program allows you to connect to any database with existing jdbc drivers replacing the original programs like mysql, sqlplus or psql.
Example to connect to an oracle database with sqlline:
$ java -cp ~/path/classpath/classes12.jar:/usr/share/java/sqlline.jar sqlline.SqlLine sqlline version 1.0.2 by Marc Prud'hommeaux sqlline> !connect jdbc:oracle:thin:@hostname:1521:xe USER PASS Connecting to jdbc:oracle:thin:@hostname:1521:xe Connected to: Oracle (version Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production) 2: jdbc:oracle:thin:@hostname:1521:xe>
Fr 20. Feb 20:04:37 CET 2009
Static ip assignment with libvirt
I just started to use libvirt and needed to have static ip assignment for some of the systems. Libvirt supports this but there is no documentation for this, a patch with documentation has just been send to the mailing list, but thats all (except the documentation in the *.c files ;-)
A simple example which assigns 192.168.122.2 to the host with the mac AA:BB:CC:DD:EE:FF:<network> <name>sample</name> <bridge name='intbr0' /> <ip address='192.168.122.1' netmask='255.255.255.0'> <dhcp> <range start='192.168.122.2' end='192.168.122.254' /> <host mac='AA:BB:CC:DD:EE:FF' ip='192.168.122.2' name='foobar'/> </dhcp> </ip> </network>
So 11. Jan 13:13:05 CET 2009
Short overview about mpris and command line tools
mpris player
media mlayer remote interface specification, short mpris is a specification to connect media players via dbus. This is quite useful as you can have one command for example to control Amarok, Audacious or any other mpris capable player.This are all gui player, so lets have a look at mpd, a music daemon simple to control via commandline.
mpd natively does not support dbus, but there is another solution, mpDris, a mpd client exporting the mpris functionality via dbus.
mpris client
A really nice and powerful mpris command-line client is mpris-remote to access an mpris capable player. Here are some examples commands:mris-remote pause # toggle pause mris-remote next # next mpris-remote random true mpris-remote random falseit is really intuitiv, so just use ist.
So what is the benefit?
- You only have one command to control them all, so you can just switch your music player and your scripts will work. So instead of binding player specific commands to, e.g. your multimedia keys on the keyboard, consider using mpris and it does not depend if you use mpd, amarok, audacious or any other client.
- Additional features are possible, for example inhibit power-manager when playing music, so you can close the lid, unhibit when music stop so your pc can start sleep. And this works for multiple player out of the box.
- You can can subscribe to signals from the music player, so you can just get the information and don't have to check the status regular
Sa 3. Jan 17:22:10 CET 2009
Mark build dependencys as automatical installed
You can set the option on the commandline
apt-get -o "Apt::Get::Build-Dep-Automatic=True" build-dep gnome-power-manager
or set it in the config file
$ cat /etc/apt/apt.conf.d/99builddep APT::Get::Build-Dep-Automatic "True";
To remove the dependencies just use apt-get autoremove
Mo 29. Dez 23:52:10 CET 2008
Mehr als 800 Zuschauer innerhalb von 5 Minuten ....
Ich habe da u.a. ich beim Theora Streaming mitgemacht, und wir haben dazu von der FEM ihre MMS Streams transcoded und Theora Streams bereitgestellt. Kurz vor Start hatten wir ca. 400 Zuschauer, danach >1200 Zuschauer.
Das ganze auf 4 Servern (2 an der Uni Ulm, einer an der BA Lörrach und einer im BCC) verteilt. Sehr coole Aktion!