October 09, 2008

Slackware 12 on the IBM x61s

Here is the description of how I got slackware 12 running on a lenovo x61s with
all the things I need.

Installation:
Scrinking the vista image
Dualboot installation (if you really need it ;)
Thinkpad kernel

System configuration:
Bluetooth
Wireless
Dual monitor setup
Acpi
vpn
Modified system configuration files

User applications:
Netbeans & Ant
Kdesvn, rapid svn
Openoffice
Diffing files
Cobertura

Installation:
Scrinking the vista image:
First off you'll have to scrink your vista image since the machine
comes with vista preinstalled. You can use the vista diskmanagement
tool for this (this is what I did).

I managed to get approx 32 GB from the vista installation, which is
more than enough for slackware.

Dualboot installation:
There's a problem with the intel boot loader, this problem means that
you can't install lilo in the mbr or on th efirst partition of the hd
becaue of the recovery partition.

So I deleted the recovery partition, it is the first partition
(/dev/sda1) of 5.4 GB. Then I created a linux partition instead and
installed grub on this. I didn't use lilo since it was never able to
go to the mbr???
Disk /dev/sda: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1         679     5448704   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2   *         679       10487    78781440    7  HPFS/NTFS
Partition 2 does not end on cylinder boundary.
/dev/sda3           10487       10518      254667   82  Linux swap
/dev/sda4   *       10519       14593    32732437+  83  Linux


That's my setup, planning to mount /dev/sda1 as /var clean the vista
partition and mount this as a windows path setup! But that's still to
come.

With the partitions ready get a hold of a CD drive and throw slackware
on the hdu. I selected everything ;) That's what slackbook reccomends.

Thinkpad kernel:
Version 2.6.23_rc5
Depending on your laptop type, mine's a x61s that at writing is a
retalively new machine, you should build a kernel. This is to ensure
that you get all the acpi features of you machine.

There's a bunch of patches you need, they are all listed on the
slackwiki.org. I just took a 2.6.23-rc9 this had everything except
suspend to ram. I'll apply the suspend patch once I have the
time. Since it seems like there's a lot of issues with recovering from
suspend to ram.

Follow the instructions on slackwiki for building your kernel and you
should be running in no time. While you're at it you should add fuse
(file system in user space) and smbfs support.

This'll be a great help since you can then use sshfs or obexfs to mount a ssh
login as a drive, mount a obex enabled phone as a drive and finally mount the
windows shared drives.

Add the following entry to /boot/grub/menu.lst
  title thinkpad on (/dev/sda4)
  root (hd0,3)
  kernel /boot/vmlinuz-huge-smp-2.6.23-rc9-smp root=/dev/sda4 ro vga=normal

To install your new kernel in the grub boot menu

Version 2.6.25.8:
Yes you should upgrade your kernel once in a while ;) There's a couple of new
ACPI configurations, and I also added the MPPE encryption in device drivers
to get vpn running. This is needed. It should be a module but because of
issues with the pptpsetup command I made a kernel with the encryption built
in. pptpsetup kept saying that the pppd_mppe_mppc module was not installed.

Copy the old configuration file for you latest running kernel
cp /oldkernelpath/.config /newkernelpath/

Then issue:
make oldconfig

Command to setup the new kernel with your latest changes. After this you can
run a:
make menuconfig

To add the new stuff you need. Once done
make
make modules_install

and I always manually copy the boot image to the /boot partition along with
any configuration for this particular kernel. See the 2.6.23_rc5 on how to
update grub.

System configuration:
Bluetooth:
Unfurtunately there's no bluetooth on/off switch, and this chip is
using a lot of power. but you can (enable|disable) the interface as
root via /proc/acpi/ibm/bluetooth.
 
echo disable > /proc/acpi/ibm/bluetooth
echo enable > /proc/acpi/ibm/bluetooth

switches bluetooth off and on respectively. When using bluetooth for
you everyday tasks, like uploading midlets to the phone or using dial
up in the train to and from work there's still a couple of things to
do.

