Sunday, April 29, 2007

Yum commands

[root@sempron acardh]# yum --disablerepo=macromedia update

Thursday, April 26, 2007

Download and install NVIDIA Drivers

First of all, if you tried using the script then you can find the NVIDIA installer package in /usr/share/doc/nvidia If the installer package is not there go to NVIDIA Download Page, and get the latest drivers for your computer.

Install the drivers

If you are in runlevel 5, go to runlevel 3 by typing the following comand as root in one of the consoles (which you can access by pressing ctrl-alt-f1 [f1 up to f6])

telinit 3

Now go to the directory containing the drivers.

cd /usr/share/doc/nvidia

or

cd /the/path/where/you/saved/the/drivers/from/nvidia/website

Now simply type the following and follow instructions

sh NVIDIA-Linux----.run -q

Monday, April 16, 2007

Tuesday, March 13, 2007

Remote X session from Linux to Linux

To have a remote X session from Linux machine A to Linux machine B connect to A using the command:
ssh -X 192.168.0.6 -l mylogname

Replace 192.168.0.6 for your IP or hostname.

Tuesday, February 20, 2007

Mounting ISO images

http://www.linuxquestions.org/questions/showthread.php?t=277643

Do this:
Code:
md /mnt/iso

Code:
mount -o loop -t iso9660 .iso /mnt/iso
Try this...

mount -t iso9660 -o ro,loop=/dev/loop0 /home/ste/cd.iso /mnt/iso

Tuesday, February 13, 2007

Combining multiple PDF files in one

http://www.debianadmin.com/combine-multiple-pdfs-into-one-file-in-ubuntu-linux.html
http://www.newsforge.com/article.pl?sid=04/06/09/1844259

Preparing Your system
sudo apt-get install gs pdftk
(Merge, merging, cancatenate, concatenating pdf files)

Now we will see one example how to combine pdf files let us assume we have 1.pdf,2.pdf,3.pdf files and now we need to cobmine this files using the following command:
gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=combinedpdf.pdf -dBATCH 1.pdf 2.pdf 3.pdf
Another different approach:
gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=finished.pdf file1.pdf file2.pdf
In the above command after “-sOUTPUTFILE=” type whatever name you want for the merged file (don’t forget to append .pdf to the end of the file name). Rename “1.pdf 2.pdf 3.pdf” to whatever your file names are (separate your file names with a space).
After you run the above command, a new PDF file called combinedpdf.pdf will be created with your individual files merged according to the order you list.
The same can be done with PS files:
gs -sDEVICE=pswrite -sOutputFile=output.ps -dNOPAUSE -dBATCH file1.ps file2.ps file3.ps
If you want to know more options available for gs command check man page

Tags: , , , , , , ,

Merge PDF files with pdftk
Having some of my manuals/documentations downloaded in several separated pdf files, I wanted to merge them into a single file.

First, I installed pdftk

# apt-get install pdftk

In Ubuntu 18.04 the previous command won't work. Instead:

sudo snap install pdftk

Then, I merged the files into a single file

$ pdftk   file1.pdf    file2.pdf    file3.pdf   cat  output   file123.pdf

When the files to be merged is a lot, I edited the file list in a text editor (or, when I am in a good mood, using ls & awk & sed) then combine it with the script found here

$ cat stdin_pdf.sh
#!/bin/sh
# combine PDFs; pass filenames in on stdin;
# pass output to stdout
read input_filenames
pdftk $input_filenames cat output -

$ cat filelist|./stdin_pdf.sh>mergedfile.pdf

So far, I am satisfied with the result. (link)

Saturday, February 10, 2007

Switching between different keyboard mappings

http://www2.blogger.com/post-create.g?blogID=4592078922113874023
setxkbmap us_intl # to write Spanish stuff
setxkbmap us # to write English stuff and code
setxkbmap es # to write Spanish stuff and code

Sunday, February 04, 2007

Saturday, February 03, 2007

Lenovo T60 with fedora core 6

http://www.thinkwiki.org/wiki/Installing_Fedora_Core_6_on_a_ThinkPad_T60

Lenovo Thinkpad T60

http://statgen.ncsu.edu/~jdstarme/fc5_on_t60.txt

I am much indebted to all of the great information there is already on the
internet about how to get Fedora Core 5 (FC5) working on a ThinkPad T60.
In this document I attempt to cite the sources where I got various bits
of information, however, I may have missed a few. To those authors I offer
an apology and ask that you send me an email! (jdstarme_at_ncsu.edu)

Special thanks to Tom Davidson for sending me feedback and good suggestions
for revisions to this document.


System:

Lenovo Thinkpad T60

Intel Core Duo T2500 2.00 GHz
1 GB RAM
100 GB Hard Drive (SATA150)
ATI Mobility Radeon X1400 M54
VGA video out


0) Boot into windows and make sure everything is working the way. Make
the rescue CDs (there are 7 total - oh, and it is not obvious how to make
the back up CDs. However, if you search around enough, you'll figure it out.)


1) Download the latest System Rescue CD from

www.sysrescd.org

I ended up with: SystemRescueCD-x86-0.2.19

(I tried using the version I made long ago when I installed FC2, but the
graphical partitioning program, qtparted, would not recognize the new
SATA type hard-drive)

In order to burn the ISO, I had to download something called "Nero 7". After
fiddling around for a bit, I figured out how to use it to burn the ISO to
a CD.

Reboot with the new CD in the drive

at the prompt, type: run_qtparted

Select the main partition and re-size it to about 20GB then commit your change.
I was unable to create all of the sub-partitions I usually make for linux.
However, I was able to do that when I installed FC5.


2) Boot up with FC5 disk1 and press return to begin installing. The old
problem (from FC2 days) of having to specify the hard-drive geometry in order
to get the system to dual boot no longer exists, so you
don't have to worry about specifying anything on the command line.

NOTE: this destroys part of the ThinkVantage buttons functionality. You can
still use the ThinkVantage button to get into the bios, but you can no
longer use it to restore and recover the system (good thing you made those
backup CDs?) This really doesn't bother me that much since I only
intend to use windows once in a blue moon and the only thing I'm really
concerned about being able to fix without reformatting the whole drive is
the linux stuff and the FC5 distribution comes with a rescue mode...


I did my own partitioning:

/dev/sda
/dev/sda1 ntfs 19807 1 2525
/dev/sda3 /boot ext3 102 2526 2538
/dev/sda4 extended70473 2539 11522
/dev/sda5 / ext3 10001 2539 3813
/dev/sda6 /usr/local ext3 4997 3814 4450
/dev/sda7 swap 2000 4451 4705
/dev/sda8 /home ext3 53474 4706 11522
Free FS 6 11523 11523
/dev/sda2 vfat 5006 11523 12161


3) Reboot (note, I did not have the problem with the system hanging on the
initial boot that was mentioned on the think-wiki site
http://www.thinkwiki.org/wiki/Installing_Fedora_Core_5_on_a_ThinkPad_T60),

The monitor was not detected
(it is a 14.1" TFT display with 1400x1050 resolution)

Set the monitor to LCD Panel 1400x1050 (generic).

THINGS THAT WORKED OUT OF THE BOX

- SMP (symmetrical multiprocessing support for the core duo)
- Sound (just remember to turn up the volume so you can hear the sound!)
- USB
- Suspend (after an update to (at least) kernel version 2.6.17-1.2139_FC5.
This means that suspend will not work immediately after a fresh
install. However, once you run "yum update", everything should
work fine.)

A NOTE ON SUSPEND: sometimes the wireless daemon or the
network-manager daemon is dead when you bring the computer back to
life. To remedy, just select System->Administration->Services
and then stop and start whichever daemon died.


After rebooting and verifying that I could boot into Windows XP,
I booted back into Fedora and updated the installed packages:

shell# yum update

This took forever and a day over my painfully slow DSL provided by BellSouth.

Getting the the thinkpad buttons to display information on the monitor only
required:

a)
shell# yum install tpb

b)
and then a restart.


To get X programs (like xterm and xfig) to have white backgrounds...

