Archive for Ubuntu

Ubuntu 10.04, LTSP ja ID-kaart

Vahepeal on mitu uut Ubuntu väljalaset olnud ning viimased ID-kaardi terminal-serveri paketid Ubuntule sai treitud 8.04 jaoks. Seekord siis Estobuntu 10.09 ehk Ubuntu 10.04 jaoks, seni olengi ainult Ubuntu Long Term Support väljalasetele neid teinud ning tihedamini vist ei hakkagi punnitama.

Serveri tarkvara paigaldus

Juhend eeldab Ubuntu Server 10.04 paigaldust. Kõigepealt paigalda LTSP paketid:

apt-get install ltsp-server-standalone python-software-properties ubuntu-desktop

Paigalda soovitud töölaud:

apt-get install ubuntu-desktop

Luba repositooriumid:

add-apt-repository ppa:lauri-vosandi/ppa
add-apt-repository ppa:esteid/ppa
apt-get update

Paigalda paketid:

apt-get install openssh-server libpcsclite1
    qdigidoc qesteidutil mozilla-esteid thunderbird-esteid

Lisa Xsession skript mis näitab uut PCSC-lite sokkli asukohta:

echo "export PCSCLITE_CSOCK_NAME=$HOME/.pcscd.comm" > /etc/X11/Xsession.d/80-pcsclite

Terminali tarkvara paigaldus

Paigalda terminali tarkvara serveri /opt/ltsp/i386 alla:

MIRROR="http://ee.archive.ubuntu.com/ubuntu/" \
EARLY_PACKAGES="ltsp-client" \
LANG=C \
ltsp-build-client --arch i386

Sisene terminali juurikasse:

chroot /opt/ltsp/i386

Uuenda pakettide nimekirju:

apt-get install python-software-properties
add-apt-repository ppa:lauri-vosandi/ppa
add-apt-repository ppa:esteid/ppa
apt-get update

Paigalda modifitseeritud paketid:

apt-get install openssh-client pcscd libccid

Lisa SSH kliendi seadistused, asenda 192.168.0.21 oma serveri IP-ga:

echo "Host 192.168.0.10
    RemoteForward [~/.pcscd.comm] :[/var/run/pcscd/pcscd.comm]" >> /etc/ssh/ssh_config

Välju terminali juurikast

exit

Uuenda võrgust laetavaid tõmmiseid

ltsp-update-image --arch i386

Comments (1) »

Firefly Media Server and Banshee

If you have more than 10k audio tracks on your NAS box, reading all the metadata is rather slow via Samba or NFS. There are various ways to access multimedia over LAN, DLNA/UPnP is good enough for videos, Digital Audio Access Protocol is better for audio. DAAP originates from Apple’s iTunes, it is based on HTTP and most of the Free Software implementations are actually reverse engineered, because Apple hasn’t exactly provided proper documentation if I am not mistaken.

There are various DAAP servers besides iTunes itself, the most used one seems to be mt-daapd. The author of mt-daapd has abandoned the project and there’s a bunch of forks on the web: Firefly Media Server, the more up-to-date forked-daapd and probably others.

DD-WRT’s Optware repository contains mt-daapd and mt-daapd-svn packages, first one seems to be pretty much obsolete version, the second one seems to carry Firefly Media Server branding. That’s also the package I got working on my router. The configuration for those of you who are interested sits in at /opt/etc/mt-daapd/mt-daapd.conf:


[general]
web_root = /opt/share/mt-daapd/admin-root
port = 3689
admin_pw = mt-daapd
db_type = sqlite3
db_parms = /mnt/disc0-part1/.mt-daapd
mp3_dir = /mnt/disc0-part1/Muusika
servername = Firefly on rt-n16
runas = nobody
extensions = .mp3,.m4a,.m4p,.flac,.ogg
logfile = /mnt/disc0-part1/.mt-daapd/mt-daapd.log
rescan_interval = 0
always_scan = 0
scan_type = 0
compress = 0

