Posts Tagged ‘server’

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

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