CrunchBang on Thinkpad X220

Desktop Replacement
_ Hardware Modifications_
_ Upgrade BIOS From USB_
_ About CrunchBang_
_ System Modifications_

Desktop Replacement:

It has been over two and a half years since my last Debian-related post so I thought it necessary to provide an update. I have since donated my desktop machine to a worthy cause in favour of the more-mobile Thinkpad platform. My semi-retired Debian desktop is now providing headache-free internet access at the local library, where one of the librarians had long been toying with the idea of using open source. The successful implementation of my machine prompted their acquisition of a further two Ubuntu machines.

My new Thinkpad, on the other hand, has been running CrunchBang Linux (#!) for over a year and a half, and I could not be happier. Although not a pure Debian system, #! is still a lean derivative.

Hardware Modifications:

Hardware changes I’ve made so far include: installing an Intel 30GB 525s MLC mSATA SSD drive to act as my system drive; and running 2 x 4 GB Corsair PC3-10600 DDR3-1333 RAM in dual channel mode.

Upgrade BIOS From USB:

After grabbing the latest BIOS-update bootable iso from the Lenovo support site, it is necessary to extract its [otherwise hidden] contents via a perl script called geteltorito.pl.

To fetch the script:
$ wget 'http://userpages.uni-koblenz.de/~krienke/ftp/noarch/geteltorito/geteltorito.pl'

Then, extract the contents of the downloaded *.iso file to any new target file:
$ perl ./geteltorito.pl /path/to/_bios_update_cd.iso > /path/to/_target_image_.img

To write the image to your USB (located at /dev/sdX):
$ sudo dd if=/path/to/_target_image_.img of=/dev/sdX bs=512K

Then hit F12 at bootup to choose the bootable medium.

About CrunchBang:

Out-of-the-box, #! does everything I need it to do on a laptop (wifi management; power-saving; keyboard accessibility-support,) at a fraction of the resources required were I to customize a larger/slimmer distribution to suit my needs. Were I to install Debian, I would have arrived at my ideal setup at a much later date.

Crunchbang provides a superb arsenal of open-source productivity applications, and I found myself bored witless during post-install. It defaults to using Openbox - which is not exactly a tiling WM that I’m accustomed to using - but I have made peace with that by implementing split-panes in tmux which, considering the smaller LCD screen real-estate, works reasonably well.

For work-purposes, I have implemented KVM + Qemu to manage a guest Windows XP OS - the guide I used can be found here - and I have been able to leverage the power of this fantastic little unit to conduct business.

System Modifications:

System changes I’ve made so far include: switching from grub2 to syslinux (see here); colourizing init feedback (see here); mounting system paths on the SSD drive with TRIM support (with fstab: -o discard); enabling Thinkpad-specific battery savings (with tlp and thinkpad-smapi); relocating /var paths and browser profiles to tmpfs (with profile-sync-daemon).

To get wifi working again after a system suspend-resume event, my executable /etc/pm/sleep.d/20_fix_wifi contains:
case "${1}" in resume|thaw) rmmod iwlwifi && modprobe iwlwifi ;; esac

Additionally, I had CrunchBang show verbose shutdown messages by modifying /etc/slim.conf to show:

xserver_arguments -nolisten tcp -novtswitch

As my Crunchbang box is essentially a Debian Wheezy machine, I will henceforth address it as my debian box in all future blog entries.

Address Merged Ports

My most recent # portmaster -Da revealed a package conflict: py-setuptools was merged with py-distribute.

From FreshPorts:

2013-03-05
Affects: users of devel/py-setuptools (i.e you)
Author: rm@FreeBSD.org
Reason: devel/py-setuptools was replaced with devel/py-distribute. py-setuptools port will be removed shortly.

To fix this:
# portmaster -o devel/py-distribute devel/py-setuptools

From man 8 portmaster:

-o new port dir in /usr/ports installed port:replace the installed port with a port from a different origin

Relocate iOS Backups

There are currently 3 different iPhones and 2 different iPads in my household that need updating - from iOS versions 3.x, 4.x, and 5.x. In order to make the transition to iOS version 6.0.1 (current), I first have to back up each device via iTunes. Unfortunately, my meagre 60GB SSD system drive will not suffice. I have decided to use NTFS’ junction function to link directories on separate hard drives. I had to move %APPDATA%\Apple Computer from my system drive to a separate D:\, using cmd.exe:

move "%APPDATA%\Apple Computer" D:\

then issue the following command in cmd.exe (as admin):

mklink /J "%APPDATA%\Apple Computer" "D:\Apple Computer"

For the curious, %APPDATA% contains the full path to the Application Data folder of the logged-in user, e.g., C:\Users\ootput\AppData\Roaming

NES Nostalgia

![](/images/5cd1299343eb332066db11696f3710a460030757.png “NintendoLogo”)

A throwback to the NES days of old, this video has recently become a favourite of mine. It features Anamanaguchi - Jetpack Blues, Sunset Hues,

Anamanaguchi is a chiptune indie rock band from New York City that “makes loud, fast music with a hacked NES from 1985.” Akin to other chiptune artists, Anamanaguchi creates music using synthesizers, albeit unconventional ones: namely a hacked NES and Game Boy.

CouchPotato on FreeBSD

For CouchPotato in FreeBSD, firstly acquaint yourself with my previous blog entry on Sabnzbd+Sickbeard on FreeBSD, and then perform the following additional steps:

At Step 3, fetch CouchPotato’s source code:

# cd /usr/local && git clone git://github.com/RuudBurger/CouchPotato.git couchpotato

Also, it is advisable to change the permission and ownership of the CouchPotato folder:

# chown root:_sabnzbd /usr/local/couchpotato