I installed kdebletooth and kmobiletools. These tools integrate the
bluetooth interface directly in kqonquerer. The versions avaiiable as
beta3 never worked on my machine?? Dunno why, but I simply used the
versions from slax (www.slax.org). Convert the *.mo packages to
slackware tgz and install these as you'd install any other slack package.
You'll need linux live tools or a live distribution to do this. If you
havent all ready installed slax on your usb stick now's a good time to
do so. (see www.slax.org)

Once you have the mobile tools installed you'll have to ensure that
all users can run with bluetooth. Add:
hcid        # set the machine ID
hciconfig   # configure the bt subsystem
sdpd        # Let other BT devices see the machine

to our /etc/rc.d/rc.local or your distribution equivalent. On slack
there's a little trick copied from debian to set up the pin and phone
names.

In the file /etc/bluetooth/hcid.conf you'll can set the name of your machine
# Default settings for HCI devices
device {
    # Local device name
    #   %d - device id
    #   %h - host name
    name "darkstar (%d)";

Mines darkstar, the default name is Bluez. Setup the pin by echoing
the pin number you like to /etc/bluetooth/passkeys/default. I.e.
echo 1234 > /etc/bluetooth/passkeys/default

Now you can pair you phone. If you have issues chack the thinkpadwiki
for bluetooth details.

If you like you can autobind you bluetooth device using the
rfcomm.conf file. This is straight forward just place you phone's
bluetooth address with the one in the file, and voila you have a
rfcomm device you can use.

Heres my rfcomm.conf file:
cat /etc/bluetooth/rfcomm
rfcomm0 {
    # Automatically bind the device at startup
    #bind no;
    bind yes;

    # Bluetooth address of the device
    device 00:18:C5:3D:BF:C1; #Noia N73

    # RFCOMM channel for the connection
    channel    2; #Dial up networking port DUN profile connection

    # Description of the connection
    comment "Noia N73";
}

This is the best availabel guide to get BT dial up running:
http://www.marotori.com/blog/?p=16. You'll need a phone that supports the
bluetooth DUN profile. Believe me it's harder to get tha you think. I'm
currently using an Nokia N73. Runs perfectly with 3G

Heres my Slack dial up configuration:
first the chat-gprs file to set up th ebt moden for using the fastes
connection (gprs and 3G)
cat /etc/ppp/chat-gprs
'' ATZ OK
AT+CGDCONT=1,"IP","internet"
OK "ATD*99***1#"
CONNECT ''

Next my mobile internet provider is Danish TDC:
cat /etc/ppp/peers/tdc
/dev/rfcomm0 115200
connect '/usr/sbin/chat -v -f /etc/ppp/chat-gprs'
crtscts
modem -detach
noccp
defaultroute
usepeerdns
noauth
ipcp-accept-remote
ipcp-accept-local
noipdefault
debug
lcp-echo-failure 0

With these two files on place simply start the pppd as root, by issuing:
pppd call tdc

If you run into problems adding a debug on the pppd command will most likely
help
pppd call tdc debug

or you could use this small script
#!/bin/sh
sudo pppd call tdc debug

Wireless:
Is incredably straight forward. All you have todo is to insert the
inteldriver and then build the wrapper for it. The instructions to do so is
right here:
http://slackwiki.org/ThinkPad_X61s#Wireless_LAN_.28802.11.29

Next you'll need to get the wireless net running. You'll have to start the
service and the driver so it is loaded when you activate the machine.

Then you'll have to activate the card. This is done by starting the interface
with:
ifconfig wlan0 up
iwconfig wlan0 ESSID "your net work name"
dhcpcd wlan0

First you start the interface, then you attach it to your preffered network,
and finally you get an IP address from the networks dhcp server.

I added the following to my rc.local:
if [ -z ifconfig eth0 | grep ]; then
   if [ -s ifconfig wlan0 | grep ]; then
      iwconfig wlan0 ESSID "network name"
      dhcpcd wlan0
   else
      echo "wlan0 could not be found, check the wireless switch"
   fi
fi

Now you'll have to chmod the script to be able to execute it! And notice
you'll have to be either root or a sudo'er to activate the ifconfig and iw
config calls.
cat /root/wireless_nome.sh
#!/bin/sh

if [ -e /etc/dhcpc/dhcpcd-wlan0.pid ]; then
    rm /etc/dhcpc/dhcpcd-wlan0.pid
fi

ETH0=$(ifconfig|grep eth0|cut -c 1-4)
WLAN0=$(ifconfig|grep wlan0|cut -c 1-4)

if [ -z $ETH0 ];then
    if [ -z $WLAN0  ];then
        echo "No wireless adaptor found, check the wireless switch!"
    else
        iwconfig wlan0 ESSID "your wireless ssid"
        dhcpcd wlan0
        exit 0;
    fi
else
    echo "apparently there's a ethernet card!"
fi
exit 1;

Dual monitor setup:
Adding the following to your .xprofile file will utilize the screen you have
on your desk.
if [ -z xrandr|grep VGA ]; then
   xrandr --output LVDS --mode 1024x768  
else
   xrandr --output LVDS --mode 1600x1200  
fi

My xorg.conf file can be found here:
cat /etc/X11/xorg.conf
# John's handhacked dual monitor xorg.conf file
Section "ServerLayout"
    Identifier     "X.org Configured"
    Screen      0  "int" 0 0
    InputDevice    "Mouse0" "CorePointer"
    InputDevice    "Keyboard0" "CoreKeyboard"
EndSection

Section "Files"
    RgbPath      "/usr/share/X11/rgb"
    ModulePath   "/usr/lib/xorg/modules"
    FontPath     "/usr/share/fonts/TTF"
    FontPath     "/usr/share/fonts/OTF"
    FontPath     "/usr/share/fonts/Type1"
    FontPath     "/usr/share/fonts/misc"
    FontPath     "/usr/share/fonts/75dpi/:unscaled"
EndSection

Section "Module"
    Load  "xtrap"
    Load  "GLcore"
    Load  "dri"
    Load  "dbe"
    Load  "glx"
    Load  "extmod"
    Load  "record"
    Load  "freetype"
    Load  "type1"
EndSection

Section "InputDevice"
    Identifier  "Keyboard0"
    Driver      "kbd"
    Option        "XkbModel" "pc104"
    Option        "XkbLayout" "dk"
    Option        "XkbOptions" "grp:shifts_toggle"
EndSection

Section "InputDevice"
    Identifier  "Mouse0"
    Driver      "mouse"
    Option        "Protocol" "auto"
    Option        "Device" "/dev/input/mice"
    Option        "ZAxisMapping" "4 5 6 7"
EndSection

Section "Device"
    Identifier  "Card0"
    Driver      "intel"
    VendorName  "Intel Corporation"
    BoardName   "Mobile Integrated Graphics Controller"
    Option        "MergedFB" "true"
    Option        "MetaModes" "1024x768 1024x768"
    Option        "MergedDPI" "100 100"
    BusID       "PCI:0:2:0"
EndSection

Section "Device"
    Identifier    "Card1"
    Driver        "intel"
    BusID        "PCI:0:2:0"
    Screen        1
EndSection

Section "Screen"
    Identifier "int"
    Device     "Card0"
    Monitor    "laptop"
    DefaultDepth     24
    SubSection "Display"
        Viewport   0 0
        Depth     1
#        Virtual   3000 1600
    EndSubSection
    SubSection "Display"
        Viewport   0 0
        Depth     4
#        Virtual   3000 1600
    EndSubSection
    SubSection "Display"
        Viewport   0 0
        Depth     8
#        Virtual   3000 1600
    EndSubSection
    SubSection "Display"
        Viewport   0 0
        Depth     15
#        Virtual   3000 1600
    EndSubSection
    SubSection "Display"
        Viewport   0 0
        Depth     16
#        Virtual   3000 1600
    EndSubSection
    SubSection "Display"
        Viewport   0 0
        Depth     24
        Virtual   2624 2048
    EndSubSection
EndSection

Section "Monitor"
    Identifier   "laptop"
    VendorName   "LEN"
    ModelName    "4000"
    Option        "DPMS"
EndSection

Section "Screen"
    Identifier "ext"
    Device     "Card1"
    Monitor    "external"
    DefaultDepth     24
    SubSection "Display"
        Depth     24
        Modes    "1600x1200" "1280x1024"
    EndSubSection
EndSection

Section "Monitor"
    Identifier  "external"
    Option        "DPMS"
EndSection

Section "DRI"
    Mode         0666
EndSection

Acpi:
Getting the full potential of the laptop means using acpi! In the kernel part
of this document you have putin acpi support and the thinkpad dirvers for
acpi. The next part is to configure it. There is a big indepth guide tpo acpi
here: http://slackwiki.org/ThinkPad_X61s#ACPI

The generel idea is that you place small scripts in /etc/acpi/actions, then
you point to these scripts from /etc/acpi/events/

The lid event can be controlled like this:
event=button lid.*
action=/etc/acpi/actions/sleep.sh

Then dump the sleep script in /etc/acpi/actions. But you should notice that
there is aproblem with sleeping. The wake up part screws up the screen
light/brightness leaving the screen almost black. I have attempted to fic
this issue but no luck so far.

vpn:
Creating a vpn connection is quite tricky on slackware! Since all the common
and preffered wizards fails! Which leads to actually reading the
documentation and figuring out what actually happens ;) (I love Slackware)