edit the file: /etc/X11/Xresources

and then add the lines:

xterm*background: white
xterm*scrollBar: true

xfig*background: white
xfig*foreground: black

(be sure to end the file with a new line)

The changes will take effect after you log out and then log back in, or you
can cause them to take effect now with the command:

shell> xrdb /etx/X11/Xresources


To make X programs have readable fonts, I set the font for the xterm and
emacs to 7x14 (you can do this per program with the -fn 7x14 option)


3) Wireless

0: Get NetworkManger working: all you have to do for this is to start
the NetworkManger services. System->Administration->Services


1: Add the "ATrpms" repository for yum by adding the file:

atrpms.repo

to the directory: /etc/yum.repos.d/

and in this file I put the lines:

[atrpms]
name=Fedora Core $releasever - $basearch - ATrpms
baseurl=http://dl.atrpms.net/fc$releasever-$basearch/atrpms/stable
enabled=0

and then ran the commands:

shell# rpm --import http://ATrpms.net/RPM-GPG-KEY.atrpms

shell# yum --enablerepo=atrpm\* install ipw3945 ipw3945d
ipw3945-ucode ipw3945-kmdl-CURRENT_KERNEL_VERSION_FC5smp

where CURRENT_KERNEL_VRESION is the version of the kernel that you are running.
You can figure out the version you are running with the command:

shell> uname -a

and this will print out all kinds of information about your kernel. Your
kernel version should be something like 2.6.17-1.2174_FC5smp.



2: Get the wireless kernel modules working...

shell# /sbin/depmod -a (you only have to do this once, right after installing
the rpms)

shell# /sbin/modprobe ipw3945 (load the kernel module)
shell# /sbin/ipw3945d (start the wireless daemon)

and then the wireless networks appear in the NetworkManager applet.

However, on restart, the module is not automatically loaded. However, to
fix this, I took the "wireless" script from Jim Hall's page:
http://us.fdos.org/linux/laptops/tp-t60/

and removed the case where it checks for eth0, since I'm going to let
NetworkManager deal with wired vs. wireless connections. So here's
my /etc/init.d/wireless file:

#! /bin/bash
#
# wireless Bring up/down integrated wireless networking (ipw3945)
#
# chkconfig: 2345 90 10
# description: Activates/Deactivates eth1 wireless interface (ipw3945)
#
### BEGIN INIT INFO

# # ipw3945d --help
# usage: ipw3945d [--OPTION]
# options:
# --quiet Load silently (unless errors occur)
# --version Display version information
# --debug=value Specify debug level to print
# --dvals View possible debug values
# --foreground Do not fork to background
# --kill Kill any running ipw3945d instance and exit
# --help View this help message
# --isrunning Check if already running. Returns 0 if yes.


# See how we were called.
case "$1" in
start)
/sbin/ipw3945d --isrunning
if [ $? -eq 0 ] ; then
echo "ipw3945d already running"
exit 1
fi

modprobe ipw3945
/sbin/ipw3945d
#ifup eth1

echo "ipw3945d started .."
;;

stop)
/sbin/ipw3945d --isrunning
if [ $? -ne 0 ] ; then
echo "ipw3945d not running"
exit 1
fi

ifdown eth1
/sbin/ipw3945d --kill
rmmod ipw3945

echo "ipw3945d stopped .."
;;

restart)
$0 stop ; $0 start
;;
esac

Once you create this file, make sure you set the permissions on this
file so that everyone can execute it (i.e. chmod a+x) and then run the
chkconfig program:

shell# /sbin/chkconfig --add wireless

Since nine-times out of ten I'm going to be using a wireless network,
I selected: System->Administration->Network and edited eth0 so that it would
not attempt to activate on startup. NetworkManager does a fine job activating
eth0 if you plug in an ethernet cable.

NOTES: One thing that can mess up wireless is if you have added an entry for
eth1 in System->Administration->Network. If you have done this, just delete
the entry and if you have followed the previous steps, things should work.


4) Touchpad...

turn off tapping, actually tapping is pretty good on this machine (better
than on my old T42), but still, I find it annoying overall.

Back up the file: /etc/X11/xorg.conf
Edit the file: /etc/X11/xorg.conf
Add the line:

Option "SHMConfig" "on"

to the section for the "Synaptics" mouse. It should then look like....

Section "InputDevice"
Identifier "Synaptics"
Driver "synaptics"
Option "Device" "/dev/input/mice"
Option "Protocol" "auto-dev"
Option "Emulate3Buttons" "yes"
Option "SHMConfig" "on"
EndSection

Now reboot the computer...

You can test that your editing of the xorg.conf file worked with the command:

shell# synclient -l

You should see a listing of all of the parameters settings.

you can experiment with various settings by using the synclient program
on the command line. For example, to turn off tapping:

shell# synclient MaxTapTime=0

To make these changes permanent, add the commands to the Synaptics section
of the xorg.conf file. For example:

Section "InputDevice"
Identifier "Synaptics"
Driver "synaptics"
Option "Device" "/dev/input/mice"
Option "Protocol" "auto-dev"
Option "Emulate3Buttons" "yes"
Option "SHMConfig" "on"
Option "MaxTapTime" "0"
EndSection


I also turned off the "forward and reverse" thing that affected web browsing
by adding the line:

Option "BottomEdge" "5500"

to the same section in my xorg.conf file... So the final version looked
like this:

Section "InputDevice"
Identifier "Synaptics"
Driver "synaptics"
Option "Device" "/dev/input/mice"
Option "Protocol" "auto-dev"
Option "Emulate3Buttons" "yes"
Option "SHMConfig" "on"
Option "MaxTapTime" "0"
Option "BottomEdge" "5500"
EndSection


5) .bashrc

# .bashrc


# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi

# User specific aliases and functions

alias cleanup="rm -f *~; ls"

alias emacs="emacs -fn 7x14"

alias rm="rm -i"
alias mv="mv -i"
alias cp="cp -i"

export EDITOR="emacs -nw"
export GRACE_EDITOR=emacs

export CVS_RSH=ssh


6) An mp3 player. I know they are not Free, as in speech, but I have to be
able to play them, otherwise I can't rehearse for gigs. Bands always send me
their stuff as mp3s...

add the "livna" repository for yum by adding the the file:

livna.repo

to the directory: /ety/yum.repos.d/

and in this file, put the lines:

[livna]
name=Livna for Fedora Core $releasever - $basearch - Base
baseurl=
http://rpm.livna.org/fedora/$releasever/$basearch/
http://livna.cat.pdx.edu/fedora/$releasever/$basearch/
http://wftp.tu-chemnitz.de/pub/linux/livna/fedora/$releasever/$basearch/
http://ftp-stud.fht-esslingen.de/pub/Mirrors/rpm.livna.org/fedora/$releasever/$basearch/
failovermethod=priority
#mirrorlist=http://rpm.livna.org/mirrorlist-5
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-livna


import the GPG key...

shell# rpm --import http://rpm.livna.org/RPM-LIVNA-GPG-KEY


and install xmms with mp3 support...

shell# yum --enablerepo=livna install xmms-mp3 xmms-faad2


7) A DVD player...

shell# yum --enablerepo=livna install xine libdvdcss

(However, until you can get hardware support for video, it's going to drop
a lot of frames - so see the tips below for "Graphics Card".)


8) Graphics Card (everything (video playback, OpenGL rendering, etc)
works as of kernel 2.6.17-1.2174 and the fglrx driver version 8.28.8)

shell# yum --enablerepo=livna install kmod-fglrx-smp

shell# /usr/sbin/ati-fglrx-config-display enable

restarted.

and then selected "display" form the administration menu, and then configured
the hardware graphics card to "fglrx". I then restarted X.
This seems to have done the trick!

You can double check that things are going well by looking at:
System->Administration->ATI-fglrx



9) Suspend (If you are running a kernel older than 2.6.17-1.2139_FC5)

First, make sure the kernel module for the wireless card exists (if a new
kernel just came out, you may have to wait a few days).

a: get a newer kernel (version 2.6.17-1.2139_FC5 or higher)

