Archive for the ‘Computers’ Category

How to turn a T-Online S100 Settop Box into a Server

Tuesday, December 1st, 2009 by BEni

Over at my other posts here and here i described how to turn an IBM Netvista 2200 Netclient into a lowpower server and the problems i had with its “intresting” hardware (no bootloader, usb1.1, …).

After my server was down for a couple of weeks i started to look for a replacement system that consumes little power, is cheap and can run linux nicely. My search brought me to the T-Online S100 Settopbox. It was developed as a PayTV receiver but the program was discontinued so people are getting rid of their boxes. Little do they know that it makes a great server.

Where to get it? Look at Ebay, i got mine for 25Eur which is a good price for this piece of hardware.

The box features:

* 733 Mhz Mobile Celeron CPU
* 128MB Ram
* USB 2.0
* 100Mbit Network
* Power Supply built-in

Since it was used as a TV Box it also features a remote control, cinch sound-out, and various tv (scart, av) outs but no vga out.

So in order to install and configure the server a little hardware modification is useful. If you have a working distribution and know for sure that you can ssh into it once the machine booted, you can change the bios setting to boot from the external usb drive blindly. but since i built my distribution myself thats not part of this posting.

In order to use a monitor you need to build a special VGA cable. The pinlayout is mentioned over at the very useful page zenega-user.de. It states to connect some pins on the vga side, those are GROUND and according to this post you can connect 2,4,6 on the S100 side and 5, 6, 7, 8, 10 on the VGA side.

I soldered the cable and drilled a hole for the connector into the top of the box. Works like a charm. While you have your box open, remove the DOM (Disk on module) from the IDE-Slot.

Next step is to properly set the BIOS. On bootup you can enter the BIOS by pressing the DEL key. Its advised to update the BIOS to the latest (109 means 1.09) version. A local copy of the 109-Rom can be found here, it contains the actual .rom, a dos622 bootdisk image and the amibios updatetool. Password for the archive is: update. This post explains how to update the bios. I used the preinstalled version (107 i think) and updated it later through my linux with flashrom, see below.

When in your BIOS settings, use your keyboard (USB i might add) and cursor over to bootup settings, set “boot into Windows CE” to “no” and select your usbstick (which is attached in the back) as boot device. After saving your settings, the S100 should try to boot from your usbstick.

Now lets prepare the usbstick with a nice operating system. The following steps where executed on an IBM X31 laptop running Ubuntu 9.04 32Bit. You could run a virtual image (Virtualbox/VMWare) on Windows/Mac if you dont have a linux around.

We are going to prepare a Gentoo system for the S100 but until its ready to use we need to work on our buildsystem/hostsystem. If you never worked with Gentoo or a Gentoo install have the Gentoo Handbook open somewhere on the side.

First of all, we will need to download a decent stage3 tarball. So lets create a working directory and go for it. All lines starting with # are executed on your commandline/shell. I would work as superuser (Ubuntu: #sudo su) but its up to you to decide which steps need superrights and which ones can do without.

# mkdir -p /opt/s100gentoo && cd /opt/s100gentoo

Now we are getting the stage3 tarball, select a Mirror from here and look for a recent i686 stage 3 tarball.

# wget -c ftp://gentoo.inode.at/source/releases/x86/autobuilds/current-stage3/stage3-i686-20091124.tar.bz2

After the download finished we need to extract the tarball

# tar xjvpf stage3-i686-*.tar.bz2

Now we have the base of our system in /opt/s100gentoo. In order to install and configure it apropriatly for the S100 we will use an chroot environment. I created a little script which mounts the necessary devices into the environment and cleans up after usage. Edit the file “startGentoo.sh” and put the following contents into it:

#!/bin/bash
cp -L /etc/resolv.conf /opt/s100gentoo/etc/
mount -t proc none /opt/s100gentoo/proc
mount -o bind /dev /opt/s100gentoo/dev
chroot /opt/s100gentoo /bin/bash
umount /opt/s100gentoo/proc
umount /opt/s100gentoo/dev
echo "done"