[plugins]
# Banshee fails to play transcoded FLAC stream so I disabled
# ssc-ffmpeg.so and ssc-script.so plugins by deleting them
plugin_dir = /opt/lib/mt-daapd/plugins

[scanning]
process_playlists = 0
process_itunes = 0
process_m3u = 0

Once started Firefly Media Server scans the music directory for audio files, stores meta-information and afterwards starts listening on port 3689, that’s also the standard port for DAAP. You can fire up a browser and see how it’s doing, the login in this case is admin and mt-daapd. The web interface seems to be the “right” place to shut down the media server because the process is not properly handling SIGTERM or SIGKILL, you can also reinitiate the scan from the web interface.

Now once Firefly is up and running, you can connect to it using iTunes, but being an open-source zealot, I don’t have much Apple gear lying around! On Ubuntu you can try out Rhythmbox, and it’s buggy bro Banshee. Banshee is written in C# and those guys have written some funky code that exposes it’s local cache and what not on http://localhost:8089. Note that Firefly by default transcodes FLAC and OGG to uncompressed WAV, but Banshee doesn’t play with that well.

For all the hackers out there: having a HTML5 based player interface in Firefly would be a bliss!

No comment »

Reedeõhtune virin ketaste teemal

Alustaks siis seekord tavalistest kõvaketastest. Arvutimaailma tundvad inimesed teavad et 1 kilobait = 1024 baiti, 1 megabait = 1024 * 1024 = 1 048 576 baiti ning 1 gigabait = 1024 * 1024 * 1024 = 1 073 741 824 baiti. Kui nüüd tähti närida siis õigem oleks kasutada 1024 astmete jaoks termineid kibibyte, mebibyte, gibibyte aga IT-inimeste seas pole see vedu võtnud. Küll aga kõvakettatootjad on aga otsustanud kõvaketaste mahtuvust mõõta “õigetes” SI-ühikutes. Praktikas tähendab see seda, et 1000GB ketas ongi ligilähedal miljardile baidile:

lauri@localhost:~$ fdisk /dev/sdb
Command (m for help): p
Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes

Tehes siit nüüd kiire arvutuse ja eeldades, et failide suurusi mõõdan ma ikka 1024 kordsetena nagu normaalne arvutikasutaja, tuleb välja et oma arust makstud 1000GB asemel saan ma kettale kirjutada 931GB andmeid ning 69GB jagu on mulle tünga tehtud! Protsentides oleks see umbkaudu 7% jagu.

Minnes edasi nüüd SSD ehk pooljuhtketaste juurde, siis asi on veel absurdsem. Ketastele peale märgitud suurused nt. 128GB väljendavad füüsiliselt kasutatavat andmemahtu, tegelikkuses on pooljuhtketaste omapäraks see, et osad plokid hapnevad kirjutustsüklite ammendumisel. Selle raviks on tarbija makstud ruumist eraldatud mingi hulk plokke, nt 8GB remap-imise jaoks. Kasutaja jaoks on seetõttu partitsioneeritav ainult 120GB:

lauri@localhost:~$ smartctl -i /dev/sda
smartctl 5.40 2010-10-16 r3189 [x86_64-redhat-linux-gnu] (local build)
Copyright (C) 2002-10 by Bruce Allen, http://smartmontools.sourceforge.net
 
=== START OF INFORMATION SECTION ===
Device Model: ADATA SSD S599 128GB
Serial Number: 00000000000000000082
Firmware Version: 3.1.0
User Capacity: 120,034,123,776 bytes
Device is: Not in smartctl database [for details use: -P showall]
ATA Version is: 8
ATA Standard is: ATA-8-ACS revision 6
Local Time is: Sat Apr 30 00:29:14 2011 EEST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
 
lauri@localhost:~$ fdisk /dev/sda
Command (m for help): p
Disk /dev/sda: 120.0 GB, 120034123776 bytes

