Wednesday, May 16, 2012

different runlevels in gentoo

Different default runlevels isn't something which is quite popular because usually one default runlevel is enough. Nonetheless sometimes it's quite useful.
Since i play around with xen it's very handy to have two different default runlevels. One where the xen services xenconsoled and xenstored get started and one without these services.
The reason is, when starting gentoo without xen these services would crash and thus would slow down the boot process.

To create a new runlevel called "xen" you have todo following:

# mkdir /etc/runlevels/xen
# cd /etc/runlevels/default
# for service in *; do rc-update add $service xen; done
# rc-update add xenstored xen
# rc-update add xenconsoled xen

This would copy all services from the default runlevel into xen and would add both xen init scripts too. Next you need to configure the bootloader and add the softlevel parameter to /boot/grub/grub.conf.

title Gentoo Linux XEN
root (hd0,0)
kernel /boot/xen.gz dom0_mem=8192M,max:8192M iommu=1 xsave=1 dom0_max_vcpus=4 dom0_vcpus_pin 
module /boot/gentoo-3.4.0-rc6 root=/dev/md3 softlevel=xen

Finish, that's all. Quite easy and really useful for xen. A more detailed howto about runlevels can be found at gentoo's offical documentation: Link

Sunday, May 13, 2012

new pc, new toy

It's been already 5 years ago since i bought my last desktop PC. Now i bought a new one. A few months ago i've started to think about my new system. Basically i don't wanted anything special, there was just one thing which i definitely wanted to try out: xen with vga passthrough. Therefore i couldn't choose just anything because you need hardware support for vga passthrough and not every vendor does support it.

Anyway, last month i finally had everything i needed and thus bought my new system.

A big change with the new system was to choose amd over intel. For years now i went with intel, but this time i decided to take amd. The main reason was because amd/ati started to release documentations about their graphic cards years ago. That's something i wanted to support.

Well, this is now my new system:

AMD FX 8150 8-core processor 3,6Ghz
Gigabyte 990FXA-UD5
2x OCZ Vertex 3 120GB
Lian Li PC-6 Aluminium Case
NEC PA301W 30" Display
Scythe Grand Kama Gross CPU Cooler
Seasonic Xseries 760W Power Supply
PowerColor Radeon HD6850 (passiv)
XFX R7970 Radeon H7970 Black Edition
Corsair DDR3 1600MHZ 16GB DIMM

The system runs on gentoo amd64 testing (of course). Since i have two gpu's and xen, there is a virtualized windows 7 64bit for gaming too.
The HD7970 is for windows, while the HD6850 is for gentoo. I also additionally pluged in 2x 22" Lenovo l220x running on the HD6850 on linux (from the old pc). Mouse, keyboard and the audio system is still from the old pc.

This is my desktop right now:

The motherboard supports iommu which is needed for vga passthrough in xen. Nonetheless i updated the bios to the latest version first. On the cpu it's called amd-vi (the cpu flag is called svm) which the amd 8-core also supports. GPU support isn't a hardware feature and has been already implemented for almost every gpu so i didn't had to look for a particular one.

Setting up the system wasn't a big deal. Below are the most important changes while i set up the system.

* i had to change the primary output in the bios so that the system would show the output on my hd6850.

* i also had to enable iommu in the bios (for xen).

* to get eyefinity working i had to download x11-drivers/radeon-ucode and enable the firmwire blobs in the kernel under Device Drivers --> Generic Driver Optinos (howto)

The harddrives running in both raid1 (for the boot partion) and raid0 (for the system/home). Since all the important files are on my server file inconsistency is not  that important. Windows is virtualized and thus just a file on the hard disk.

So far the system is pretty stable. I have a few minor problems with xen but nothing serious. I'll gonna blog about my xen setup anyway.

Monday, May 7, 2012

ssh with different private keys


SSH is probably one of the most used command line tools on linux. If you want to connect to another linux host it's the best way to go. It's also very secure and since security is really important nowadays many hosts on the Internet choose a public key authentication. This method is really smart because it only let people connect if they know their password AND their public key is in the "authorized_keys" file on the host.

For some time now i started a gitolite services at home. It's just for my own usage and thus not available over the Internet. Every script which i write is stored on the gitolite server.
This is quite handy because i can easily switch back to an older version of a script in case i made a mistake. Besides that I'm also forced to learn git which i really want to learn. 

Gitolite also have a public key authentication (on top of ssh), but since the service just runs on the local network and i don't wanted to enter my password every time, I've created a second key without a password.

Well now my problem was, ssh doesn't choose the right key for the git service so i searched the web for solution of my problem. A few hour later i found what i needed. It's easy. You just need a configuration file for ssh, which looks something like this:

Host tunafix
        Hostname tunafix
        User git
        IdentityFile ~/.ssh/gitolite_rsa

Host tunafix
        Hostname tunafix
        User michael
        IdentityFile ~/.ssh/id_dsa

The configuration is stored in file ~/.ssh/config. As you can see, depending on the username ssh choose different identity files. 

Wednesday, May 2, 2012

notify script for cmus

Recently i bought a new PC and therefore i wanted to switch to a new audio player. Usually i use amarok which is still one of the best audio player out there. But it has a big disadvantage - it uses mysql for its database, and i simple don't wanted mysql.
Though, to choose mysql for the database backend is still a good decision - if you have a really big collection.
And that's amarok's audience - users with a huge audio collection.
Well, actually i have a huge audio collection too, but since i actually just play around ~40 tracks all the time besides mostly listening to streams, i really don't wanted a audio player which depends on mysql.
While looking for a new player i found cmus. A very simple console player. It's perfect. It has all the things which i need (playlists, mp3/flac support, stream support) and also has a really tiny memory footprint.
To make the player really comfortably in kde i wrote a small script which shows me some basic information about the actual track which i'm listening too.

And that's the script:
#!/bin/bash
KDIALOG="/usr/bin/kdialog"
GREP="/bin/grep"
AWK="/bin/awk"
CMUSREMOTE="/usr/bin/cmus-remote"

declare -i duration=$($CMUSREMOTE -Q|$GREP "duration"|$AWK '{ print $2 }')
declare -i position=$($CMUSREMOTE -Q|$GREP "position"|$AWK '{ print $2 }')
percent=$[100*position/duration]

artist=$($CMUSREMOTE -Q|$GREP "tag artist") # ${artist:10}
title=$($CMUSREMOTE -Q|$GREP "tag title") # ${title:9}

$KDIALOG --title "CMUS is playing... ($percent%)" --passivepopup "${artist:10} - ${title:9}" 3



It looks like this:


To make it even more comfortably i put some code into my .bashrc and initab.
.bashrc:
if ! [ "$(pidof cmus)" ];
  then /usr/bin/cmus
fi


inittab:
c8:2345:respawn:/sbin/agetty -a michael 38400 tty8 linux


With that settings, cmus always get started on tty8. And with the alias p="cmus-remote -u" i just have to press "p" after login to play music (just a note: i don't use a login-manager, thats why i always login at the console and start kde/X with startx).