Minecraft on Linux

Minecraft Logo
I struggled to get Minecraft up and running on my laptop (Ubuntu 10.04). I copied an older user folder from a windows machine, and nothing worked – I only got a black screen after starting the game. This seems to be quite common, and seems to be cause by library mismatches.

There are a million complicated howtos out there how to fix this, but for me it was sufficient to let Minecraft re-download all its libraries:

$ rm -rf ~/.minecraft/bin

Then, start the game and wait for the download to finish. Et voila!

The folder on windows is %APPDATA%\Roaming\.minecraft\bin\. An alternative route is to select “force update” in the Minecraft option screen.

Dell DRAC/Remote Console discoveries

1. Logout else lockout

The system has usually a limited number of users, and if you don’t logout properly multiple times you find yourself in the position that all slots have been taken. In this case, you have to wait for a timeout…

2. Firefox & Java

On Linux, the only supported browser is Firefox. On standard Ubunut, this does not work in combination with the DRAC as Ubuntu installs the Icetea Java plugin by default. Switch to the Sun Java plugin:

sudo update-alternatives --set mozilla-javaplugin.so /usr/lib/jvm/java-6-sun/jre/lib/i386/libnpjp2.so

3. Firewalls

On many systems, you will have problems to access the DRAC (or at least the remote console) because of firewalls in your way. You can forward the whole thing by using a host inside the network as an proxy. For this, you have to tunnel the connections through SSH as follows:

sudo ssh -L 443:<DRAC_IP>:443 -L 5900:<DRAC_IP>:5900 -L 5901:<DRAC_IP>:5901 -l <LOGIN> -N <SSH_PROXY_SERVER> -o ExitOnForwardFailure=yes

Update: I created a project page for my server.

Those darn fans!

As I explained before, I changed all the fans of my PowerEdge 2800 to low-noise, low-RPM models.

Fans of a PowerEdge 2800

The fans of my PowerEdge 2800. Front the cpu fans (stock Delta left, replacement everflow right); at the back the 120mm case fans (left the Artic, right the stock Nidec)

This was nice and shiny, and the system was quiet and quite cool. Too cool unfortunately, because the BMC throttles the fans too much so that their RPM values go below the configured thresholds. Then, the system goes into panic mode, spins up all fans at 100%, and lowers them successively below the threshold again. Repeat. :)

I ended up putting the Delta’s back in, because you cannot configure the lower failure threshold of the fans. So, lots of work for nothing, and the system is still way too loud. Very unsastifactory.

Thus, I started thinking how to get around this problem. Possible ways I see:

  1. make the fans faster/buy faster fans
  2. make the system hotter
  3. hack the fans into reporting more RPM than they actually do
  4. hack the BMC
  5. find out how the OEM sets these thresholds

Well, 1. and 2. are for obvious reasons dissatisfactory.

Regarding 3: I thought about getting the sensor in the fan to report a higher value. Most fans actually consist of a ring-magnet. The sensor lies just below it, with the rotating magnet passing over it. On 1-4 places on the magnet, the manufacturers apply some paint. I guess it’s some sort of EMI shield and the sensor detects the change in the field – but I couldn’t find any paint that would reproduce the effect. This would be a very neat and nice solution.

Regarding 4: The BMC is implemented in some microcontroller on the motherboard of the PowerEdge. I haven’t found out yet where it is. I am not even sure what type of architecture it is, so reverse engineering the BMC firmware wasn’t possible. Damn, I don’t even know if this is little-endian or not.

Regarding 5: The manual states that these values are read-only and are to be configured by the OEM. But how? I doubt that they create a new firmware for each combination of fan manufacturers that they use. So my guess is that there are some hidden OEM IPMI commands that allow to set the threshold. I asked the guys over at FreeIPMI if they’ve got a clue, but they don’t know about any such functionality.

Anyone out there with some hints?

UpdateI continued my search for a solution

Update 2

I finally managed to adjust the critical fan thresholds by patching the BMC firmware! Here’s the howto. Additionally, I created a project page for my server.

Mute sound on screen lock

My coworkers got annoyed that my music continued playing when I was away from my desk. As I am anyways locking the screen automatically after 5 minutes (if I forget to do it by keyboard shortcut), I thought I might use this event for muting as well.