Now make it executable and start it (root needed)

# chmod +x startGentoo.sh && sudo ./startGentoo.sh

And taadaa, the terminal should have changed to something like

hostname / #

. To distinguish between inputs IN the chroot environment and the hostsystem i will use

c #

for chroot commands and

#

(as used before) for the host system.

First lets configure the chroot system then update the components and finally install userspace applications. Check if you can connect to the internet (ping or something) and if not consult the handbook for tipps.

c # env-update && source /etc/profile

You might want to set a password for the root user, too

c # passwd

Next edit your

/etc/make.conf

according to your needs using your favourite editor (like nano or vim). My make.conf is attached at the end of the post.
Next we will update the portage tree, select a profile (10.0 hardened), update the system and install some useful apps.

c # emerge --sync --quiet
c # emerge -av portage
c # eselect profile set 5
c # emerge -Dav world
c # rc-update add sshd default
c # rc-update add net.eth0 default

The last step will take longer but i happened to come across some Illegal Instructions so recompiling the whole system with the new -march settings is a good idea.
Now its time to install some useful applications. Its up to you what to install, you can look for programs by using

c # emerge --search foo

The following apps are installed on my machine (from the top of my head):

c # emerge -av dhcpcd screen rtorrent lighttpd pciutils usbutils \
libftdi irssi openssh openvpn sudo ccache grub sqlite git subversion \
gentoolkit gitosis php zlib

Some packages might depend on each other so you have to install them seperatly (one first, then the other, play with the USE variable or mask other packages. See handbook).
You need to configure all the packages accordingly, since every system differs this is not part of my tutorial. Configuring /etc/fstab and /etc/conf.d/net is mandatory for the system to boot later.
Next big todo is building a kernel. I attached my 2.6.31 config at the end, it works but might not be the most optimized. In order to build your own kernel you need to get the kernel sources copy my .config there, create a symlink and make it.

c # emerge -av gentoo-sources
c # cd /usr/src/linux-2.6.3*
c # wget http://blog.chris007.de/wp-content/uploads/2009/12/config.txt
c # mv config.txt .config
c # make -j2

I attached my kernel at the end. I tried to build everything necessary into the kernel since im not a big fan of modules. Once the kernel built correctly you need to copy it to your boot directory.

c # cp arch/x86/boot/bzImage /boot/kernel-2.6.31

If you want to use AuFS (like for /usr/portage) to safe some space you need to patch your kernel sources.

c # cd /usr/src/
c # git clone http://git.c3sl.ufpr.br/pub/scm/aufs/aufs2-standalone.git aufs2-standalone.git
c # cd aufs-standalone.git
c # git checkout origin/aufs2-31

Now follow “3. Configuration and Compilation” (apply two patches, copy files to linuxsource, build it with approriate .config) on the official AuFS page. See my /etc/fstab on how to use AuFS.

Another important change is related with the frontpanel leds. To tell them to stop blinking after bootup edit the file /etc/conf.d/local.start which will get executed after bootup and before the userprompt. Put the follwing into it:

# stop the frontleds from blinking
echo "disabling LED blinking"
/bin/stty 38400 cs8 -parenb -cstopb -F /dev/ttyS1
echo -e '\xa2\xb2\xa2\xb2\xa2\xb2' > /dev/ttyS1

If you plan to update the bios from within linux you can install flashrom already via svn:

c # cd /root
c # svn co svn://coreboot.org/flashrom/trunk flashrom
c # cd flashrom
c # make

Later (beeing on your S100 running linux nicely) you can update your BIOS with the following command (assuming you downloaded the BIOS.bin to the current folder):

# flashrom -w BIOS_109.ROM

Make sure it verified ok, if you have questions visit the official page here or ask the nice guys in #flashrom@freenode.

