08 March 2012

96. Building a real-time kernel (3.2.9) on debian testing

Building an RT kernel is not terribly different from building a vanilla kernel:http://verahill.blogspot.com.au/2012/03/debian-testing-kernel-329.html

The main differences are:
1. the application of the relevant RT kernel patch
2. the configuration of RT specific kernel options

The latter step requires reading up on what an RT kernel does differently from a vanilla kernel, and the configuration will depend on your application.

The value of this guide is fairly small, since you wouldn't typically use an RT kernel on a desktop, but on a dedicate server or embedded system. I'm still working on a cross-compiling guide for non-x86 architectures.

In addition, having an RT kernel is only the first step -- it needs to be used in the correct way to allow for prioritising processes/pre-emptive execution in an efficient way. An overview for a particular application is given here: http://wiki.linuxmusicians.com/doku.php?id=system_configuration

Briefly,
sudo apt-get install kernel-package fakeroot
wget http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.2.9.tar.bz2
wget http://kernel.org/pub/linux/kernel/projects/rt/3.2/patches-3.2.9-rt17.tar.bz2
tar -xvf linux-3.2.9.tar.bz2
cd linux-3.2.9/
bzcat ../patches-3.2.9-rt17.tar.bz2 |patch -p1
cat /boot/config-`uname -r` .config
make oldconfig

You get to answer a number of questions relating to real-time OS execution

  1. No Forced Preemption (Server) (PREEMPT_NONE)
> 2. Voluntary Kernel Preemption (Desktop) (PREEMPT_VOLUNTARY)
  3. Preemptible Kernel (Low-Latency Desktop) (PREEMPT__LL) (NEW)
  4. Preemptible Kernel (Basic RT) (PREEMPT_RTB) (NEW)
  5. Fully Preemptible Kernel (RT) (PREEMPT_RT_FULL) (NEW)
choice[1-5]: 4
[..]
 Testing module to detect hardware-induced latencies (HWLAT_DETECTOR) [M/n/y/?] (NEW)
[..]

Launch the build process
fakeroot make-kpkg -j7 --initrd --revision=3.2.9 --append-to-version=rt kernel_image kernel_headers 

where 7 is the number of cpu cores+1.

The deb-packages will be found in the folder above linux-3.2.9/ and can be installed using sudo pkg -i
.


97. Wine 1.4 out now -- very brief build instructions

UPDATE 16 May 2013: See here for Wine 1.5.30: http://verahill.blogspot.com.au/2013/05/416-wine-1530-in-chroot.html

UPDATE (10th Jan 2013): See here for Wine 1.5.21 using the multiarch approach in Debian Testing/Wheezy: http://verahill.blogspot.com.au/2013/01/308-compiling-wine-1521-on-debian.html

Updated list of dependencies for debian stable/squeeze: http://verahill.blogspot.com.au/2012/11/compiling-wine-155-from-source-using.html


The instructions are identical to those for wine1.4 rc4 and 5: http://verahill.blogspot.com.au/2012/02/debian-testing-wheezy-64-compiling-wine.html and wine 1.3.35: http://verahill.blogspot.com.au/2012/01/debian-testingwheezy-64-bit-installing.html

I've tested the build on 8 March 2012.

-- START HERE --
sudo apt-get install bison flex gcc libc6-dev libfontconfig-dev libfreetype6-dev libglu-dev libgsm1-dev libice-dev libjpeg-dev libldap-dev libmpg123-dev libncurses5-dev libopenal-dev libpng-dev libsm-dev libssl-dev libusb-dev libx11-dev libxcomposite-dev libxcursor-dev libxext-dev libxi-dev libxinerama-dev libxml2-dev libxrandr-dev libxrender-dev libxslt-dev libxt-dev libxxf86vm-dev make libcapi20-dev liblcms-dev libsane-dev libhal-dev libdbus-1-dev valgrind prelink libcups2-dev opencl-dev lib32opencl1 oss4-dev gettext lib32v4l-dev lib32ncurses5-dev lib32asound2-dev lib32z-dev ia32-libs-dev
mkdir ~/tmp
cd tmp/
wget http://prdownloads.sourceforge.net/wine/wine-1.4.tar.bz2
tar -xvf wine-1.4.tar.bz2
./configure

configure: gstreamer-0.10 base plugins 32-bit development files not found, gstreamer support disabled
configure: libgsm 32-bit development files not found, gsm 06.10 codec won't be supported.
configure: libtiff 32-bit development files not found, TIFF won't be supported.
configure: WARNING: libjpeg 32-bit development files not found, JPEG won't be supported.
configure: Finished.  Do 'make' to compile Wine.
The warnings about lack of support can safely be ignored if you don't need it. The TIFF error seems a bit random since it appears on some of my systems, but not others. I haven't figured out the responsible package yet.

make
sudo checkinstall --install=no
to build 23Mb deb package without installing it
 OR 
sudo make install
to install without building a package.


Note:
JPEG support is supposedly available if you
1. remove symlinks
sudo rm /usr/lib32/libjpeg.so.62 /usr/lib32/libjpeg.so.62.0.0
2. Then, create new ones
sudo ln -s /usr/lib32/libjpeg.so.8 /usr/lib32/libjpeg.so.62
sudo ln -s /usr/lib32/libjpeg.so.8 /usr/lib32/libjpeg.so.62.0.0