Below is the script I came up with. It needs the inotify-tools (sudo apt-get install inotify-tools) to work. Thanks to Vermind on the ubuntuforums for figuring out the mute stuff!

The advantage of this script is that it works with the auto-lock of the screensaver as well as the pre-configured shortcuts for screen locking.

#!/bin/bash
################################################################################
# mute-on-lock.sh
# Mutes sound and pauses amarok when the screen gets locked
# Version 1.0
#
# written by Arnuschky, mute stuff by Vermind (ubuntu forums)
#
# http://ubuntuforums.org/showthread.php?t=1364597
################################################################################

########################################
# Settings
########################################

mute=1            # Mute the sound while locked. 0=do not mute.
amarok=1          # Pause/unpause amarok on lock
card=0            # Sound card. 0 == default, first card.
channel="Master"  # Which volume to control. Examples: Master, PCM, Headphone
step=3            # Fade step: The volume increment/decrement amount
interval=0.2      # Seconds between increments/decrements when fading


########################################
# Functions
########################################

# get current volume
function getvol {
    vol=$( ${m} sget ${channel} | awk '
$0 ~ "%" {
    if ($4 ~ "%") {
        print $3;
    } else if ($5 ~ "%") {
    print $4;
    exit 0;
    }
}'
)
}

# fades volume up or down
function fade {
    # get current volume
    getvol
    if [ "$1" == "down" ]; then
        # fade down:
        while [ ${vol} -gt 0 ]; do
            ${m} set ${channel} ${step}- >/dev/null
            let vol-=${step}
        sleep ${interval}
        done
        ${m} set ${channel} mute >/dev/null
   else
       # first unmute, then fade up
        ${m} set ${channel} unmute >/dev/null
        while [ ${orig} -gt ${vol} ]; do
            let vol+=${step}
            if [ ${vol} -gt ${orig} ]; then vol=${orig}; fi
            ${m} set ${channel} ${step}+ >/dev/null
            sleep ${interval}
        done
        ${m} set ${channel} ${orig} >/dev/null
   fi
}

########################################
# Startup
########################################

if [ "${mute}" == "1" ]; then
    # short mixer command with card
    m="amixer -c ${card}"
    # record original volume value
    getvol
    orig=$vol
fi

########################################
# Loop                                 #
########################################

# start dbus monitor
monitorfile=`mktemp`
dbus-monitor --session "type='signal',interface='org.gnome.ScreenSaver',member='ActiveChanged'" &> ${monitorfile} &
pid=$!

# loop on changes on the monitorfile
while inotifywait -e modify ${monitorfile} &> /dev/null; do
  # on file change, grab the last line and filter it
  lastline=`tail -n1 ${monitorfile}`
  echo ${lastline} | grep -e "boolean true" -e "boolean false" &> /dev/null
  if [ $? -ne 0 ]; then
    continue
  fi

  # grab the lock state and act on it
  lockstate=`echo ${lastline} | sed 's/^.*boolean \(.*\)/\1/'`
  if [ ${lockstate} == "true" ]; then
    if [ "${mute}" == "1" ]; then
      fade down
    fi
    if [ "${amarok}" == "1" ]; then
      amarok --pause
    fi
  elif [ ${lockstate} == "false" ]; then
    if [ "${amarok}" == "1" ]; then
      amarok --play
    fi
    if [ "${mute}" == "1" ]; then
      fade up
    fi
  fi
done

# kill monitor & cleanup
kill $pid
rm -f ${monitorfile}

exit 0

How to install this? Put it into e.g. /home/youruser/bin/mute-on-lock.sh. Then, go to System -> Preferences -> Startup Applications and add your script. Log in& out and you’re done!

Replacing the fans on a Poweredge 2800

Fans of a PowerEdge 2800

The fans of my PowerEdge 2800. Front the cpu fans (stock Delta left, replacement everflow right); at the back the 120mm case fans (left the Artic, right the stock Nidec)

My “new” PowerEdge was way too loud. Like, jumbo-loud. I’ve chosen to replace all the fans with quieter models, but oh boy, this turned out to be a major pain! As always, I didn’t follow the most important rule when tinkering: do stuff incrementally, and test after each step. Well, maybe I’ll learn someday.

