blog @ bjerck.net
Login RegisterCompiling an upstream kernel on ubuntu.
by: tomIntroduction
After downloading the source from kernel.org or any of the mirrors, you have at least two options for how to compile the source for a ubuntu system. First you can just do it the traditional way and just use the Makefile
that comes with the source directly. A second and more convenient and safer way to do this is to make a deb package, and let apt handle the installation and later eventually the removal of the kernel when it is no longer needed. Also making a deb will make sure that any installation scripts in the /etc/kernel
directory is executed. These scripts currently updates the initramfs image, updates grub config and recompiles any third party modules. These scripts can not be part of the kernel package since they are dependent of the target system.
Compiling using the make deb-pkg
target in the Linux kernel source Makefile
I didn't know this until recently, but the kernel Makefile has a deb-pkg target. It's the functionality used for compiling a new kernel documented in the Debian Kernel Handbook chapter 4. Se the scripts/package/builddeb
file in the Linux source to see what this build target does. If you have a multi core cpu, you may use make's -j<num jobs>
option, to speed things up.
Compiling using kernel-package
You should install the following packages:
kernel-package
fakeroot
build-essential
Relevant documentation:
man make-kpkg
man kernel-package
man make
Debian Kernel Handbook
wiki.ubuntu.com/KernelTeam/GitKernelBuild
/usr/share/doc/kernel-package/README.gz
/usr/share/doc/kernel-package/Kernel.htm
man gpg
man wget
www.kernel.org/signature.html
kernelnewbies.org/FAQ/KernelCompilation
Versions
There are three version labels:
- The stable upstream kernel versions at kernel.org whose format are three numbers separated by dots, like
3.4.6
. - The deb package of the kernel has it's own version; usually composed of the upstream version numbers and local revision numbers.
- Then there is a third versioning labeling the locally configured and compiled kernel. This version number is the output of
uname -r
.
/lib/modules
. It's important that these names are unique for each new kernel installed on the system in order to have binary compatibility between the kernel image and it's modules and prevent previously installed kernels and modules from being overwritten.
Downloading sources from kernel.org
In the following I'll download and unpack the source code for the 3.4.6 version of the upstream Linux kernel. I'll also download the gpg signature file and use it to verify the download. Using wget:
wget "https://www.kernel.org/pub/linux/kernel/v3.0/linux-3.4.6.tar.xz"
wget "https://www.kernel.org/pub/linux/kernel/v3.0/linux-3.4.6.tar.sign"
The compressed tar file needs to be decompressed before gpg verification:
xz -d "linux-3.4.6.tar.xz"
Use gpg to verify:
gpg --verify "linux-3.4.6.tar.sign"
If you get an error message about a missing key, you need to import the signing key from a keyserver:
gpg --recv-keys <key id>
And then run the gpg verify command again. You should then get a message proclaming "Good signature". If you get a message stating "Bad signature" something is wrong. If this step goes well, continue and untar the archive:
tar xf "linux-3.4.6.tar"
This should extract a directory named linux-3.4.6
. Make this your working directory:
cd linux-3.4.6
Configure the kernel
You now need to configure the kernel. If you want base the new configuration on the old config that was used when building your currently running kernel, you just copy it from the /boot
directory like this:
cp /boot/config-$(uname -r) .config
The new kernel will likely have new configuration options not present in the config for the old kernel. Therefore you now need to run one of the several utilities supplied with the kernel source for editing the configuration. For a terminal user interface you can use menuconfig which you start by giving the command make menuconfig
in the root directory of the source.
Use make-kpkg to compile the source
created: 2012-07-20 15:38:14. Permalink
Lenovo Thinkpad Edge S430 on Linux - First impressions
by: tomA few days ago I received my new Thinkpad Edge S430, and so far I'm satisfied with it. I've upgraded to 16GB memory, and changed to a 128GB ssd from Samsung (830 series 2.5"). If you plan on buying one of these laptops and install a ssd, you should know that it needs to have a maximum height of 7mm to fit. And remember to enable TRIM with the "discard" mount option in /etc/fstab. This was not done automaticalle by the Ubuntu installer. The system seems really fast and responsive with Ubuntu. (This is with 16GB memory and the Samsung ssd; I never ran Ubuntu with the original configuration.)
Pros:
- Low weight. (1.8kg)
- Good screen resolution (1600x900)
- Low price.
- Anti Glare
- Comfortable keyboard
- Aesthetics
Cons:
- Battery won't last more that 3½ - 4 hours with max backlight, general browsing and writing code in vim. And you will want to use max backlight in daylight. According to Lenovo the screen brightness is 250 nits.
- TN LCD means low viewing angles. But what can you expect at this price?
- The lid is a bit flexible.
Ubuntu 12.04
Installation of Ubuntu 12.04 went smoothly. Everything works; most notably WiFi, suspend and keyboard keys for backlight brightness, the thinklight, volume and media keys. However, I have not tested the dvd drive, fingerprint reader, thunderbolt, nor the hdmi port. There have been some stability issues where the system freezes completely every few hours, and there is nothing else to do than force a cold reboot using the power button. This seems to be an issue with Ivy Bridge: [IVB]12.04 64 bit System freezes (mouse, keyboard). A new kernel is in "proposed" which purportedly solves the freezes, and should be released within the next week. However I'm not patient enough to wait for that, so I've compiled and installed the latest stable release from kernel.org (3.4.6). This version is rock solid.
nVidia Optimus
This laptop has a graphics chip from nVidia in addition to the integrated chip in the Intel Core i5 CPU. nVidia Optimus technology is used on Windows to switch this chip on and off automatically to save battery. nVidia has not supported this functionality on Linux, something everybody should know by now after a Finnish student asked Linus Torvalds about his views on nVidias lack of support to open source developers for this crucial functionality which doesn't exist in their binary drivers, and he replied that nVidia was the singel worst company they had ever worked with. Se Phoronix article and nVidias response. The BIOS has a choice between integrated graphics and nVidia Optimus. Since I don't want the nVidia chip to be switched on and draw battery, and because of the lack of Linux support I disabled the nVidia Optimus chip in BIOS before installing Ubuntu. There is of course the Bumblebee project: http://bumblebee-project.org/.
Output from lscpi
tom@edge:~$ lspci 00:00.0 Host bridge: Intel Corporation Ivy Bridge DRAM Controller (rev 09) 00:02.0 VGA compatible controller: Intel Corporation Ivy Bridge Graphics Controller (rev 09) 00:14.0 USB controller: Intel Corporation Panther Point USB xHCI Host Controller (rev 04) 00:16.0 Communication controller: Intel Corporation Panther Point MEI Controller #1 (rev 04) 00:1a.0 USB controller: Intel Corporation Panther Point USB Enhanced Host Controller #2 (rev 04) 00:1b.0 Audio device: Intel Corporation Panther Point High Definition Audio Controller (rev 04) 00:1c.0 PCI bridge: Intel Corporation Panther Point PCI Express Root Port 1 (rev c4) 00:1c.1 PCI bridge: Intel Corporation Panther Point PCI Express Root Port 2 (rev c4) 00:1c.3 PCI bridge: Intel Corporation Panther Point PCI Express Root Port 4 (rev c4) 00:1c.4 PCI bridge: Intel Corporation Panther Point PCI Express Root Port 5 (rev c4) 00:1d.0 USB controller: Intel Corporation Panther Point USB Enhanced Host Controller #1 (rev 04) 00:1f.0 ISA bridge: Intel Corporation Panther Point LPC Controller (rev 04) 00:1f.2 SATA controller: Intel Corporation Panther Point 6 port SATA Controller [AHCI mode] (rev 04) 00:1f.3 SMBus: Intel Corporation Panther Point SMBus Controller (rev 04) 02:00.0 Unassigned class [ff00]: Realtek Semiconductor Co., Ltd. Device 5229 (rev 01) 03:00.0 Network controller: Intel Corporation Centrino Wireless-N 2230 (rev c4) 04:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller (rev 07)
Configuring trackpoint and trackpad
Relevant man pages are xinput
, evdev
and synaptics
. I used xinput --list
to find the names of the trackpad and trackpoint:
tom@edge:~$ xinput --list ⎡ Virtual core pointer id=2 [master pointer (3)] ⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)] ⎜ ↳ SynPS/2 Synaptics TouchPad id=11 [slave pointer (2)] ⎜ ↳ TPPS/2 IBM TrackPoint id=12 [slave pointer (2)] ⎣ Virtual core keyboard id=3 [master keyboard (2)] ↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)] ↳ Power Button id=6 [slave keyboard (3)] ↳ Video Bus id=7 [slave keyboard (3)] ↳ Power Button id=8 [slave keyboard (3)] ↳ Integrated Camera id=9 [slave keyboard (3)] ↳ AT Translated Set 2 keyboard id=10 [slave keyboard (3)] ↳ ThinkPad Extra Buttons id=13 [slave keyboard (3)]As can be seen, the relevant names are
SynPS/2 Synaptics TouchPad
and TPPS/2 IBM TrackPoint
To turn the trackpad off, issue this command:xinput --set-prop --type=int "SynPS/2 Synaptics TouchPad" "Synaptics Off" 1
By default the middle button of the trackpoint has a wheel emulation timeout of 200 milliseconds. This means that the driver issues a click event if the time between press and release is less than this value. If the time is larger, it issues scrolling events when used in combination with the trackpoint. This is really nice, but 200ms is too short for me, and I find it really difficult to issue clicks with this timeout. To increase this, issue the following command (on a single line):
xinput --set-prop --type=int "TPPS/2 IBM TrackPoint" "Evdev Wheel Emulation Timeout" 300
This sets the timeout to 300ms. Of course whenever the X server is restarted these commands must be issued again. One way to do this is to put these commands in
~/.xsessionrc
. Se man Xsession
.
Another thing you may want to change is the sensitivity and speed of the trackpoint. In order to do this you need to change the contents of two files in the /sys
virtual file system:
/sys/devices/platform/i8042/serio1/serio2/sensitivity
/sys/devices/platform/i8042/serio1/serio2/speed
This can be done as root this way:
echo -n 200 >/sys/devices/platform/i8042/serio1/serio2/sensitivity
echo -n 150 >/sys/devices/platform/i8042/serio1/serio2/speed
You may experiment with different numbers between 0 and 255. If you reboot you need to issue these commands again. I used to put these commands in /etc/rc.local
, but this doesn't work any more. I've also written udev rules, but that didn't work either. What worked was to put these commands in an upstart script. I put the following upstart
file in /etc/init
:
description "Trackpoint settings." env TPDIR=/sys/devices/platform/i8042/serio1/serio2 start on virtual-filesystems task script while [ ! -f $TPDIR/sensitivity ]; do sleep 1 done echo -n 200 > $TPDIR/sensitivity echo -n 150 > $TPDIR/speed end script
Update 2012-07-25
I can confirm that with 3.4.6, the instabilities of the stock Ubuntu kernel are gone. A patched 3.2 kernel is released from Ubuntu, but I haven't tested it. However, if you use nfs, you are likely to hit this bug in the nfs idmap code. A temporary solution is to use the new idmap code as described in the mailing list. Also, if you use Compiz (which is the default on Ubuntu) and suspend, you are likely to run across this bug. The temporary solution is to choose Unity 2D from the login manager. But then you will likely experience tearing while watching videos. If you still want to use Compiz, it is a good idea to save any open files before going to suspend.
created: 2012-07-18 18:05:00. Permalink
My experience with Linksys AE1000 wireless USB adapter under Linux.
by: tomAt university I often use a room where the wireless signal is so weak that the connection drops about ten times per hour. This happens when I use the internal wirless adapter in my Lenovo mini-laptop (S10-3). Therefore I decided to try an external adapter, and bought the Linksys AE1000.
Cisco does not support this device on Linux, but the chipset is from Ralink who does:
$ lsusb Bus 001 Device 013: ID 13b1:002f Linksys AE1000 v1 802.11n [Ralink RT3572]
However, there is a driver for this chipset in the kernel (rt2800usb), but when I plugged in the adapter, it was not recognised as supported by this driver. I'm using Ubuntu 12.04.
So I downloaded the official driver from Ralink's site, compiled it and installed it, and this time around it worked. But as became apparent soon, this driver dropped the connection after a few minutes and caused a kernel oops.
I didn't want to give up on the adapter, and now decided to compile a new kernel with a more current version of the rt2800usb driver. I downloaded the current stable Linux kernel (v3.4.2) and made two changes to the .config: 1) Support for the chipset rt3572 is marked as experimental and is not compiled by default, so this needed to be changed. 2) I set wireless powermanagement to off. Not really sure why, but elsewhere on the net people recommended it.
After installing the new kernel the connection has been stable, and no kernel oops. It works better than the internal adapter, and I can recommend it if you know how to compile a new kernel.
created: 2012-06-11 15:43:22. Permalink
Praktisk utregning av integralet i $\mathbb{R}^2$ - Repetisjon - Råtekst
by: tomIgjen gitt en kontinuerlig funksjon $f:A \in \mathbb{R}^2 \rightarrow \mathbb{R}$, og et rektangel $\u{R} = [a,b]\times[c,d]$. Riemann-summer gir en algoritme som lett kan implementeres i en datamaskin for å regne ut integralet over R, men det ville være interessant om vi kan finne en måte å beregne integralet symbolsk. For å komme frem til en generell metode er det naturlig å ta utgangspunkt i riemannsummer. Som vi husker er: $$ R(U,f) = \sum_{j=1}^n \sum_{i=1}^m f(\mathbf{u}_{ij})\cdot |R_{ij}| $$ Der U er mengden av utplukk fra en gitt partisjon $\Pi$. $R_{ij}$ er delrektangler definert ved en partisjon $\Pi_k$ av R. Maskevidden til $\Pi_k \rightarrow 0$, når $k \rightarrow \infty$ Vet at: $$ R_{ij} = |x_i - x_{i-1}| \cdot |y_j - y_{j-1}| $$ Slik at: $$ \begin{align} R(U,f) & = \sum_{j=1}^n \sum_{i=1}^m f(\mathbf{u}_{ij})\cdot \left( |x_i - x_{i-1}| \cdot |y_j - y_{j-1}| \right)\\ & = \sum_{j=1}^n \left( \sum_{i=1}^m f(x_i, y_j)\cdot |x_i - x_{i-1}| \right) \cdot |y_j - y_{j-1}| \end{align} $$ Siden maskevidden $\rightarrow 0$ når $k \rightarrow \infty$, så vil nødvendigvis også $|x_i - x_{i-1}| \rightarrow 0$.
created: 2011-04-23 12:33:00. Permalink
Kap 6 - Riemannintegralet i $\R^2$.
by: tomSom i forrige post har er vi gitt en kontinuerlig funksjon $f:A\subseteq\R^2\rightarrow\R$, et rektangel R = $[a,b]\times[c,d]$ og en partisjon $\Pi$ av R. $\u{R}_{ij}$ refererer til det ij-te delrektanglet i partisjonen.
Som for $\R\rightarrow\R$ kan vi gjøre et utplukk, dvs fra $\u{R}_{ij}$ velger vi et vilkårlig punkt. Betegn dette punktet $\mathbf{u}_{ij}$. Mengden av alle slike punkter fra R kan vi betegne med U. Anta som før at $\u{m}_{ij}$ og $\u{M}_{ij}$ er henholdsvis infimum og supremum til f på $\u{R}_{ij}$. Riemann-summen til $f$ over U er da:
$$
R(\u{U},f) = \sum_1^m \sum_1^n f(\mathbf{u}_{ij}) \cdot |\u{R}_{ij}|
$$
Vet at:
$$
\u{m}_{ij} \le f(\mathbf{u}_{ij}) \le \u{M}_{ij}
$$
Dermed er:
$$
\sum_1^m \sum_1^n m_{ij} \cdot |R_{ij}| \le R(\u{U},f) \le \sum_1^m\sum_1^n M_{ij} \cdot |R_{ij}|
$$
Anta nå at vi har en følge $\{\Pi_{k}\}$ av partisjoner der maskevidden $\rightarrow 0$, og tilhørende utplukk $\u{U}_k$. Da gjerlder at $R(\u{U}_k,f) = \sum_1^m \sum_1^n f(\mathbf{u}_{ij}^k) \cdot |\u{R}_{ij}| \rightarrow \iint_R f(x,y)\ud x\ud y$, når $k \rightarrow \infty$. Bevis:
Siden $f$ er kontinuerlig, så er $f$ også uniformt kontinuerlig. Gitt en $\varepsilon \gt 0$, så fins en $\delta \gt 0$, slik at for alle $\mathbf{u}$ og $\mathbf{v} \in |\mathbf{u} - \mathbf{v}| \lt \delta$, så er $|f(\mathbf{u}) - f(\mathbf{v})| \lt \frac{\varepsilon}{|R|}$. Videre fins en $\u{N} \in \mathbb{N}$ slik at for alle $k \gt \u{N}$, så er maskevidden til $\u{U}_k \lt \delta$. Dermed er vi garantert at for alle $\mathbf{u}, \mathbf{v} \in \u{R}_{ij}$, så er $|\mathbf{u} - \mathbf{v}| \lt \delta$, og dermed også at $|f(\mathbf{u}) - f(\mathbf{v})| \lt \frac{\varepsilon}{|R|}$. For en gitt partisjon $\Pi_k$ må vi da ha:
$$
sup\{f(\mathbf{u})\ |\ \mathbf{u}\in R_{ij}\} - inf\{f(\mathbf{v})\ |\ \mathbf{v}\in R_{ij}\} \le \frac{\varepsilon}{|R|}
$$
Likhet fordi supremum og infimum gir oss endepunktene i det åpne intervallet.
Multipliserer på begge sider med $|R_{ij}|$:
$$
sup\{f(\mathbf{u})\ |\ \mathbf{u}\in R_{ij}\} \cdot |R_{ij}| - inf\{f(\mathbf{v})\ |\ \mathbf{v}\in R_{ij}\} \cdot |R_{ij}| \le \frac{\varepsilon}{|R|} \cdot |R_{ij}|
$$
Summerer vi over alle delrektanglene $R_{ij}$ er differansen på venstre side ikke noe annet enn differansen mellom øvre og nedre trappesummer:
$$
\u{Ø}(\Pi_k) - \u{N}(\Pi_k) \le \varepsilon
$$
Vi kan altså få denne differansen så liten vi måtte ønske for alle partisjoner i følgen med index større enn N.
created: 2011-04-14 17:03:41. Permalink
Previous >