shell# yum update

b: plug the computer into a wired network and reboot into the new kernel.

c: remove the old wireless stuff...

shell# yum remove ipw3945 ipw3945d ipw3945-ucode ipw3945-kmdl-OLD_KERNEL_VERSION_FC5smp
Removing : ipw3945-kmdl-2.6.16-1.2133_F ######################### [1/5]
Removing : ipw3945-firmware ######################### [2/5]
Removing : ipw3945d ######################### [3/5]
Removing : ipw3945 ######################### [4/5]
Removing : ipw3945-ucode ######################### [5/5]


d: install the newer wireless stuff...

shell# yum --enablerepo=atrpm\* install ipw3945 ipw3945d ipw3945-ucode ipw3945-kmdl-CURRENT_KERNEL_VERSION_FC5smp
=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
ipw3945 i386 1.0.10-10.rhfc5.at atrpms 35 k
ipw3945-kmdl-2.6.17-1.2139_FC5smp i686 1.0.10-10.rhfc5.at atrpms 89 k
ipw3945-ucode noarch 1.13-1.at atrpms 65 k
ipw3945d i386 1.7.19-2.at atrpms 35 k
Installing for dependencies:
ieee80211-kmdl-2.6.17-1.2139_FC5smp i686 1.1.14-11.rhfc5.at atrpms 34 k

Transaction Summary
=============================================================================

e: get the wireless daemon running again

shell# /sbin/depmod -a
shell# /sbin/modprobe ipw3945 (load the kernel module)
shell# /sbin/ipw3945d (start the wireless daemon)

And reboot. To suspend the computer, select suspend from the System
menu. Do not select "Shut Down" and then click on the "suspend" button. For
some reason, that doesn't work.

I then modified my Power Management Preferences so that the laptop would
suspend when the lid is closed. Also, when running on battery, I set it so
that it would suspend the computer if is inactive for 30 minutes.






##################################################################
#### ######
#### HOW TO UPDATE THE KERNEL ONCE YOU HAVE EVERYTHING SET ######
#### ######
##################################################################


a: First make sure everything is updated:

shell# yum update --exclude kernel-smp

b: Make sure there are wireless RPMs for new version of the kernel on the
ATRpms site:

http://atrpms.net/dist/fc5/ipw3945/

c: Install the new kernel:

shell# yum update

=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
kernel-smp i686 2.6.17-1.2157_FC5 updates 15 M
Removing:
kernel-smp i686 2.6.16-1.2133_FC5 installed 39 M
Removing for dependencies:
ieee80211-kmdl-2.6.16-1.2133_FC5smp i686 1.1.13-10.rhfc5.at installed 84 k

Transaction Summary
=============================================================================
Install 1 Package(s)
Update 0 Package(s)
Remove 2 Package(s)
Total download size: 15 M
Is this ok [y/N]: y
Is this ok [y/N]: y
Downloading Packages:
(1/1): kernel-smp-2.6.17- 100% |=========================| 15 MB 04:32
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Removing : kernel-smp ######################### [1/3]
Installing: kernel-smp ######################### [2/3]
Removing : ieee80211-kmdl-2.6.16-1.2133 ######################### [3/3]


d: plug the computer into a wired network and reboot into the new kernel.

c: remove the old wireless stuff... (replace "OLD_KERNEL_VERSION" with the
actual version number.)

shell# yum remove ipw3945 ipw3945d ipw3945-ucode ipw3945-kmdl-OLD_KERNEL_VERSION_FC5smp
Removing : ipw3945-kmdl-2.6.16-1.2133_F ######################### [1/5]
Removing : ipw3945-firmware ######################### [2/5]
Removing : ipw3945d ######################### [3/5]
Removing : ipw3945 ######################### [4/5]
Removing : ipw3945-ucode ######################### [5/5]


d: install the newer wireless stuff...

shell# yum --enablerepo=atrpm\* install ipw3945 ipw3945d ipw3945-ucode ipw3945-kmdl-CURRENT_KERNEL_VERSION_FC5smp


e: Get the wireless daemon running again

shell# /sbin/depmod -a
shell# /sbin/modprobe ipw3945 (load the kernel module)
shell# /sbin/ipw3945d (start the wireless daemon)

(at this point you should be able to disconnect the ethernet cable from the
computer and the wireless should kick in automatically)

g: update the ati driver (if you can)

shell# yum --enablerepo=livna update kmod-fglrx-smp

shell# /usr/sbin/ati-fglrx-config-display enable

g: reboot!

Everything should be working....

Friday, February 02, 2007

C Tutorial: Strings

(link to tutorial)

Defining Strings:
C has a character type, but no string type as such. Text is defined as a character array, that is as a table of single characters. The lack of a string type in C is quite a severe deficit for application programming, and was one of the main reasons for developing C++, which does have a string type.

There are no C instructions that will handle a string as a single variable in the way MVC or MOVE do. Instead, string functions like strcpy() or memcpy() implement loops that address each character one by one.

To declare a text string, specify a type of char and place the number of characters in the array in square brackets after the string name.

char volume[6];

This generates a table of six contiguous characters and an implied pointer to the first character. A detailed description of this pointer is given in Addressing a String.

Addressing Each Character in a String:

The string declared above is an array with six members, volume[0] through volume[5]. Each member is of type character. A character literal is enclosed in single apostrophes. Double quotes identify a string literal (character array), not a character. So 'x' is a one-byte character and "x" is a two-byte character array consisting of an 'x' followed by a null-byte.

You can also assign characters hex values. In particular, note that a null-byte (a byte with all bits set to zero) can be written either using an escape character (backslash) or as a hex value:

char zerobyte = '\0'; /*use escape character*/
char zerobyte = 0x00; /*use hex value*/

Both of the following lines assign the letter S to the first character in volume[], first using a character literal and then using the EBCDIC hex value.

volume[0] = 'S';
volume[0] = 0xe2;

Since C handles characters internally as short integers, you can do arithmetic with them. This is more than a party trick: the routines to convert between uppercase and lowercase letters simply add or subtract 'A' - 'a' to the character. The following line sets the second character in volume[] to T.

volume[1] = volume[0] + 1;

Addressing a String:

The implied pointer that C generates when you declare a character array has some special properties:

  • It has the string name (no subscripts);
  • It is a constant (you can't alter its value);
  • The sizeof() function returns the size of the array, not that of a pointer.
The memcpy() function copies the string at the second address to the string at the first address for a length specified by the third parameter. Memcpy() will accept volume as its first parameter, because volume is a pointer.

Memcpy() also will allow a string literal as its second parameter. String literals are enclosed in double apostrophes and always have a null byte of binary zeros appended to the end in memory.

memcpy(volume, "STRG01", sizeof(volume));

The memset() function sets all characters in a string to a padding byte. The following line sets all six characters of volume[] to S.

memset(volume, 'S', sizeof(volume));

Memcmp() compares two strings for the length specified in the third parameter. It returns zero if a match is found.

if (memcmp(volume, "STRG", 4) == 0)
{
ProcessStorageVolume(volume);
}
else;

Looping through a String using a Subscript:
The usual way to loop through an array is to use a variable as the subscript in a for or while loop. More details about loops are given in the Loop Tutorial.

int i;
char volume[6];

for (i = 0; i LT sizeof(volume); i++)
{
volume[i] = '0';
}

This code will load volume[] with '000000'. The loop is set to terminate when i is less than 6 because the subscripts go from 0 through 5.

Looping through a String using a Pointer:
Since you can't change value of the pointer generated automatically by C when you declare an array, you must declare your own pointer to loop through a string. Initialize it by copying the implied pointer.

char volume[6];
char *cptr;

for (i = 0, cptr = volume; i LT sizeof(volume); cptr++, i++)
{
*cptr = i;
}

Initializing a String:
You can set the initial value of a character array when you declare it by specifying a string literal. If the array is too small for the literal, the literal will be truncated. If the literal (including its null terminator) is smaller than the array, then the final characters in the array will be undefined. If you don't specify the size of the array, but do specify a literal, then C will set the array to the size of the literal, including the null terminator.

char volume[6] = "STRG01"; /* contains 'S', 'T', 'R', 'G', '0', '1' */
char volume[] = "STRG01": /* contains 'S', 'T', 'R', 'G', '0', '1', '\0' */

Null-terminated Strings:
C was developed for Unix and still assumes that text strings will be delimited by a null terminator, a byte containing binary zeros. That means that string functions like strcpy() and strcmp(), as well as those that use strings like sprintf(), will identify the length of the operation to be not the length of the array declared, but the length between the first character and the first null byte, wherever it is.

S0C4 abends on a mainframe are often caused by a string not being delimited by a null terminator. The following lines will format a message containing the value in volume[], by copying volume[] into a temporary field initialized with nulls, and using that as the string.

char volume[6], temp[7], buffer[20];
memset(temp, '\0', sizeof(temp));
memcpy(temp, volume, sizeof(volume));
sprintf(buffer, "Volume is %s", temp);

If you know the exact size of a text string, you can print it out safely by setting the minimum and maximum size to print.

printf(buffer, "Volume is %6.6s", volume);

Thursday, January 25, 2007

Gentoo configuration issues (2)




Updating configuration files in gentoo
=======
* Regenerating GNU info directory index...
* Processed 160 info files.
* IMPORTANT: 34 config files in /etc need updating.
* Type emerge --help config to learn how to update config files.
=======
In this case run the command: #etc-update


To add a service to the start up runlevel (so it will start every time the machine is reinitiated)

Adding to the run level:
# rc-update add gpm default
# rc-update add sshd default

To find a string:
Goto the applications folder, then:
grep -inr searchterm *
Ex: grep -inr localhost.localdomain *
This should show you all the files that contain that string.


3) Gentoo Method