For reference, here the fan models:

Funtion Dell Replacement
4x Memory/Disk, 120x120x32mm, PWM Nidec Beta V TA350DC, M34789-35 Arctic F9 PWM
2x PSU, 60x60x25mm, Tacho Nidec Beta V TA225DC, B34605-33 Akasa AK-192BKT-B
2x CPU, 60x60x35mm PWM Delta AFB0612EHE Everflow F126025BU

I’ve changed all the fans in one go and ended up with a system that didn’t boot anymore. It didn’t even get to the end of the BIOS initialization, it shut down directly. I gathered that it must be the power supply’s fans (else I would have had a warning message on the POST). I’ve checked and I realized that I bought some fans with a build-in thermal control; a sensor that slows down the fan rotation. Well, as I had them already I hacked them up to ignore the sensor (cracked open sensor casing, soldered two pins together; no resistance acts as if the sensor measures a very high temperature).

Connector for PowerEdge 2800 fans

The connector with the soldered cables of the everflow fan. Here, the yellow and blue cable on the connector has been switched.

Next problem was that all fans spun at full speed. Impressively noisy, even for a seasoned cluster admin as me (I could hear the vibration 2 floors below). The reason were swapped PWM and Tacho pins (as I’ve found out after trying for a night to install Dell OpenManage 6.4 on Ubuntu 11.04 64bit). I don’t know why, but I needed different PIN configurations that every other source I’ve found on the Internet. Here’s what I’ve used in the end (This is looking on the bottom of the connector):

+---+---+
| 2 | 1 |-+
+---+---+ |
| 4 | 3 |-+
+---+---+
Pin Funtion Dell Everflow Arctic
1 VCC red yellow red
2 Control/PWM blue blue blue
3 Sense/Tacho yellow green yellow
4 Ground black black black

So everything is exactly as in the datasheets, except the swapped Control and Sense pins. After I’ve swapped them, the server became quite quiet and I quite happy. :D Actually, my desktop is now more noisy. Argh! BTW, thanks a lot to Brent Ozar for his blog entry on making a power edge quieter.

Update

Now I seem to have another problem: as reported by Brent Ozar and others

One problem shown above is that sometimes fans spin slow enough that they trigger Dell’s thresholds for slow-moving fans. Gotta figure out how to fix that for good one of these days.

Damn. Now I either have to find a way to make the fans a little bit faster or to change the threshold. See the follow-up post for more info on the threshold problem.

Update 2

I finally managed to adjust the critical fan thresholds by patching the BMC firmware! Here’s the howto. Additionally, I created a project page for my server.

Installing Dell OpenManage on Ubuntu 11.04 64bit

Installing Dell OpenManage 6.50 on Ubuntu 11.04 64bit (Meerkat? Olifant? damn names) was a pain. Mostly because Debian-based systems are only supported since recently and thus there is too much outdated info out there (mostly grisly hacks how to force the rpm-based install to work on your system).

Thus, here a very quick summary:

  1. Follow instructions on this page:http://linux.dell.com/repo/community/deb/latest/
  2. Afterwards, in order to be able to authenticate, edit /etc/pam.d/omauth as follows:
    -auth required /lib32/security/pam_unix.so nullok
    -auth required /lib32/security/pam_nologin.so
    -account required /lib32/security/pam_unix.so nullok
    +auth required /lib/x86_64-linux-gnu/security/pam_unix.so nullok
    +auth required /lib/x86_64-linux-gnu/security/pam_nologin.so
    +account required /lib/x86_64-linux-gnu/security/pam_unix.so nullok

Surprisingly painless (if I would have had this information 5 hours earlier). Ah yes, don’t forget to open your firewall for port tcp 1311… :)

Update: I created a project page for my server.

New blog (a.k.a. the most creative post title ever)

Hey Internet,

finally, I had the time and motivation to install a  blog – planned this since a long time. I am doing a lot of tinkering on the side, plus working with Linux etc… Well, as I profit tremendously from what all you people out there published, I thought it’s only fair that I give something back. So this is intended as a loose collection of “projects”.

Over the next week I will (re)post mostly old projects. Edit: I discovered that I can back-date posts. All posts published before this post will be content I moved from my old site – so don’t be surprised about bad formatting and the like. Additionally, all these posts will be in the category ‘old site’.