Maakeeli tähendab see seda et makstud 128GB asemel saan ma kasutada vähem kui 112GB. Protsentides tähendab see umbkaudu 13% tünga. Remap ala suurus sõltub tootjast, ADATA omadel rohkem, OCZ omadel vähem. OCZ pooljuhtketaste jaoks leidus ka püsivara uuendamise tarkvara Linux jaoks erinevalt ADATA-st.

Kokkuvõttes üsna ebameeldiv kuidas tarbijaid lollitatakse numbritega …

No comment »

GNU/Linux based terminal-servers with SmartCard support


Our company has been dealing with GNU/Linux based terminal-servers for a while and in Estonia you run into issues with ID-card at some point. Estonian ID-card is a SmartCard which is used to authenticate person online and to give legally valid signature. With terminal-server systems issues arose immediately because PCSC-lite originally didn’t support any network transparency. With few hacks it is possible to do this and that’s what this post is about.

PCSC-lite is a SmartCard framework which allows multiple applications to use multiple cards. Applications use a UNIX domain socket to talk to the process which handles the cards. There also used to be a public shared memory file which was a complete showstopper for LTSP, but after poking the core developer Ludovic it was finally removed. In revision 5373 another important feature for LTSP was implemented, the user can also specify the path to the forementioned UNIX domain socket.

So obviously what you need to do is to run the daemon in the terminal, redirect the UNIX domain socket to the server and tell the application to use that custom path. With version 5 LTSP switched from unencrypted connections to OpenSSH which encapsulates X11 traffic and any other connections between server and terminal. OpenSSH does support redirecting TCP/IP sockets but not UNIX domain sockets altough required code changes are minor.

There was a project called streamlocal, which was basically a bunch of patches for OpenSSH 4.4p1 to allow UNIX domain socket redirecting, I updated the patch and made it available for OpenSSH 4.7p1. After that there were some major rewrites in the OpenSSH core so I didn’t bother porting and I started from scratch to have the bare minimum to make ID-card work. This resulted in hackish rewrites for OpenSSH 5.3p1 and 5.5p1.

LTSP5 uses LDM in the terminal to authenticate SSH connection after which it passes X11 session to the desktop session application on the remote machine. To enable the socket redirection I also needed to modify LDM to inject parameters to SSH client process. This patch is obsolete since LDM now officially reads environment variable LDM_SSHOPTIONS for exactly the same purpose.

There are packages available for Ubuntu 8.04 and Ubuntu 10.04. National Library of Estonia is using them to power their server and 50 VxL terminals. There’s a manual written in Estonian, you can try your luck with Google Translate. There was an article about our solution in Arvutimaailm, again you can try your luck with Google Translate.

PS: OpenSSH is reference implementation of the SSH protocol so incorporation of UNIX domain patches needs protocol standard change first. This could be pushed through Internet Task Engineering Force, so if anyone is willing to lobby them please let me know :)

No comment »

lskvm

I got so bored with doing ps aux and manual kill for closing a running KVM instance so I made this little nifty Python script to list all running KVM processes and allow killing them by index number.

Drop the code to /usr/local/bin/lskvm and make it executable:

wget http://pastebin.com/download.php?i=Ah9FRHu2 -O - -q |
  sed "s/r//" - > /usr/local/bin/lskvm
chmod +x /usr/local/bin/lskvm

Run the command just by doing:

lskvm

The output will be something like:

# PID   MP  Used  Alloc Executable         VNC   User Disk
1 3247  2   266MB 256MB qemu-system-x86_64       kvm  manpremo.bin
2 6382  4   1GB   1GB   qemu-system-x86_64 :1    kvm  debian-lenny.bin
3 10336 4   1GB   1GB   qemu-system-x86_64       kvm  nopidou.bin

Kill: 3

The command prompt will be waiting for the user to enter index here in the first column for a process to be killed. Return or Control-C cancels the prompt.

No comment »

Povi