Gentoo also uses a script to enable or disable services during boot-up. The name of the script is rc-update . Gentoo has three default runlevels. Them being: boot, default and nonetwork. Suppose I want to add the apache webserver to start in the default runlevel, then I run the command:
# rc-update add apache2 default
... and to remove the webserver, it is as simple as :
# rc-update del apache2
To see all the running applications at your runlevel and their status, similar to what is achieved by chkconfig --list, you use the rc-status command.
# rc-status --all

Gentoo configuration issues










To update the entire system
#emerge --update --deep --newuse --ask world

To manage blocked packages
http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?full=1#blocked
To un emerge the blocked packages:
#emerge --unmerge pckgname

Upgrade guide
http://www.gentoo.org/doc/en/new-upgrade-to-gentoo-1.4.xml

1. Before you begin

Be prepared

As with any major upgrade to the core of your Gentoo system, there is always the possibility that unforeseen problems will ensue. It is always prudent to back up all important data before beginning this process. If possible, try to allocate a large block of time for this upgrade, so that you will not feel rushed. All the software on your machine will need to be recompiled.

Other options

This is not the only way to upgrade your system. You can install a new 1.4 system onto a separate partition and reuse some of your system configuration instead. This method also has the advantage that you can always go back to your old system in the meantime as a fallback. You may also decide to simply not upgrade your system. If you decide you want to upgrade in place, read on.

General notes

Whenever the code listings suggest running the emerge command, it is always a good idea to make a test run of the command using the -p or --pretend option to make sure that the command will do what you expect it to do.

2. Upgrading in place

Get Portage as current as possible

Some of the syntax of current ebuilds is unreadable by older versions of Portage. If you don't have at least Portage 2.0.44, try upgrading Portage.

Code Listing 2.1: Updating Portage

# emerge --sync
# emerge -u portage

Note: If your Portage version is very old, you may get an error message containing the phrase "unscriptable object". Read and follow the instructions in /usr/portage/sys-apps/portage/files/README.RESCUE. Your Portage install should then be current.

Preparing GCC for cohabitation

You will be installing a newer version of GCC during this upgrade. Versions of GCC older than 2.95.3-r8 are not designed to have multiple versions of GCC installed. You must therefore upgrade GCC to at least version 2.95.3-r8. This will also have the beneficial side-effect of installing the gcc-config package on your system, which can be used to switch back and forth between various installed versions of GCC.

Code Listing 2.2: Updating GCC

# emerge -u gcc 

You can now check to see if gcc-config is working properly:

Code Listing 2.3: Verifying GCC profile

# gcc-config --get-current-profile 

This should return i686-pc-linux-gnu-2.95.3 on most x86 systems. Older systems may return i586-pc-linux-gnu-2.95.3.

Installing GCC 3

Now you can install a newer version of GCC without damaging your current compiler. Look in /usr/portage/sys-devel/gcc for a version of the GCC ebuild that is at least 3.2.1-r6. Choose the highest version that is marked stable for your architecture. To see if an ebuild is considered stable for your architecture, look for the KEYWORDS line in the ebuild file. If it has your architecture listed without a ~ in front of it, it is considered stable. Assuming 3.2.2 is the most current stable version, we first need to remove the glibc dependency from gcc.

Edit /usr/portage/sys-devel/gcc/gcc-3.2.2.ebuild and search for the line containing DEPEND. Remove the glibc dependency and save the ebuild.

Code Listing 2.4: Editing gcc-3.2.2.ebuild

# vim /usr/portage/sys-devel/gcc/gcc-3.2.2.ebuild 

Now install the latest GCC version on your system:

Code Listing 2.5: Install the latest GCC

# USE="-java" emerge /usr/portage/sys-devel/gcc/gcc-3.2.2.ebuild 

Changing profiles

Now you need to change two sets of profiles: your gcc-config profile and your Portage profile.

Code Listing 2.6: Change the Portage profile

# cd /etc
# rm make.profile
(Replace "x86" with your architecture)
# ln -s ../usr/portage/profiles/default-x86-1.4 make.profile

Code Listing 2.7: Change the GCC profile

(Note the one for the version you just emerged, use it below)
# gcc-config --list-profiles
(Replace with the version you noted above)
# gcc-config i686-pc-linux-gnu-3.2.2

Recompile toolchain

Now you need to recompile your core toolchain with your new compiler. If you are continuing in the same shell, you need to run source /etc/profile as gcc-config instructed you to. Then emerge glibc and binutils using your new compiler:

Code Listing 2.8: Rebuilding the toolchain

# emerge glibc binutils 

Warning: It is quite likely that you will upgrade glibc from a 2.2 or older version to 2.3. Do not downgrade glibc afterwards. Any software you have compiled against glibc 2.3 will stop working, and this can make your system unusable.

Recompiling everything with your new compiler

Now you may recompile everything on your system with your new compiler:

Code Listing 2.9: Rebuilding the entire system

# emerge -e world 

Note: If this command fails at any point due to errors, you can use emerge --resume to continue the process where you left off. This requires Portage 2.0.47 or later.

Wednesday, January 24, 2007

IBM-Lenovo Thinkpad T60

Author
Bill Giannikos (bill2 at giannikos.com.au) (Link to webpage)

Discuss this laptop here.

Introduction
This is a guide to running Linux with the IBM-Lenovo Thinkpad T60 laptop, model 19514BM.

Editing this page
Feel free to edit this page if you have further information or corrections to add. You may also completely delete and re-create this page if you feel you can do a better job as long as you at least cover the details already here.

Specifications
ProcessorIntel Core Duo T2400 1.83GHZ
Screen14.1"
RAM512MB
HDD60GB
Optical DriveDVD-RW
GraphicsIntel Media Accelerator 950
NetworkGigabit Ethernet, 802.11g Wireless, Bluetooth
Other3 x USB2.0


Linux Compatibility
DeviceCompatibilityComments
ProcessorYes
ScreenYes
Optical DriveYes
GraphicsYesSee notes below
SoundYes
EthernetYes
WirelessYesUse ipw3945 driver
BluetoothNot tested
56K ModemNot tested
USBYes
PCMCIANot tested but should work


Notes
For best results you should use a Linux distribution with kernel 2.6.16 or greater, such as Fedora Core 5.

Some versions of the T60 use the Intel Media Accelerator 950 graphics chip. Use the i810 driver for these laptops.