Happy tinkering!

Reflashing a semi-bricked Hitachi/LG XBox 360 dvd drive

This app will flash single sectors in the Hitachi/LG firmware using debug flash erase/program routines that exist in the 3120L firmware. The difference to SeventhSon’s or the usual flashers is that it utilizes code that isn’t located
in one of the sectors that are changed when applying a hacked firmware. So if something went wrong during flashing, there might be a wee chance that the debug code works and can still be used to fix your drive.

All of this is based on Kev’s/SeventhSon’s work. I simply put together two of his programs to create a flasher that uses the Hitachi debug commands to flash sectors in the drive’s flash. All credit goes to SeventhSon. I even copied this text from his site. :) Unfortunately, his site vanished, so there are none of his notes left.

Use at your own risk, this may break your 360, 360 DVD drive and/or PC if done improperly (or if I happen to have made any mistakes).

Note: This does not work in recovery mode. This tool only helps if your checksum was patched (reports ok), but flashing does not work due to overwritten upload/execute handlers. If you don’t know what I’m talking about, leave it be.

Warning: This app is an interim solution intended only for hackers who know what they are doing. It is very easy to kill your drive with this program. If you fail to update the firmware checksum before you power down the drive, you will break your drive. If you overwrite any of the upload and execution command handlers with broken code, you will break your drive. If you overwrite your flash entry point code, you will break your drive. If you overwrite the sector containing your AES key without backing up your key first, you will break your drive and will not be able to repair it. If you do not understand everything that I just said, then this app isn’t for you.

Download

Flashing sectors in the Hitachi/LG drive’s firmware from a PC

In the following examples encrypted_fw.bin is a full firmware dump. It must be encrypted. Encrypt it after you make your changes and before you run the flasher. There are tools somewhere on the internet that allows you to de/encrypt firmware images. So, encrypted_fw.bin would be created like so (in Windows),

C:\> memdump_win e 12200 8 8000 firmware.bin

(then modify your target sector within firmware.bin)

C:\> FirmCrypt e firmware.bin encrypted_fw.bin

(then flash the modified sector as per the examples below)

You will almost certainly break your drive if you do not encrypt the firmware image before flashing.

The next argument is the address of the target sector in the MN103’s address space in hexadecimal. Just add 0x90000000 to the sector’s offset into the firmware dump to get this value. The final argument is the sector size. The 3120L erase/program routines support a few devices, some appear to have 8KB sectors (0x2000 bytes), others 4KB sectors (0x1000 bytes). My drive has a SST39SF020A flash device (with 4KB sectors). I’m not sure if any Hitachi-LG drives exist with a different chip, but my app supports them just in case. Make sure you specifiy the sector size in hexadecimal.

Please. Don’t use this app if you don’t understand all of the above.

Linux example:

$ ./debug_flashsec /dev/sdb ./encrypted_fw.bin 9003F000 1000

Windows example:

C:\> debug_flashsec_win e encrypted_fw.bin 9003F000 1000

Note that the drive does not restart after each sector flash, nor does it need to be restarted. So you can change multiple sectors in one sitting. For example, a typical session might look like this (in Windows)

C:\> debug_flashsec_win e encrypted_fw.bin 90006000 1000
C:\> debug_flashsec_win e encrypted_fw.bin 90010000 1000
C:\> debug_flashsec_win e encrypted_fw.bin 90027000 1000
C:\> debug_flashsec_win e encrypted_fw.bin 9003E000 1000

This example shows 3 sector changes followed by a final sector change to update the firmware with a new correct checksum value. This final checksum update flash must always be performed unless you actually want the checksum to fail the next time your drive powers up (which will leave you stranded in recovery mode, not a great place to be).

TraMoS – Traffic Management over SNMP

General Info

This software allows to query, display and administrate Linux traffic shaping rules over SNMP. TraMoS was a project I did at university, and I used it for a while at home.

The server-side is based on SNMP (d’oh), tc and htb. More infos on the underlying Linux software can be found at the Linux Advanced Routing howto. I wrote the server side, which consists of a SNMP daemon interfacing with NET-SNMP, in C.

The client is a Java Swing client that allows to graphically administrate hierarchical rulesets. It has been written by a collegue of mine.