# chmod g+w /usr/local/couchpotato

At Step 4, add the following to /etc/rc.conf:

1
2
3

couchpotato_enable="YES"

.. and create /usr/local/etc/rc.d/couchpotato containing:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84

#!/bin/sh
#
# PROVIDE: couchpotato
# REQUIRE: DAEMON sabnzbd
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# couchpotato_enable (bool): Set to NO by default.
# Set it to YES to enable it.
# couchpotato_user: The user account Couch Potato daemon runs as what
# you want it to be. It uses '_sabnzbd' user by
# default. Do not sets it as empty or it will run
# as root.
# couchpotato_dir: Directory where Couch Potato lives.
# Default: /usr/local/couchpotato
# couchpotato_chdir: Change to this directory before running Couch Potato.
# Default is same as couchpotato_dir.
# couchpotato_pid: The name of the pidfile to create.
# Default is couchpotato.pid in couchpotato_dir.
PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin"

. /etc/rc.subr

name="couchpotato"
rcvar=${name}_enable

load_rc_config ${name}

: ${couchpotato_enable:="NO"}
: ${couchpotato_user:="_sabnzbd"}
: ${couchpotato_dir:="/usr/local/couchpotato"}
: ${couchpotato_chdir:="${couchpotato_dir}"}
: ${couchpotato_pid:="${couchpotato_dir}/couchpotato.pid"}

WGET="/usr/local/bin/wget" # You need wget for this script to safely shutdown Couch Potato.
HOST="127.0.0.1" # Set Couch Potato address here.
PORT="5000" # Set Couch Potato port here.
SBUSR="" # Set Couch Potato username (if you use one) here.
SBPWD="" # Set Couch Potato password (if you use one) here.

status_cmd="${name}_status"
stop_cmd="${name}_stop"

command="/usr/sbin/daemon"
command_args="-f -p ${couchpotato_pid} python ${couchpotato_dir}/CouchPotato.py ${couchpotato_flags} --quiet"

# Check for wget and refuse to start without it.
if [ ! -x "${WGET}" ]; then
warn "Couchpotato not started: You need wget to safely shut down Couch Potato."
exit 1
fi

# Ensure user is root when running this script.
if [ `id -u` != "0" ]; then
echo "Oops, you should be root before running this!"
exit 1
fi

verify_couchpotato_pid() {
# Make sure the pid corresponds to the Couch Potato process.
pid=`cat ${couchpotato_pid} 2>/dev/null`
ps -p ${pid} | grep -q "python ${couchpotato_dir}/CouchPotato.py"
return $?
}

# Try to stop Couch Potato cleanly by calling shutdown over http.
couchpotato_stop() {
echo "Stopping $name"
verify_couchpotato_pid
${WGET} -O - -q --user=${SBUSR} --password=${SBPWD} "http://${HOST}:${PORT}/home/shutdown/?pid=${pid}" >/dev/null
if [ -n "${pid}" ]; then
wait_for_pids ${pid}
echo "Stopped"
fi
}

couchpotato_status() {
verify_couchpotato_pid && echo "$name is running as ${pid}" || echo "$name is not running"
}

run_rc_command "$1"

NTFS-Write in FreeBSD

NTFS-write in FreeBSD is possible with NTFS-3G from ports. From tuxera.com:

NTFS-3G is a stable, full-featured, read-write NTFS driver for Linux, Android, Mac OS X, FreeBSD, NetBSD, OpenSolaris, QNX, Haiku, and other operating systems. It provides safe handling of the Windows XP, Windows Server 2003, Windows 2000, Windows Vista, Windows Server 2008 and Windows 7 NTFS file systems.

To install NTFS-3G, do:

# portmaster sysutils/fusefs-ntfs

Next, create a symbolic link from the newly-installed /usr/local/bin/ntfs-3g into /usr/sbin/:

# ln -s $(which ntfs-3g) /usr/sbin/mount_ntfs-3g

Modify your /etc/rc.conf to contain:

1
2
3

fusefs_enable="YES"

Provided you know on which hard-disk (based on make/model/capacity of the device) your NTFS partition resides, you can figure out it’s exact device node in FreeBSD:

# egrep 'ad[0-9]|cd[0-9]|da[0-9]' /var/run/dmesg.boot

ad0: 35303MB  at ata0-master
ad2: 57240MB  at ata1-master
ad4: 286168MB  at ata2-master

My NTFS partition resides on a 300GB WD Velociraptor drive, ad4. To confirm that /dev/ad4 does indeed contain the NTFS partition, do:

# gpart show -p ad4

=>        34  586072064    ad4 GPT  (286G)
          34  586072064  ad4p1 ntfs (286G)

To mount the partition manually, do:

# ntfs-3g /dev/ad4s1 /mnt/windows7

Finally, add the appropriate line to /etc/fstab to have the NTFS partition mounted at the next system boot. For instance, my /etc/fstab contains:

/dev/ad4s1              /mnt/windows7            ntfs-3g rw,late         0       0

Flickr and WordPress and Bub

[![Our Beautiful Bub](/images/d88fdc5d17576a8d25388d836d4a270ebbd8271f.jpg)](http://www.flickr.com/photos/ootput/7172231697/ "Our Beautiful Bub by ootput, on Flickr") [Our Beautiful Bub](http://www.flickr.com/photos/ootput/7172231697/), a photo by [ootput](http://www.flickr.com/photos/ootput/) on Flickr.

Flickr makes it easy to share uploaded photos in WordPress blogs, and I couldn’t resist taking the opportunity to share a photo of my beautiful son.

For instructions on how to compose blog entries from Flickr, go here. Also, there is a Flickr widget available that will show thumbnails of your latest Flickr photos in your sidebar.