Istun bussis, liikvel Tallinnast Tartu poole. Sülearvuti ei kipu seljakotis püsima ja levi jagub selle posti kirjutamiseks ning jääb ka ülearu. Peaaegu kaks nädalat on möödas eelmisest postitusest ja vahepeal on nii mõndagi juhtunud. Kogu aeg on kulunud sellele et tööd leida aga ma pole seda endale raasugi lihtsamaks teinud.

Jaanuaris mina ja mõned sõbrad asutasime ettevõtte nimega Povi Software OÜ. Selle kohta ma siin blogis polegi pikemalt kirjutanud. Povi alguseks võiks mingil määral lugeda 2006 aastat kui mina, Laur ja mõned teised tuttavad kogunesime Viru keskuse neljanda korruse raamatupoes. Üleskutse sai postitatud Pingviini foorumis ning eks sealt asi arenes edasi aeglaselt. Kõigepealt Estobuntu ja siis rakendused Estobuntu ümber. Reaalselt OÜ loomiseni jõudsime 2009 aasta lõpus.

Säärase ettevõte asjade ajamisega on tükk tööd – projektide ja koostööpartnerite otsimine, lepingute sõlmimine, arvete välja kirjutamine ja kõige selle otsa raamatupidamine. Kapitalistliku süsteemi ekspluateeritav tööinimene võib õnnelik olla et ta ei pea kogu selle jamaga tegelema :D

Hetkel on meil käsil mõned Django/Python projektid ning Estobuntu LTSP-ga seotu. Kui oled andekas tudeng ja otsid praktikakohta kus igapäevaselt kasutusel ainult Vaba Tarkvara siis võiksid meiega kontakti võtta. Väga andekatele lubaks isegi tüki ettevõtte osalusest :)

No comment »

Colourful command prompt

Remember Gentoo and it’s nice colourful command prompt? Append this to your users’ ~/.bashrc. The locaton to put this code varies from distro to distribution tough.

if [[ ${EUID} == 0 ]] ; then
  PS1='[33[01;31m]h [33[01;34m]W $ [33[00m]' 
else
  PS1='[33[01;32m]u@h [33[01;34m]W $ [33[00m]' 
fi

No comment »

Calculating disk geometry

When you come across various disk partitioning tools you might wonder what’s up with cylinders, heads and whatnot. Well this goes back to the old days when they actually meant something, 4 heads meant 2 platters and so on. Nowadays it’s just like an appendix that should have been cut out long time ago. This means that the disks are using maximum value those bits could use anyways like 255 for heads and 63 for sectors per track although there is no real disk with 127.5 platters!

So you have a disk which insist that it has 24321 cylinders, 255 heads, 63 sectors per track and 512 bytes per sector. Now to calculate the size of such disk you just multiply all those figures:

24 321 cylinders * 255 heads * 63 sectors per track * 512 bytes per sector = 200 047 034 880 bytes or 200 gigabytes

Now to create partitions, lets say with fdisk you need to have the number of sectors. So sector count for 64MB partition goes like this:

64 mebibytes * 1 048 576 bytes per mebibyte / 512 bytes per sector = 131 072 sectors

Note that 1 megabyte is 1 000 000 bytes and 1 mebibyte is 1 048 576 bytes!

No comment »

DELL D620 ja TELE2 netipulk (Huawei E1752)


Teisipäevasele Vaba Tarkvara klubi kogunemisele toodi üks DELLi sülearvuti ning TELE2 netipulk, täpsemini Huawei E1752. Peale oli lastud eelmine Estobuntu versioon (Ubuntu 9.10 põhine) ning netipulk mängis trikke. Kuna masin oli dokumentidest tühi siis peale mõningast näppimist tundus mõistlik värske Estobuntu 10.05 peale lasta. Hiljem selgus et üks USB port oli rikkis, mistõttu netipulk ei töötanud aga mis sest.

Esiteks panin paika DELLi jahutuse:

sudo apt-get install i8kutils
cat /usr/share/doc/i8kutils/examples/i8kmon.conf | sudo tee /etc/i8kmon

Sülearvuti sees oli ka Broadcomi bcm4311 võrgukaart, seega panin peale võrgukaardi firmware:

wget http://lauri.vosandi.eu/dists/estobuntu/karmic/binary-i386/b43-firmware-1.0_estobuntu1.deb
sudo dpkg -i b43-firmware-1.0_estobuntu1.deb

Netipulgaga oli nii, et mõnikord ta tegi modeswitchi ise, mõnikord mitte. Mälupulgana oli ta lsusb all indekseeritud tootja identifikaatoriga 0x12d1 ning toote identifikaatoriga 0×1446. Peale modeswitchi lülitus toote id 0×1001 peale. Selleks et olla kindel et lülitus toimuks paigaldasin ka usb-modeswitch paketi:

sudo apt-get install usb-modeswitch usb-modeswitchd-data

Teadmiseks teistele häkkeritele siis Udev reeglite tegemine või usb-modeswitchi seadistamine EI ole enam vajalik. Udev reeglid mis kõik automatiseerimise ära teevad on failis /lib/udev/rules.d/40-usb_modeswitch.rules

Lõpuks tegin masinale restardi ning seadistasin võrguhalduris TELE2 ühenduse ning kõik toimis nagu kulda.

No comment »

WiFi kaardid Ubuntus

Siin siis väike kokkuvõte situatsioonist võrgukaartidega Ubuntu all. Ehk säästab kellelegi aega! Selleks et kontrollida mis võrgukaart sul arvutis on, sisesta terminalis:

lspci | grep -i net

Tulemuseks on midagi sellist:

0c:00.0 Network controller: Broadcom Corporation BCM4311 802.11b/g WLAN (rev 01)

Broadcom

Kui tegu on Broadcom kaardiga, on situatsioon üsna paha. Broadcom pole avaldanud eriti palju dokumentatsiooni oma kaartide kohta mistõttu draiverite kvaliteet jätab soovida. Ubuntu 10.04 sees on b43 moodul mis on reverse-engineeritud Linksys ruuteri tüürelite baasil. Kuigi tüürel on olemas, siis sellest siiski ei piisa, vajalik on ka firmware mis võrgukaardis endas jookseb. Debiani pakett mis kõik raske töö ära teeb on olemas siin. Selle paketiga olen ma käima saanud võrgukaardid järgnevate kiibistikega: BCM4311, BCM4312. Varem on b43 tüürel põhjustanud arvuti kokkujoosmisi olles ühendatud krüpteeritud võrku, kuid praegu peaks situatsioon olema paranenud. Kui on probleeme siis võib mulle kirjutada-joonistada!

Intel

Intelil on oma open-source osakond kes Linuxi tüürelitega tegeleb seega Inteli võrgukaartidega eriti probleeme ei tohiks tekkida. Paraku võrgukaartide firmware on kinnise lähtekoodiga, samas Intel lubab neid binaare levitada. Ubuntus on Inteli võrgukaartide firmware juba kaasas.

Atheros

Atherose võrgukaardid on popid netbookides. Minu teada on nende võrgukaartide moodulid (ath3k, ath5k, ath9k) ja ka firmware avatud lähtekoodiga. Atheros ise tüürelite arendust vist palju ei toeta kuid on avaldanud piisavalt dokumentatsiooni, et Vaba Tarkvara kogukonnal oleks võimalik tüüreleid ise arendada. Probleemide esinemisel tasub paigaldada wireless backports pakett:

sudo apt-get install linux-backports-modules-wireless-lucid-generic

Ralink

Ralink on üks vähestest firmadest kes paneb rõhku avatud lähtekoodiga moodulitele (rt2500, rt73). Ralink võrgukaartide tugi on üldiselt väga hea. Probleemide korral kehtib sama soovitus mis Atheros puhulgi – paigaldada wireless backports pakett.

No comment »