Some versions of the T60 use the ATI Mobility Radeon x1300 and x1400 graphics chip. The open source radeon driver does not support this chip yet but you can get it working with the proprietary ati driver.

Summary
You should use a Linux distribution which includes kernel 2.6.16 or greater, such as Fedora Core 5. With an up to date distribution this notebook is easy to get going.

Debian GNU/Linux (sid) on the IBM/Lenovo ThinkPad T60

(Link to webpage)
Specification
IBM/Lenovo ThinkPad T60
  • Intel Core Duo processor T2500 (2.0 GHz)
  • Mobile Intel 945PM Express Chipset
  • 2 GB RAM (PC2-5300 667 MHz DDR2)
  • 100 GB SATA 5400 rpm hard disc (Fujitsu MHV2100BH)
  • ATI Mobility Radeon X1400 M54 128 MB
  • 14.1" SXGA+ (1400x1050) TFT color
  • DVD burner / Super Multi-Burner
  • PC Card Slot
  • Gigabit Ethernet (Intel 82573L)
  • 3 USB 2.0 ports
  • 56K V.90 (V.92 designed) modem
  • High Definition (HD) Audio AD1981HD
  • Infrared port
  • Bluetooth
  • Intel PRO/Wireless 3945ABG
  • Fingerprint reader

First Impressions

The build quality of the T60 is extraordinary. Compared to the HP Omnibook XT1000 which I own as well and which isn't bad quality at all, the ThinkPad T60 is even better. Everything feels rock solid, you cannot bend the notebook, it sits in front of you like a black beautiful monolith. Regarding the opinions on the net that the T60 doesn't look as good as its predecessors, I have to disagree. I think the T60 looks much more "finished" and business-like than even the T43.

Installation Preparation

The ThinkPad comes preinstalled with Windows XP Professional. There's an additional partition on the hard disc which contains "Rescue and Recovery" tools in case something goes wrong. This is a hidden partition, accessible via the "ThinkVantage" button during booting.
As I didn't want to lose either Windows XP itself nor the recovery partition, some investigations were necessary. The Master Boot Record (MBR) seems to be a special one that checks for the "ThinkVantage" button. So, installing GRUB in the MBR will render the button useless. Installing GRUB into the GNU/Linux root partition and making it bootable, is a nice idea but doesn't work with this MBR either.
The installation procedure I took is this:

  • First of all I created the recovery media set (one CD and one DVD) from within Windows. In case something goes wrong, you can always restore to the factory settings this way.
  • Then I shrank the Windows partition down to only 30 GB.
  • I installed Debian GNU/Linux with the latest Debian Installer Beta 2 for the forthcoming Etch release. Installation works like a charm. SATA and the Gigabit Ethernet are recognized without problems. No manual fiddling necessary here.
  • As mentioned above, I didn't install GRUB in the MBR of the hard disc, but in the GNU/Linux root partition.
  • In order to make Debian really bootable, I used the Windows XP boot loader. Therefore, the 512 bytes GRUB installed in the GNU/Linux root partition (/dev/sda4 in my case) have to be copied over to the Windows partition. The Debian installer offers you the option to open a shell where you can do:
    dd if=/dev/sda4 of=bootgrub.bin bs=512 count=1
    Now copy bootgrub.bin to some removable media or to some other computer via network for later on.
  • When the Debian installer prompted for a reboot, I booted into Windows XP, copied the bootgrub.bin file into C:\ and added the following line to C:\boot.ini:
    C:\bootgrub.bin="Debian GNU/Linux"
    I also made this the default and decreased the timeout to 5 seconds, but that's just personal taste.
  • When I rebooted into Debian, the first this was changing /etc/apt/sources.list from etch to unstable and doing an apt-get dist-upgrade.

Once you know how to do it, it's not very hard. ;-)

Framebuffer Booting

If you want to see your two Tuxes when booting, add the following option to your kernel options when booting:
vga=0x323

Kernel

I'm using Linux kernel 2.6.16 on the T60. The most important configuation option I had to change after the installation was multi-processing. If the machine has two processors, we would be stupid not to use both! Here's my config-2.6.16 in case you want to have a look at it.

X11

The ATI Mobility Radeon X1400 is relatively new and is not yet supported by the ati drivers included in XFree86 or Xorg. However, there is a binary only driver (called fglrx) by ATI themselves available. This driver is included in Debian and comes with source for a kernel module (for kernel 2.6.16 at present) which you should compile as well.
If you think the fonts are too small, have a look whether your X server is started with the -dpi 96 option. If so, remove it and enter the dimensions of your screen in the xorg.conf as DisplaySize in the Monitor section. Then X calculates the DPI setting and the fonts get larger. In order to make most of the touchpad, use the Synaptics driver which is supplied with Xorg. My xorg.conf is here as a reference.
Especially interesing is the Generic Mouse section as this enables middle mouse button scrolling of the UltraNav.

Sound

For sound, just compile ALSA into the kernel and especially the snd-hda-intel module (configuration option CONFIG_SND_HDA_INTEL). That was enough to make it work for me.

Network

The Gigabit Ethernet in the T60 is supported by the e1000 driver (configuration option CONFIG_E1000) and just works.

WLAN

At present you need to disable all WLAN and IEEE80211 stuff in the kernel. Then you have to build it from http://ieee80211.sf.net/ and install the driver for the WLAN card from http://ipw3945.sf.net/ which works quite well for me. But connecting to an access point can take very long at some times.

USB

Configure USB support in your kernel and install udev then hotplugging should just work as well.

Mouse

The internal touchpad and TrackPoint are on /dev/psaux. In order to make USB mice work, configure your kernel in a way that mice are enabled in the HID section of USB. In my xorg.conf I have defined the touchpad and the TrackPoint as CorePointer and have set up an additional input device that sends core events as soon as an USB mouse is plugged in.

Fingerprint reader

There's an excellent guide of how to enable the fingerprint scanner which I followed to the letter. Afterwards you can log into your account using the fingerprint scanner like you can on Windows. Cool!

Modem

I haven't spent any time in configuring it as I don't need it.

IrDA

I have not yet spent any time getting it to work.

Bluetooth

I have not yet spent any time configuring it.

ACPI

I have all ACPI modules enabled, especially ibm-acpi. If you compile that as a module and add the following line to /etc/modules, you have control over the fan via /proc/acpi/ibm/fan (although you can only enable or disable it):
ibm-acpi experimental=1

ThinkPad keys

Using either tpb or hotkey-setup makes the additional buttons emit key codes which you can map to actions.

Problems

The only thing that is worrying me a little is the fact that the fan is constantly spinning. I had hoped the T60 would be a machine near quiet. But due to the spinning fan this is not the case. That's the only disappointment for me.

Related pages

ThinkPad T60 - Installation Guide for Linux

Debian Linux on an IBM Thinkpad T43p

Click here to go back to the index page.

Linux on a Lenovo T60

(Link to webpage)

So, work is letting me use a Lenovo T60. I put Gentoo GNU/Linux (2006.0) on it and decided to create a small page detailing the results.

If you're planning on using Debian External Content on model 2007-63g, I highly recommend Marco Kraus' installation guide External Content .

Specifications
  • Make/Model: Lenovo T60 (Model 2008-CTO)
  • Processor: Intel Core Duo (Centrino Duo) T2400 @ 1.83GHz, 2048 KiB L2 Cache
  • Graphics: ATI X1400 w/64MiB DDR-1 Video RAM
  • Memory: 1024MB
  • Storage: Hitachi 60GB 5400RPM SATA Disk Drive
  • Optical Drive: CDRW/DVD Drive (HL-DT-STCD-RW/DVD DRI)
  • Audio: Intel HD Audio Chipset
  • Wireless Networking: Intel PRO/Wireless 3945ABG
  • Wired Networking: Intel 82573L Gigabit Ethernet
  • Peripheral Networking: Bluetooth

All the goodies (lspci, dmesg, etc.) can be found here.

Hardware Table

Here's a list of the hardware in the laptop:

Component Model Status/Support Notes
Processor(s) Intel Core Duo (Centrino Duo) T2400 @ 1.83GHz, 2048 KiB L2 Cache Excellent Add CONFIG_X86_SMP and CONFIG_MTRR to your kernel, and you should be fine.
Memory 1024MB DDR2 Excellent Add CONFIG_HIGHMEM to your kernel config, otherwise you'll be capped at 896MB.
Graphics ATI X1400, 64MiB DDR-1 RAM Fair Well, this works fine with the VESA driver. However, ATI has some binary drivers External Content that seem to do the trick, too. Xvideo only started working in the 8.26.18 release, though.
IDE Controller Intel 82801GBM/GHM SATA Controller Excellent Works fine. Add CONFIG_SCSI_SATA, CONFIG_SCSI_SATA_AHCI, and CONFIG_SCSI_ATA_PIIX to your kernel. Probably beats the heck out of the Silicon Image junk in my Athlon64 box ...
Hard Disk Hitachi 60GB 5400RPM SATA Disk Drive Excellent Just.. works, like it should.
Optical Drive H-L Data Storage (Hitachi-LG) CD-RW/DVD GCC-4246N Bad libata.atapi_enabled still seems to have problems with AHCI, so disable it in the BIOS if you want to use the drive. Anyway, I burned an ISO image of the T60 BIOS, and the drive does work fine.
Audio Intel HD Audio Chipset Good Works fine w/ALSA. Use CONFIG_SND_HDA_INTEL in the kernel, and remember to run alsaconf, otherwise you won't get any sound. Use the PCM and Front volume controls to tweak the sound. I don't know what the Headphone volume control does, because it certainly doesn't modify the headphone output.
Wireless Networking Intel PRO/Wireless 8945ABG (802.11a/b/g) Fair Well, it works (tried w/802.11a), but Intel External Content needs to be whipped for requiring a binary-only regulatory daemon in addition to the binary-only firmware. The Gentoo package is somewhat brain-dead, too, since it requires net-wireless/ieee80211, which doesn't work if CONFIG_IEEE80211 is enabled. If you end up going this route, you'll have to disable CONFIG_IPW2100, CONFIG_IPW2200, CONFIG_PRISM54, and CONFIG_HOSTAP, since they require CONFIG_IEEE80211. (I suggest unpacking this in your home directory, and then just run ./load and ./unload manually)
Wired Networking Intel 82573L Gigabit Ethernet Good Works fine, enable CONFIG_E1000. The firmware on this seems to be buggy or something, because if I do a warm boot without a link (eg, no cable plugged in), I get "e1000_probe: The EEPROM Checksum Is Not Valid" when the e1000 module is loaded. This works on a cold boot, and when a cable is plugged in during a warm boot. Huh?
Peripheral Networking Broadcom BCM2045B Bluetooth 2.0 Receiver Excellent Works well w/my Logitech MX900 mouse. I suggest modularizing most (or all) of the Bluetooth options in the kernel, and emerging bluez-utils. Then, configure hidd to run at startup in /etc/conf.d/bluetooth, and rc-update -a bluetooth default. Gentoo's net.ppp scripts make jumping on the Internet via Bluetooth DUN a walk in the park.
Log

[Update 20060729] Updated most of the old stuff on the page. The kernel timing issue is in fact fixed in the released 2.6.17 kernel, and in distribution specific kernels, like Ubuntu External Content 's 2.6.15-26 patch. You don't need to do any hacking for ATI's drivers anymore, they build fine against 2.6.17 kernels.