After this step we are ready to prepare the usbstick with our fresh system and test everything. Leave the chroot (exit) and become root (if not already happened). Put the desired usb stick in a free usb port (im using a 4GB usb2.0 stick, costs about 10Eur), see which device it gets mapped to (dmesg and look for /dev/sd*1) and unmount the device if your system automatically mounts it (umount /dev/sdc1). In my case im referring to /dev/sdc as the usb stick and /dev/sdc1 as the first partition on the stick.
CAREFUL ATTENTION DANGER. If you use a wrong device, you might end up with an empty harddrive. Just wanted to mention that all operations are at your own risk
Next we will format the stick using fdisk

# fdisk /dev/sdc

In case there was a partition on the stick, delete it (d, 1) and create a new primary one (n, p, 1,enter, enter, t, 83, enter) and check (p) that the stick contains a partition using the whole space of type linux. Make it bootable (a,1) and write the changes to the stick (w).
Next we will create an ext2 filesystem on the device using an high number of inodes and a small blocksize (because we will be having lots of little files). This step might take a while

# mke2fs -b 1024 -I 128 -L "root" -i 1024 /dev/sdc1

After the filesystem was created we mount the stick to /mnt and copy the filesystem over. You might want to edit your /opt/s100gentoo/boot/grub/menu.lst, mine is attached at the end. The delayroot wait is essential so the kernel can detect the usbstick.

# mount /dev/sdc1 /mnt
# cd /opt/s100gentoo
# rsync -a . /mnt/
# echo '(hd0)  /dev/sdc' > /mnt/boot/grub/device.map
# grub-install --root-directory=/mnt /dev/sdc

Now you should have a bootable usbstick loaded with your own gentoo system and grub installed. Plug it into your S100 and boot it up. Hopefully it will work like a charm and ask you for a username and password. If not, happy debugging.

Because the box only features 128Mb of ram and some buildoperations (like glibc) need a bit more (will throw weird error messages otherwise) i grabbed an old 2GB usbstick (allthough like 256MB would probably suffice) and turned it into swap. I know it will eventually brake because of the limitted amount of write cycles but then again, its like 2eur. Format the stick with fdisk like above but use the type 82 (Linux swap), write changes with “w”. Then use mkswap to make the partition into a swappartition and swapon to actually use it. Change your /etc/fstab accordingly and you should be all set.

Below you will find some links which were useful for me and the output of some commands directly from my server. Also you will find some essential configs.

In case you run into any problems feel free to comment here or contact me directly.

Links:
- s100 Linux modification
- Flashrom
- Zenega Community
- AuFS
- German site

Files:
- /etc/fstab
- /boot/kernel-2.6.31
- /usr/src/linux/.config
- /boot/grub/menu.lst
- /etc/make.conf
- lspci
- top
- uname -a
- cat /proc/cpuinfo

How to boot a decent Kernel on your IBM Netvista 2200 (8363)

Tuesday, November 17th, 2009 by BEni

So over at this post i described how to in general get linux running on this device.

Since i had some issues with my usbcluster (lvm over 4 usbsticks) i wanted to update udev, which in current versions needs a kernel beyond 2.6.27. Building a 2.6.31 first failed, i searched the net a bit and emailed some people and finally got a response from antonio (big thanks again) forwarding an email from Georg Schiesser who located the troublemaker.

Once again its the missing RTC. Because of the following lines, kernels beyond 2.6.24* wont boot:

arch/x86/kernel/rtc.c:
/*
* If UIP is clear, then we have >= 244 microseconds before
* RTC registers will be updated.  Spec sheet says that this
* is the reliable way to read RTC - registers. If UIP is set
* then the register access might be invalid.
*/
while ((CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP))
cpu_relax();

Disabling the last two lines helped. So you have to comment them out, as well as the known patches.

These are:

drivers/video/geode/gx1fb_core.c

replace the line
static char mode_option[32] = "640x480-16@60";
by
static char mode_option[32] = "1024x768-16@60";