So, read the pptpclient documentation for hand configuration:
http://pptpclient.sourceforge.net/howto-debian.phtml#configure_by_hand
and routing: http://pptpclient.sourceforge.net/routing.phtml#client-to-server

I created the options file as ressomended but added the refuce-eap option
as well, as the pptpserver om mpt1.dk kept kickin my machine off. Here are
the answers to the handconfiguration:
1.
    * the IP address or host name of the server ($SERVER) mpt1.dk
    * the name you wish to use to refer to the tunnel ($TUNNEL) mobile
    * the authentication domain name ($DOMAIN) MPOFFICE1 (not needed)
    * the username you are to use ($USERNAME) jd
    * the password you are to use ($PASSWORD) youwish!
    * whether encryption is required. But of course (mppe128)

2. cat /etc/ppp/options.pptp
lock noauth nodeflate nobsdcomp refuse-eap

3. cat /etc/ppp/chap-secrets
jd      PPTP    youwish!    *

4. cat /etc/ppp/peers/mobile
pty "pptp mpt1.dk --nolaunchpppd"
name jd
remotename PPTP
require-mppe-128
file /etc/ppp/options.pptp
ipparam mobile

The only problem with the handconfiguration is that it comes from debian, and
slackware does not contain the pon and poff commands. Så all you have to do
is to fire this little expression to start the vpn connection:
 