[Update 20060422] I just realized that the optical drive hasn't ever worked. Correction, it hasn't ever been able to read media. I burned an ISO just fine w/cdrecord, since it uses its own SCSI library. Apparently with AHCI enabled, libata.atapi_enabled=1 does nothing, and there is no way of accessing this drive via /dev. So, disable AHCI to use your optical drive =(

[Update 20060418] There's an official (erm, hard-masked) ebuild for the 8.24.8 drivers, now. You still need to hack your kernel and change that line in firegl_public.c, though :)

[Update 20060417] I got the ATI video drivers to work, today. First, I hacked my kernel via the following:

  • Adding intermodule.o to the obj-y list in kernel/Makefile
  • Adding CONFIG_OBSOLETE_INTERMODULE=y to the end of my .config

That adds (yes, you can guess it) obselete inter_module functions to the kernel, since ATI's drivers are brain-dead and use them. Now, get an unofficial Gentoo ebuild from from this post External Content . Grab ati-driver-installer-8.24.8-x86.run and ati-driver-installer-8.24.8-x86_64.run from ATI External Content , and place them in /usr/portage/distfiles. Place the ebuild in /usr/portage/x11-drivers/ati-drivers (YES, this is bad, I know I should use PORTAGE_OVERLAY, but hopefully we'll see an official driver, soon, and won't have to worry) and run "ebuild ati-drivers-8.24.8.ebuild digest" to generate a digest. Next, go ahead and compile it, but interrupt the build right after it starts building the DRM module, and edit /var/tmp/portage/ati-drivers-8.24.8/work/common/lib/modules/fglrx/build_mod/firegl_public.c. Change MODULE_PARAM(firegl, "s"); to module_param(firegl, charp, 0);, then continue the build. If it works, awesome, if not - please wait for an official ebuild. Grab my dual-head xorg.conf below, if you want an example.

[Update 20060415] The first big problem I hit was a timer/clock issue, starting with a 2.6.15-gentoo-r1 kernel. Networking was just dog slow, and the system was dropping packets to hosts on the local LAN, along with some really weird latency. According to the kernel printk timestamps, only 30 seconds had gone by, when the system had been up for over 4 minutes. Also, not a good sign when keyboard repeat rate slows down and speeds up when you're just holding down a key.

The initial fix for this was to disable ACPI. Unfortunately, doing so prevented the SATA contoller to be detected. Disabling AHCI in the BIOS fixed this. However, the Intel audio module wouldn't load, and the Intel NIC didn't feel like transmitting or receiving any frames.

So, I jumped on the bleeding edge and got 2.6.17-rc1, then patched to -git9. I also set the timer frequency to 1000Hz (shouldn't have to do this, since 250Hz works perfectly on my IBM T42). I also made sure to enable the following:

CONFIG_IRQBALANCE=y
CONFIG_REGPARM=y

Maybe it was a combination of a couple things, but stuff started working. Every once and awhile I notice a small jitter here and there, which I don't think is normal, but the system feels much better, and SSH sessions are usable. wmnd External Content doesn't seem too happy, but I don't care right now. Grab my kernel .config here.

Dual boot Linux-Windows (Leaving MBR untouched)

Disclaimer: This document is provided "as is" without warranty. Use at your own risk. In no event shall I be liable for any damage resulting from the use of this work.

This HOWTO applies if:

  • Your machine already has Windows installed, and you are installing Linux as a second operating system, and
  • You want to leave the Windows boot loader (NTLDR) on the MBR (Master Boot Record). This allows you to continue to boot Windows with no issues. I've heard that Windows 2000/Windows XP or anti-virus software may complain if the MBR does not contain the Windows boot loader

You can use either GRUB or LILO to dual-boot Windows 2000/Windows XP and Linux. Both functionally work fine, but from what I've read, GRUB requires less maintenance, as LILO requires you to reinstall the boot loader (by running /sbin/lilo) every time you rebuild the kernel or make changes to /etc/lilo.conf.

Requirements for /boot Partition

The location of the /boot partition on the hard drive is critical so that you don't get screwed by the infamous BIOS 1024 cylinder limit. The BIOS of older systems can't access data beyond cylinder 1024, which is ~8.5 GB. A simple way to avoid the BIOS 1024 limit is to create /boot within the first 1024 cylinders (~8.5 GB) of the hard drive. If you have multiple hard drives (disks), /boot must be on the same hard drive (probably the first hard drive) that has the Windows boot loader (NTLDR) on the MBR.

Here are some options for where to create /boot partition.

  1. (What I did) Shrink the Windows partition such that there is 50 MB of unused disk space at the beginning of the drive and lots of space after the Windows partition. You can install the /boot Linux partition in this first 50 MB and avoid any potential issues with the 1024-cylinder limit entirely.
  2. Shrink the Windows partition such that it does not cross the 1024 cylinder (~8.5 GB), and install the /boot partition right after the Windows partition.
  3. Use LBA (Logical Block Addressing). LBA allows you to boot beyond the 1024 cylinder. In order to use LBA, your BIOS must support it. In addition, for LILO, you must also add a flag to enable LBA support. GRUB supports LBA "out-of-the-box"

To non-destructively shrink the Windows partition, you can use the free software program fips (please note that fips does not currently support NTFS partitions). Another option is the excellent commercial product Partition Magic. It has an easy-to-use GUI. Unfortunately, the tool that comes with Red Hat 7.2, Disk Druid, does not have the ability to shrink existing partitions. Once you've shrunk the Windows partition, you can use Disk Druid during the Red Hat Installation to create all the partitions you need for Linux.

Dual-Boot Setup

Following are the steps to get dual-boot working with GRUB; I figured out how to do this by looking at a similar procedure for LILO. I've verified that this works for Windows 2000 and Windows XP, and this should work on Windows NT (all 3 OSs use the same booting architecture).

  1. Install GRUB on the first sector of the /boot partition. DO NOT INSTALL IT ON THE MBR!.
    If you are performing the Red Hat installation, for the "Boot Loader Installation" screen:
    • Select "Use GRUB as the boot loader"
    • Select Install Boot Loader record on "...First sector of boot partition".
    • After finishing the Red Hat installation, reboot into Linux. If you don't have a boot disk, try booting in linux rescue mode
    If you already have Linux installed:
    • Run the following command (e.g. assuming /boot is /dev/hda2): grub-install /dev/hda2.
      If you don't know which partition contains /boot, run the df command and check the output.
    • Edit /etc/grub.conf and make sure there is an entry for your version of Windows. For reference, here is a copy of my /etc/grub.conf file.
  2. Determine which partition contains the /boot partition by running the df command. You'll see output like this:
    Filesystem           1k-blocks      Used Available Use% Mounted on
    /dev/hda3 8665372 1639580 6585612 20% /
    /dev/hda2 46636 5959 38269 14% /boot
    /dev/hda6 513776 189504 324272 37% /osshare
    none 256624 0 256624 0% /dev/shm
    From this output, we see that /boot is on /dev/hda2.
  3. Make a copy of the Linux boot sector onto a floppy or onto a FAT32 partition. We'll name this copy linux.bin.
    To make a copy onto a floppy:
    • Mount the floppy drive if it's not mounted (assumes /mnt/floppy exists): mount -t msdos /dev/fd0 /mnt/floppy
    • Run the following command: dd if=/dev/hda2 of=/mnt/floppy/linux.bin bs=512 count=1
      Substitute the path for the if= parameter (the input file) with the appropriate partition from the previous step. E.g., set if= to /dev/hda2.
    To make a copy onto a FAT32 (vfat) partition:
    • Mount the FAT32 partition if it's not mounted yet. If it isn't listed in the df output, it hasn't been mounted yet. Check out steps 3a-3c for mounting a FAT32 partition on the "Share Partitions HOWTO".
    • Run the following command: dd if=/dev/hda2 of=/osshare/linux.bin bs=512 count=1
      Substitute the path for the if= parameter (the input file) with the appropriate partition from the previous step. E.g., set if= to /dev/hda2. Substitute the path for the of= parameter (the output file) with whatever is appropriate for your system. The example here (of=/osshare/linux.bin) is for copying onto a FAT32 partition called osshare.
  4. Reboot into Windows
  5. Copy the linux.bin file to C:\
  6. Run notepad and edit C:\boot.ini. Note that C:\boot.ini is a hidden system file, so it probably won't show up in Windows Explorer. To edit the file, try: Start->Run and enter: notepad C:\boot.ini. Add the following line at the end: c:\linux.bin="Linux"
    If your C: filesystem is NTFS (not FAT32), you must edit C:\boot.ini as a user with administrator-level privileges.
    To make C:\boot.ini writable, you can either :
    • Use Explorer:
      • Go to Tools->Folder Options->View and select Show hidden files and folders and deselect Hide protected operating system files (Recommended).
      • Right-click on the file, view the Properties and uncheck Read-only. You can now edit the file.
      • After editing the file, restore the settings to their original state.
    • Use the command-line:
      • Make the file writable: attrib -R -S -H C:\boot.ini.
      • After you've finished editing the file, put the settings back: attrib +R +S +H C:\boot.ini
    For reference, here is a copy of my boot.ini file.
  7. Reboot again. You should be able to pick either Windows or Linux. Selecting Linux will start GRUB

Troubleshooting

  • When I select Linux from the boot menu, I get a frozen "GRUB" (or an "L" in the case of LILO)
  • Make sure you created the linux.bin file correctly with the dd command. If you think you ran the command correctly, the problem may be that your /boot partition is beyond cylinder 1024 and your BIOS can't reach it. At system startup, the Windows boot loader lists the choices from boot.ini. When you select Linux, the boot loader then loads the 512-byte linux.bin file, and then BIOS tries to access the /boot partition to run GRUB. Some BIOS implementations can only address the first 1024 cylinders of a hard drive, which corresponds to ~8.5 GB. How do you fix this? Create your /boot partition before cylinder 1024; i.e. before ~8.5 GB.
  • If I select Linux from the boot menu, I get an error message that says "Windows XP could not load: The file hal.dll (windows/system32/) is missing or corrupt. Please reinstall.
  • This is usually caused by an error in the boot.ini file. If you are unable to find and fix the error, check out Kelly Theriot's page that provides various methods for addressing the problem.

Acknowledgments

  • Jimmy Andriambao: for recommending the link regarding hal.dll problems
  • Leif Roger Kolberg: for creating a Norwegian translation of this page
  • Dirk Goepfert: for creating a German translation of this page
  • Fred van Lieshout: for creating a Dutch translation of this page
  • Rostislav "Udo" Galicek: for creating a Czech translation of this page
  • Arun Swami: for validating the dual-boot setup with multiple hard drives. Thanks Arun!
  • Adrián I. Correa: for enthusiastically providing a Spanish translation of this page. Adrián said it best: "I love this wonder called The Internet!"
  • Devesh Mistry: for pointing out the use of chroot /mnt/sys/mnt/syimage when in linux rescue mode
  • Emmanuel Brun: for graciously providing a French translation of this page
  • Jason Noll: for reporting the hal.dll problem resulting from error(s) in boot.ini
  • Garth Patil: for helping to troubleshoot why GRUB was freezing and having a great sense of humor
  • Piete Brooks: for pointing out that editing C:\boot.ini requires administrator-level privileges and providing the content for making the file editable using Explorer
  • Paul Feehan: for providing the commands to make C:\boot.ini editable for Windows XP
  • Jan Holm Jensen: for reporting that C:\boot.ini is a hidden system file
  • Hampus Hedberg Hankell: for the following suggestion:
    I think you should add help for users in despair that already have installed grub on mbr ,thus loosing the their ability to boot into windows xp. Procedure for this is ,boot from a windows start disc and do a fdisk /mbr At least then they can reach their windows and this time doing it right
  • Mark Jordan: for verifying that this works on Windows XP and suggesting the content for copy to floppy
  • Darryl Eaton: for introducting me to Red Hat Linux

If you are interested in creating a translation of this page, please read the translation policy.

IBM (Lenovo Thinkpad)

http://www-306.ibm.com/pc/support/site.wss/MIGR-48NT8D.html

http://www.linux-tested.com/results/ibm_thinkpad_T60_1951-28u.html

http://www.linux-tested.com/results/ibm_thinkpad_T60_2623-d2u.html

Laptops:Lenovo Thinkpad T60

http://learn.clemsonlinux.org/wiki/Laptops:Lenovo_Thinkpad_T60

Running Linux on the Lenovo Thinkpad T60

(Link to webpage)
I've recently purchased a Lenovo Thinkpad T60 (reviews: here and here). The machine is powered by an Intel Core Duo processor, with two cores of each 1.83Ghz. More specs:
  • 1GB RAM
  • Intel IPW3945 ABG WiFi chip
  • 14" 1400x1050 TFT display
  • 60GB harddrive
  • CDRW / DVD combo drive
  • Intel Corporation 82573L Gigabit Ethernet Controller
  • ATi x1300 graphics

Kernel and drivers

Not all of the hardware in the T60 is supported out of the box. VGA and WLAN chips are pretty new, so I had to manually install drivers for those. With recent kernels (2.6.17 and higher) CPU hotplugging works - you can switch off one CPU while everything is running and switch it back on. It is even possible to set different cpufreq governors for each core and have the cores running at different speeds, those speeds are 1,0Ghz, 1,33Ghz and 1,83Ghz.

Intel IPW3845 WLAN

Intel has released a driver for the WLAN chip on http://ipw3945.sourceforge.net. In order to use the driver, you first need to compile and install the ieee80211 subsystem. Additionally, you need a binary microcode image for the WiFi chip, and a userspace daemon. The installation of the driver is a little complicated because you need 4 different components, but once done, the driver behaves stable and works very well with the exceptions that power management does not seem to be supported yet. (Note that I'm not refering to suspend and resume hooks in the driver, but to the wireless powermanagement you're setting with iwconfig [iface] power.) WPA supplicant works well with those drivers, using no encryption, WEP and WPA-PSK encryption. I did not yet test others.

I've created a patch containing the ieee80211 subsystem updates and the ipw driver, you can get it in the Files section. This patch can be applied to the kernel source directly, it saves you reinstalling the driver after a kernel rebuild.

ATi X1300 Graphics

Currently, there is no Open Source driver for the ATi x1300 chips other than VESA, which is quite slow.
ATi has recently released a binary driver that also works with the x1300 chips, albeit with minor problems: I'm getting minor corruption of the framebuffer consoles. (The problem is known to the ATi developers and should be fixed in one of the upcoming releases. Update: This problem is fixed in recent versions, the packages in the files section do not have this problem any more.)

I've generated suitable driver packages for Kubuntu Dapper Drake (6.06) and Edgy Eft (6.10). You can download the packages from the Files section.

Suspend2 (suspend-to-disk)

I've added Suspend2 to the kernel. This makes the suspend process quite a lot faster (I measured 40% compared with vanilla's swsusp) and adds possibilities for a nice progress bar, along with some other neat features. If you use the kernel image I've put in the files section, that would save you the hassle of patching and compiling it yourself. I've also put a hibernate.conf example in the Files section. In order to test, change the file so it says

ProcSetting userui_program /usr/local/sbin/suspend2ui_text
#ProcSetting userui_program /usr/local/sbin/suspend2ui_fbsplash
You can add a snazzy framebuffer splash later. How to do so is documented on suspend2.net.

Using ATi's binary driver, it took me some time to figure out that I need to setting

ProcSetting extra_pages_allowance 36000 
in /etc/hibernate/hibernate.conf, otherwise the machine would hang on suspend. With this setting, suspend2 is completely reliable for me.

(disk-backed) suspend-to-RAM

Suspend-to-RAM works reliably on this machine. I'm using a disk-backed implementation provided by suspend2 and the hibernate script (that's also used for suspend-to-disk in fact). The only change I made is setting
PowerdownMethod 3  
in hibernate.conf. 3 stands for S3 (suspend-to-RAM), 4 is S4 (suspend-to-disk). Setting it to 3 will make the notebook write a memory image to disk and then enter suspend-to-RAM. The notebook will actually need a little energy then, but you'll be able to resume much faster than with S4 (about 10 seconds with S3, around 30 seconds with S4, depending on imagesize and other variables). The memory image on disk adds the advantage that in case you run out of battery (or something else goes wrong with suspend-to-RAM), you're still able to resume from disk and continue working. Neat.