Download TraMoS

Unfortunately, I’ve lost the final version of the documentation, but here’s the final, working software:

Required SNMP Server

The project requires Net-SNMP as a base daemon.
Net-SNMP includes everything required (libraries and the like). The server side part of TraMos is an extension to Net-SNMP.

MIB Module Informations

Our own OID prefix is: 1.3.6.1.4.1.19399.8.42

As the hierarchical structure of the HTB traffic shaping classes could not be directly modeled in a MIB tree, all classes are mapped to flat tables in the tree.

Download MIBs

Here’s the MIB tree:
+--traMIB(1)
   |
   +--traIfTable(1)
   |  |
   |  +--traIfEntry(1)
   |     |  Index: traIfID
   |     |
   |     +-- -R-- INTEGER   traIfID(1)
   |     |        Range: 1..2147483647
   |     +-- -R-- String    traIfName(2)
   |     |        Size: 0..255
   |     +-- -R-- String    traIfComment(3)
   |     |        Size: 0..1024
   |     +-- -R-- INTEGER   traIfTraffic(4)
   |              Range: 0..2147483647
   |
   +--traClassTable(2)
   |  |
   |  +--traClassEntry(1)
   |     |  Index: traClassIfID, traClassID
   |     |
   |     +-- -R-- INTEGER   traClassIfID(1)
   |     |        Range: 1..2147483647
   |     +-- -R-- INTEGER   traClassID(2)
   |     |        Range: 1..2147483647
   |     +-- -R-- INTEGER   traClassParent(3)
   |     |        Range: -1..2147483647
   |     +-- -R-- String    traClassComment(4)
   |     |        Size: 0..1024
   |     +-- -R-- INTEGER   traClassRate(5)
   |     |        Range: 1..2147483647
   |     +-- -R-- INTEGER   traClassCeil(6)
   |     |        Range: 1..2147483647
   |     +-- -R-- INTEGER   traClassBurst(7)
   |     |        Range: 1..2147483647
   |     +-- -R-- INTEGER   traClassPriority(8)
   |     |        Range: 1..2147483647
   |     +-- -R-- INTEGER   traClassQuantum(9)
   |              Range: 1..2147483647
   |
   +--traRuleTable(3)
   |  |
   |  +--traRuleEntry(1)
   |     |  Index: traRuleIfID, traRuleClassID, traRuleID
   |     |
   |     +-- -R-- INTEGER   traRuleIfID(1)
   |     |        Range: 1..2147483647
   |     +-- -R-- INTEGER   traRuleClassID(2)
   |     |        Range: 1..2147483647
   |     +-- -R-- INTEGER   traRuleID(3)
   |     |        Range: 1..2147483647
   |     +-- -R-- String    traRuleProtocol(4)
   |     |        Size: 0..15
   |     +-- -R-- String    traRuleDest(5)
   |     |        Size: 0..19
   |     +-- -R-- INTEGER   traRuleDestPort(6)
   |     |        Range: 0..65536
   |     +-- -R-- String    traRuleSource(7)
   |     |        Size: 0..19
   |     +-- -R-- INTEGER   traRuleSourcePort(8)
   |     |        Range: 0..65536
   |     +-- -R-- String    traRuleTos(9)
   |     |        Size: 0..15
   |     +-- -R-- String    traRuleLength(10)
   |              Size: 0..15
   |
   +--traStatTable(4)
   |  |
   |  +--traStatEntry(1)
   |     |  Index: traStatIfID, traStatID
   |     |
   |     +-- -R-- INTEGER   traStatIfID(1)
   |     |        Range: 1..2147483647
   |     +-- -R-- INTEGER   traStatID(2)
   |     |        Range: 1..2147483647
   |     +-- -R-- String    traStatProtocol(3)
   |     |        Size: 0..15
   |     +-- -R-- INTEGER   traStatPort(4)
   |     |        Range: 1..65536
   |     +-- -R-- INTEGER   traStatTraffic(5)
   |              Range: 1..2147483647
   |
   +--traMIBConformance(6)
      |
      +--traMIBCompliances(1)
      |  |
      |  +--traMIBCompliance(1)
      |
      +--traMIBGroups(2)
         |
         +--traGroup(1)