and

arch/x86/kernel/setup.c

replace
ROOT_DEV = old_decode_dev(boot_params.hdr.root_dev);

by

ROOT_DEV = Root_SDA1;

Watch out, normally you hardcode Root_HDA1 which is the CF card with the old ATA drivers. In my kernelconfig im using ATA SFF which maps the CF card to SDA1 and any usb devices to /dev/uba1 and so on. Play with the drivers at own will. You can also disable DMA by changing

drivers/ata/libata-core.c

static int libata_dma_mask = .... to static int libata_dma_mask = 0;

after building your kernel, take the file “vmlinux” from /usr/src/linux/arch/x86/boot/compressed (with linux -> linux-2.6.31/, i used the vanilla sources) and binary patch it. source i found somewhere is attached. copy it to your /usr/src/linux directory, build it (gcc -o patch.app patch_nvista.c) and start ./patch.app. it should patch the right file and copy the output to /usr/src/linux/kernel.2×00. Use that file to boot.

Problems i am still facing: the new kernel wont boot of my 8GB CF card and i dont want to strip my RootFS that much (next working size is 2GB :(). Im trying to solve that by using a busybox init which mounts an usbstick which contains my rootfs. Disadvantage: its wicked slow! Kind of working version is attached as tar.gz. Just unpack that to a relativly small CF Card and edit to your needs.

Second problem which kind of led to my “solution” with the busybox init is that there seems to be some cache-limit the kernel runs into. I just couldnt boot anything beyond 2.5MB (tried embedding an initramfs directly into the kernel but it got too big). So keep that in mind.

Since i dont have enough time right now to test any further this blog entry can be seen as a share of information “as is”, so that people can work on it and with it to get their babies a decent kernel. Feel free to contact me tho if you have any questions!

- config_linux_2_6_31
- patch_nvista
- initramfs

Using Opentracker - a free, small, fast and powerful tool

Sunday, February 22nd, 2009 by BEni

What is a tracker in this context? In order to expain that, i need to explain the bittorrent protocoll a little.

Bittorrent as a great and fully legal concept to exchange data. The bad things you hear in the media are cases where people used this concept to exchange data which has copyright on itself.

The principle is quite easy. You install a bittorrent client, download a small file which contains all the necessary data (ending normally .torrent), tell your client to process that information and it will start to transfer files with other people who want or have that file. So if you made your own movie and want to share it, but are short on bandwidth and/or transferlimit you could make a torrent and in the best case have to share the movie once. Then after taking it down, other peers (people who take part in the sharing) will exchange the parts they have and need. So with higher distribution of your file, new leechers (people who download stuff) will face higher availibilty and probably more downspeed.

But how do peers know which others peers have and offer parts? Thats where the tracker joins the game. The tracker is a central point of communcation (its adress is located in the .torrent file, mentioned above) where all clients connect to (via http) and receive information about other clients. There are some so called “open trackers” that allow everybody to announce their files but this article is about the software “opentracker” which allows you to run your own tracker.

In order to get your own tracker you need to download, configure, compile and run the software. All ressources and steps can be found here: opentracker homepage. In short: check out from cvs, edit the Makefile to enable/disable features (for example whitelisting), make, run. You need the libowfat library in order to build opentracker.

Now to run your tracker you need to call the binary. Along can be passed some arguments, that will change its behavior. To tell the tracker to listen on the port 4321 (instead of 6969 by default) and use whitelist.txt as whitelist run:

./opentracker -p 4321 -P 4321 -w whitelist.txt

The file “whitelist.txt” contains the hash of each torrent you want to allow, seperated by a newline.

If you are running your tracker behind a router of firewall, be sure to forward/allow the port you have your tracker listening to.

Opentracker also supports some stats. The URL for stats is

http://trackerdomain:port/stats?mode=

followed by the mode you want to know. It could be: peer, conn, scrp, udp4, busy, torr, fscr, herr, top10, renew, syncs, version, startstop, toraddrem.

This information is taken from ot_http.c at about line 160, look for “static ssize_t http_handle_stats(”. If you want to restrict access to your stats, remove the comment (#) in the Makefile in front of “FEATURES+=-DWANT_RESTRICT_STATS”. Opentracker also supports mrtg for visualisation of statistic data.

To quit opentracker, just kill it (ctrl+c or kill -9 <pid>).

Too bad there is only little to no documentation about this great piece of software. But its so efficient with ressources that even The Pirate Bay uses it for their trackers, and they are the “worlds biggest tracker”.

Linux is quietly braking my harddrive

Wednesday, October 8th, 2008 by BEni

So i wondered if linux could be the reason for my laptop battery draining so fast. During my search through the web i found this intresting Article: German Ubuntu-Wiki on Harddrivebug

Because of a bug in the acpi-settings, harddrives in laptops are told to park their read/write head, allthough there is no need to while beeing on AC. In order to save battery it makes sense to park the head while in batterymode though. Since the parking procedure is limitted bei abraison, its good to help the hardrive survive.

This can be achieved by installing a script which checks if the laptop is running on AC or battery and then uses hdparm to set the harddrive into power saving mode or not. Its described in the above mentioned link here.

I have a rather new harddrive in my laptop (IBM X31) which i leave on AC practically 24/7. I just checked with the following command:

sudo smartctl -A /dev/sdX | grep -E "(Load_Cycle_Count|ID)" && date

and the outcome is a little concerning:

root@x31:/# smartctl -A /dev/sda | grep -E "(Load_Cycle_Count|ID)" && date
ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
193 Load_Cycle_Count        0x0012   001   001   000    Old_age   Always       -       1593642
225 Load_Cycle_Count        0x0012   001   001   000    Old_age   Always       -       1593642
Wed Oct  8 20:42:53 CEST 2008

RAW_VALUE is the actual count of parkings the head did in his lifetime. Manufacturers claim that harddrives have between 300k and 600k cycles. I already have 1.6M.
VALUE should be 100, the closer it gets to 0 the more cycles the head had and the more likely a harddrive crash is.

After applying the patch and rebooting i havent had a single parking yet, lets see if now the temprature of the harddrive becomes a problem. Im definatly overdue for a big backup!

My advice: do the patch, or at least check your cycles!

Turning an IBM Netvista 2200 (8363) into a server

Monday, August 18th, 2008 by BEni

So i have been on the hunt for a tiny PC which i could turn into an always-on server for a while now. I played with an Compaq IA-1 (check out ia1-hacking and linux.boeldt.net) but since it lacks an ethernet device (and let me asure you, usb-ethernet is way slow, escpecially on usb1.1) it was kind of unhandy as a fileserver. The well known ’slug’ (look for NSLU2) is another alternative but rather pricey.

Ive had my eye on some netclients (normally just networkcards with a graphicsadapter and you connect it to a powerfull mainframe) but never found one in my pricerange (less than 50 Eur). Then i came across the IBM Netvista 2200 (8363) which met the following requirements:

- PC compatible architecture with reasonable horsepower
- diskless operation (e.g. through compact flash)
- USB Ports
- small power consumption
- builtin fast ethernet (10/100mbit)
- stylish outfit since it will be placed on my workdesk

There are a couple of models (Netvista 2800, etc.) which have more power, a real pci-slot or more diskspace. But they are also more expensive so back to the 8363.

Some people get confused with the different series there are. You can identify the serie by looking at the serial number (surprise!). Some models end with -Exx (xx as a placeholder), other with -Wxx and again others with -Txx. All feature the same hardware more or less, but a short explanation:

-Exx: the _E_thernet model. It comes with an ethernetcard and the regular hardware

-Wxx: WindowsCE model. On this machine its possible to run WindowsCE. It features ethernet and i think a bigger internal storage disk

-Txx: Tokenring model. This model has a Tokenringcard plugged into the ibm-pci-slot IN ADDITION to the ethernetcard.

Thats an important fact since a lot of people on the internet think that the -Txx model only features Tokenring (which nobody uses anymore, read more about it here: wikipedia), which is not true. The tokenringcard is plugged in an pcislot that looks like it is some proprietary port from ibm. One screw and its removed and you have a good -Exx model. And most of the time the -Txx models are way cheaper (since nobody knows).

So i received my model and turned it on. It tried to boot via network. But it worked!

The netvista features an builtin CompactFlash-Slot from which it can even boot. So my plan: build a linuxkernel and a filesystem and put it on the CF-Card, boot the system, mount my external USB-Hdd, start a web and ssh server and provide some php scripts to the net. Let me tell you, after some tinkering it works great!

In order to boot from the CF-Card you need a BIOS that supports this feature. To enter the BIOS keep on hitting ESC or ENTER until it shows up. Check the version it should at least say:
If you have an older BIOS (which doesnt support booting from Flash) you need to update your BIOS. You can either boot the updatefile via net or put it on a CF-Card. I chose the later since i didnt want to setup a networkbootserver. You need a FAT or ext2 formatted CF-Card which contains the bflash.2200 file (name must be exactly this!). You can obtain the file directly from IBM or through the links mentioned here. When booting the machine, it detects the updatefile and asks you if you want to update. You want to. Dont turn of the machine now or disturb it until its all the way done.

Congrats, you can now select ‘Flash’ as a bootdevice in your BIOS. In principle the things are straight forward from now on. You need a file named kernel.2×00 in your rootdirectory (remember ext-filesystem!) which will be booted by the builtin bootloader.

A short word on 2.4 vs. 2.6: since IBM created the firmware for 2.2 and 2.4 kernels they are much easier to use.

But its also possible (and desireable) to use a 2.6 kernel. In order to do so, you need to patch the kernelbinary, patch the geode-video-driver source and remember to configure the kernel properly. this describes this process. You will find patches, kernelconfigs and instructions also here. Thanks to both i got my stuff running!

Im running a 2.6.24.3 kernel with the kernelconfig attached below. Somehow building an initramfs into the kernel woudlnt work (i assume it messes with the headers and therefore the IBM cant boot the image). My rootfs is a gentoo stage3 tarball with the latest portage (on how to install gentoo see the gentoo handbook and for tiny systems gentoo wiki or this). Additional packets i installed are e.g. lighttpd, php, sqlite, sshd, dhcpd, screen, cron, pciutils usbutils, …

Here are some files you might want to have a look at:
/etc/make.conf
/usr/src/linux/.config
/etc/fstab

Output of:
lspci
dmesg
top
df
uname -a
cat /proc/cpuinfo

As you might have noticed i added 128MB of PC133 SD-Ram (168pin) to the internal 32MB. There is a normal slot, so opening the device is highly recommended! Furthermore i plugged in a 1GB USB-Stick to one usbports and made it /home. /data is the external harddrive which also provides a little swapspace (barely used).

To sum things up, im very happy with this stylish little box running gentoo at a decent speed (i was to lazy to crosscompile the packages, i think it took about 50h to compile everything but i had the time. Just remember to emerge screen first!), providing all the services i need. The powerconsumption is ok, my router, modem, external harddrive and server together need about 38W. For this price (15Eur at ebay) a really good setup.

Other links:
- http://www.dingeldein-online.de/computer/netvista/netvista2200.html
- bluetrait
- http://www.freigeister.org/n2200.htm

- http://estate.moaworks.com/rwachinger/NetVista/index.php?location=0.3

- http://michaeldale.com.au/archive/2005/08/07/installing-linux-2200-onto-the-ibm-netvista-n2200-8363/#comments

UPDATE!
I managed to get a 2.6.31 Kernel booting, check my new post here