Minor suspend-related problems and workarounds

Note that in order to make suspend working with the fglrx binary ATi driver, the fglrx kernel module needs to be loaded. Having it not loaded, it's still possible to use X, albeit with slower rendering and no 3d, but suspend will crash reliably.
After a suspend/resume cycle the scrolling features of the touchpad is lost, switching to another VT and back to VT7 makes it work again. Compiling the evdev driver into the kernel image also solves this problem. (CONFIG_INPUT_EVDEV=y, this is done in the provided kernel image.)

Multimedia

Controlling the volume via the multimedia buttons on the notebook works fine out of the box using kmilo.

I'm using kmplayer to watch movies and xine to watch DVDs. For most DVDs to work, you need to install libdvdcss2. This library is due to it's questionable legal status in some countries (Hello USA!) not in the official Ubuntu archives. I've installed it from debian-multimedia.org, using the following line in my /etc/apt/sources.list:

deb http://www.debian-multimedia.org etch main
. If playing DVDs is terribly slow, check with hdparm if DMA is enables on the drive, and if not, read this.

In order to be able to use the sound device with more than one application at the same time, you can modify your /etc/asound.conf file as follows (or just create the file if it's not there):

pcm.card0 {
type hw
card 0
}

pcm.!default {
type plug
slave.pcm "dmixer"

}

pcm.dmixer {
type dmix
ipc_key 1025
slave {
pcm "hw:0,0"
period_time 0
period_size 2048 #1024
buffer_size 32768 #4096
#periods 128
rate 48000 #44100
}
bindings {
0 0
1 1
}
}
This enables ALSA's DMix plugin and unblocks the sounds device once an application is using it.

Various issues

DMA problems on DVD drive

DMA on the DVD-drive was switched off initially. The reason is that the IDE driver will claim the DVD drive first, it'll then appear as /dev/hdc. In this case, DMA cannot be switched on. Adding

hdc=noprobe libata.atapi_enabled=1
will solve that problem. Since the storage devices can be used with libata and thus do not need CONFIG_IDE, we can also switch it off in the kernel config and thus avoiding this problem. (I did this in my example .config.) I found this workaround on ThinkWiki.

Storage / SATA

At the moment of writing, the kernel's AHCI driver does not play nicely with suspend. In the BIOS, I switched from AHCI to "compatibility" mode, which works around that problem. I the meantime, the driver is being fixed, so I expect this to vanish with one of the next releases of the Linux kernel.

Various hacks

GRUB kernel options

In order to use swsusp, you need to add a kernel parameter, resume=/dev/sda1, where sda1 is your swap partition. (I have a swap partition of 1GB, which should be enough if I'm not "fully loaded".) Here's my grub entry:
title   Ubuntu, kernel 2.6.17.1
root (hd0,1)
kernel /boot/vmlinuz-2.6.17.1 root=/dev/sda2 ro vga=791 \
acpi_sleep=s3_bios,s3_mode quiet splash
savedefault
boot
(note that the kernel line has to be 1 line.)

Files

I've created a T60 kit for those that don't want to go through the hassle of collecting all the stuff in different places. This package should provide you with suitable drivers for the T60 hardware, it also has config files that you can use as a reference point.
The packages contain a kernel image which has ipw3945 support built-in (Note that you still need the microcode image and the ipw3945d daemon). There is also a couple of packages for the ATi driver, basically, you need to install all the packages here to get a kernel which has hardware accelerated graphics, support for the WLAN chip and swsusp support.

You can download the customized packages here.

Install them like this:
sudo dpkg -i xorg-driver-fglrx_8.25.18-1_i386.deb \
fglrx-control_8.25.18-1_i386.deb \
fglrx-sources_8.25.18-1_i386.deb \
xorg-driver-fglrx-dev_8.25.18-1_i386.deb \
kernel-image-2.6.17.1_10.00.Custom_i386.deb \
fglrx-kernel-2.6.17.1_8.25.18-1+10.00.Custom_i386.deb
If you prefer to patch and configure your kernel yourself, you can use the ipw3945 patch and the libata-acpi patch, along with my .config

Resources

17-10-2006, 22:03 h
© Sebastian Kügler