pppd pty 'pptp mpt1.dk --nolaunchpppd' call mobile debug dump logfd 2 nodetach

Where the mpt1.dk is replaced with your server name and the mobile is
replaced with tour tunnel name.

Next you'll need a route to the vpn network, this can be obtained with the
command
 
route add -net 192.168.1.0 netmask 255.255.255.0 dev ppp0

where the ip is the net you'll connect to and ppp0 is the interface you wich
to connect the route to! I have created a small script:
cat /etc/ppp/ip-up
#!/bin/sh
/sbin/route add -net 192.168.1.0 netmask 255.255.255.0 dev ppp

which adds the route to the network i need, there are several things to add
to this script to get the connections work automatically

The next thing was host resolving. The nameservice provided did not work over
the vpn tunnel :( But *nix systems have the /etc/hosts file. Here I added an
entry the hosts I need.
cat /etc/hosts
# For loopbacking.
127.0.0.1        localhost
127.0.0.1        darkstar.domain.com darkstar

#system specific hosts
svn.server.ip.address   svn_repo

That concludes the vpn configuration.

Modified system configuration files:
su -
find /etc/ -name '*~'
/etc/sudoers~
/etc/X11/xorg.conf~
/etc/bluetooth/rfcomm.conf~
/etc/bluetooth/hcid.conf~
/etc/fstab~
/etc/rc.d/rc.local~
/etc/rc.d/rc.bluetooth~
/boot/grub/menu.lst

User applications:
Netbeans & Ant:
I did a slackware package containing this. Its easy since it's located
in /opt. considering doing the same with openoffice. But hey it's a
bunch of small tgz's now so why bother ;)

You'll have to create a small script to be able to send the
environment variables to netbeans (if you'd like to activate this from
any menu item in your desktop)
#!/bin/sh
export EMC=/home/$USER/work/emc ;
export WORK=/home/$USER/work/ ;
netbeans --jdkhome /usr/lib/jdk1.6.0_01/ ;

Save this as netbeans.sh and make it executable with chmod u+x Put it
in you favorite desktop menu item and you are up running. Or you can simply
add the netbeans program to the panel as an application

I also added the work specific env vars to my .bashrc enabling me to
run netbeans from any terminal and set up ant.
#setup work environment for EMC client project
export EMC=/home/$USER/work/emc ;
export WORK=/home/$USER/work/;

#setup ant
export ANT_HOME=/usr/local/apache-ant-1.7.1
export JAVA_HOME=/usr/lib/jdk1.6.0_01
export PATH=${PATH}:${ANT_HOME}/bin:${JAVA_HOME}/bin

To install ant just copy the ant bin and lib folders to the place in
the system you prefer. Mine's /usr/local/ant/ insluding bin and lib

If you want to build ant it is a different story. Then you'll have to obtain
the sources from http://ant.apache.org/. Follow the instructions on
http://ant.apache.org/manual/index.html to somplete the installation.

I neede to place the junit for building the test cases for ant. This optional
package must go in ants optional directory:
cd $ANT_HOME
mkdir lib/optional/
cp junit.jar junit.jar

This gives you the junit file available for ant. Then just build normally,
and install the ant. My ant directory at writing is: /usr/local/apache-ant-1.7.1/

If you need the possibility of using the Sony ericsson emulator with netbeans
read the entry.

Kdesvn:
To get svn running with a wysiwyg thing you'll need something like
kdesvn. just fetch and install the package. It is done by following the
package instructions.

Openoffice:
Since openoffice installer is using rpm, which suck, and wont work
directly on slackware you'll have to rpm2tgz all the oo rpms. Do:
mkdir tgz
cd tgz
rpm2tgz ../rpms/*.rpm
installpkg *.tgz

now all you have todo is to create the menu items and the links to
/usr/bin if you prefer.

Diffing files:
You'll need meld. Its the best available diff and merge tool. Yess it beats
ediff! On a slack 12 kde machine you'll have to get the gnome-pythn
package. The best way (once you have slapt-get installed) is:
 
slapt-get --install gnome-python

That takes care of the meld dependencies. Now you'll need meld. It's
available here: http://meld.sourceforge.net/ there even is a slackware
package :) Down the meld slackpack and fire:
 
installpkg meld.whatever.version.you.downloaded.tgz

Next issue:
 
meld

To start melding the files ;)

2 comments:

Chris Chaney said...

Hey -- I just attempted to setup my second monitor on my x61s (using the dock) but am having issues.

I copied your xorg.corf file and also created the .xprofile (I didn't have one of these already) and placed it at ~/ (also copied to to /etc/xprofile just in case it was looking there for it).

Whenever I startx with the external monitor plugged into the dock, both monitors come on with the display mirrored. The external monitor is set to its correct resolution (1280x1024); however, the x61s LCD is not being set to its 1024x768 (I can only see a portion of the desktop and everything else falls off). If I startx without the external monitor plugged in, the LCD comes up with the correct resolution (1024x768).

When I do an xrandr it shows VGA connected (1280x1024) and LVDS shows connected (1024x768).

I would love to be able to use both monitors with extended desktop instead of the mirrored desktop.

Any suggestions?

Chris Chaney said...

When I manually run the .xprofile script, I get the following:

~ # ~/.xprofile
/root/.xprofile: line 1: [: missing ']'
grep: ]: No such file or directory
xrandr: cannot find mode 1280x1024

And I copied your file line for line