Edit:
I didn't know it before, but there's a slightly different, wine-specific, way of building described here http://chrisjrob.com/2012/03/08/wine-1-4-on-debian-wheezy/

To see you wine version do
winecfg
This is from a newer build - 1.5.6



Links to this page:
http://chrisjrob.com/2012/03/08/wine-1-4-on-debian-wheezy
http://forums.linuxmint.com/viewtopic.php?p=535245
http://debian.linux.pl/threads/26515-Instalacja-wine-1-4-w-Debianie-Squeeze

07 March 2012

96. Optimising, trimming and making your solid state drive last longer on linux

There's an excellent and informative guide here:
http://apcmag.com/how-to-maximise-ssd-performance-with-linux.htm

Please read it. I've tried it on my SSD and it didn't crash my system. In fact, it even seems snappier, but that might be subjective.

While the guide above talks about making Solid State Drives (SSD) last longer and work faster, it equally applies to other solid state media such as USB sticks.

Here we'll apply that guide to a USB stick with debian we installed as shown in this guide: http://verahill.blogspot.com.au/2012/02/installing-debian-on-usb-stick-live-usb.html

--START HERE --
Mount your USB stick as you would any other -- the wonderful things about *NIX is that all configuration options are set in files which you can easily edit.

/etc/fstab
Before editing, it looks like this

proc            /proc           proc    defaults        0       0
UUID=8c0c9c98-e73f-4f5a-b7d7-f91f95c9d8ca /               ext4    errors=remount-ro 0       1
UUID=e3305fbe-8e4e-4d0e-9975-0db692f87d32 none            swap    sw              0       0
/dev/scd0       /media/cdrom0   udf,iso9660 user,noauto     0       0
We'll edit to

  • enable TRIM by adding discard.
    From the manual: "discard/nodiscard - Controls  whether  ext4  should issue discard/TRIM commands to the underlying block device when blocks are freed.  This is useful for SSD devices and sparse/thinly-provisioned LUNs, but it is off by default until sufficient testing has been done."
  • noatime.
    From the man: "Do not update inode access times on this filesystem (e.g., for faster access on the news spool to speed up news servers)."
  • nodiratime
    Same as noatime, for directories
  • move some temporary /var files to the RAM instead of disk
  • the last line puts all log files (/var/log/) in RAM as well. If you do want logs to persist between boots, comment it out
  • 1777 = chmod +trwx, 0755= u+rwx g+rw o+rw
  • I've kept the swap since I might want to use my stick on underpowered machines, but you really probably shouldn't
  • A good source of information on mount options is here: http://www.tuxfiles.org/linuxhelp/fstab.html


proc            /proc           proc    defaults        0       0
UUID=8c0c9c98-e73f-4f5a-b7d7-f91f95c9d8ca /               ext4 noatime,nodiratime,discard,errors=remount-ro 0       1
UUID=e3305fbe-8e4e-4d0e-9975-0db692f87d32 none            swap    sw              0       0
/dev/scd0       /media/cdrom0   udf,iso9660 user,noauto     0       0
tmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0
tmpfs /var/spool tmpfs defaults,noatme,mode=1777 0 0
tmpfs /var/tmp tmpfs defaults,noatime,mode=1777 0 0
tmpfs /var/log tmpfs defaults,noatime,mode=0755 0 0

/etc/default/grub 
To set a system-wide scheduler policy for disk I/O we can edit grub and define elevator as noop, deadline or anticipatory.

Change e.g.
GRUB_CMDLINE_LINUX_DEFAULT="text splash"
to
GRUB_CMDLINE_LINUX_DEFAULT="text splash elevator=deadline"
If you want to know more about schedulers, you can look here: http://www.cyberciti.biz/faq/linux-change-io-scheduler-for-harddisk/


We need to do update grub, and that's a bit trickier, but still not too difficult.
My USB stick is mount at /media/8c0c9c98-e73f-4f5a-b7d7-f91f95c9d8ca/


sudo mount -o bind /dev 8c0c9c98-e73f-4f5a-b7d7-f91f95c9d8ca/dev/
sudo mount -o bind /sys 8c0c9c98-e73f-4f5a-b7d7-f91f95c9d8ca/sys/
sudo mount -o bind /proc 8c0c9c98-e73f-4f5a-b7d7-f91f95c9d8ca/proc/
sudo chroot 8c0c9c98-e73f-4f5a-b7d7-f91f95c9d8ca/
root@beryllium:/# update-grub
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-3.2.0-1-686-pae
Found initrd image: /boot/initrd.img-3.2.0-1-686-pae
Found linux image: /boot/vmlinuz-2.6.32-5-686
Found initrd image: /boot/initrd.img-2.6.32-5-686
grep: input file `/boot/grub/grub.cfg.new' is also the output
done

And exit the chroot jail (type exit)


/etc/rc.local
Add a line to the end
echo 0>/proc/sys/vm/swappiness
to prevent use of swap until the RAM is full.

You're now done.


For an SSD drive you can just boot into your system and make the changes as above, but without fiddling with mounting /dev, /sys, /proc and doing chroot.