TypeMatrix 2030

I was looking to replace my really bad logitech keyboard and at the same time make the switch to the Bepo layout (a french and free ergonomic keyboard layout similar to Dvorak). We have long sought after a quality keyboard like the classic ThinkPad keyboard and avoid the many badly designed toys we found on the market. Macish like keyboards with their flat smooth keys and soft press were right out. I really hate these even if everyone seems to swear only by them nowadays.

So we ordered three TypeMatrix keyboards one month ago and we just received them this week. One of the distinguishing feature of this keyboard is that it doesn’t conform with the classical staggered layout remaining unchanged from the typewriter era and use a vertical columns layout instead which reduces motions. It also comes with a optional switchable skins with different layouts (qwerty, azerty, dvorak, bepo). These not only makes the layout switching easier but also makes the keyboard waterproof and dirt-free. The keyboard itself requires no drivers though you may want to add the following to /etc/X11/xorg.d/typematrix.conf to setup the default layout :

Section "InputClass"
Identifier "Typematrix"
MatchIsKeyboard "on"
MatchVendor "TypeMatrix.com"
MatchProduct "USB Keyboard"
Driver "evdev"
Option "XkbRules" "xorg"
Option "XkbModel" "pc105"
Option "XkbLayout" "fr"
Option "XkbVariant" "bepo"
Option "XkbOptions" ""
EndSection

Howto save a lot of disk space on nokia N810

The Nokia N810 is an internet tablet (not a phone though it can communicate with cellular phone via bluetooth). It’s a nice small device which run the Maemo Distribution which seems to be based on Debian since it uses the Debian Package Manager. But the distribution’s structure really feels like an embedded device and this is quite annoying when you try to optimize this device.
One thing which is really boring is the lack of disk space on the device. Actually the device use two miniSD (MMC) cards for personnal documents, images, videos and so on and a 256MB MTD using a JFFS2 compressed file system to store the whole distribution which means every package and their data files which takes a large amount of disk space and even so much that the MTD can easily be completely filled with a few apps.
The basic idea to save some disk space is to move some part of the MTD on the MMC primarely reformated from vfat to ext2. Many articles explain how to move stuff like /var/cache and others using symlinks which can save you about 20MB. But they also explain that you can’t do that with /usr/share/ for example since it will break the boot process. Indeed the boot process depends on many stuff located in /usr/share and thus if the MMC are not mounted while boot occurs the system will just stall waiting for an hard reset to get everything right and clean again. Here comes a way to go around this :

As root we check the run level :

Nokia-N810-43-7:~# runlevel
N 2

We see we are in runlevel 2. Let’s check how the boot process arranges itself in that runlevel :

Nokia-N810-43-7:~# ls /etc/rc2.d
K00zzinitdone
S12fb-progress.sh
S20dbus
S20hal
S20osso-applet-display
S21mce
(…)

It looks like fb-progress.sh is the first script executed in the boot process. So we edit this script (/etc/init.d/fb-progress.sh) and add the following line at the beginning of the script (line 19 or so):

/usr/sbin/osso-mmc-mount.sh /dev/mmcblk0p1 /media/mmc2
/usr/sbin/osso-mmc-mount.sh /dev/mmcblk1p1 /media/mmc1

So we know that MMC will be mounted at first in the boot process. After that scripts which need share stuff or other may look on the MMC since we know they were already mounted. Then we move things like /usr/share on the MMC :

Nokia-N810-43-7:~# mkdir /media/mmc1/.usr
Nokia-N810-43-7:~# cp -aR /usr/share /media/mmc1/.usr
Nokia-N810-43-7:~# rm -rf /usr/share
Nokia-N810-43-7:~# ln -s /media/mmc1/.usr/share /usr/share

Of course the same could be done for other directory. Here is the list of directory that I switched from MTD to MMC without breaking the boot process :

  • /var/backups
  • /var/cache
  • /usr/local
  • /usr/share
  • /usr/bin
  • /usr/games
  • /usr/lib
  • /home/user

The df entry for the MTD follow :

Filesystem Size Used Available Use% Mounted on
/dev/mtdblock4 249.5M 16.8M 232.7M 7% /

And it almost never grow when apps are installed.

Ext4 on root filesystem

Since a few days the last version of squeeze’s debian installer (which runs sid I think) is able to install on an ext4 filesystem. Which means that the ext4 filesystem could now easily be used as root filesystem.
When the installation is completed a problem might appear at the first boot. The kernel will simply panic complaining that he cannot mount the root filesystem. Actually the squeeze’s default kernel is currently 2.6.26 and this version does not fully support ext4.
The quick fix is to use the rescue part of the debian installer which will chroot you in your root partition and let you temporarily change your apt’s sources from squeeze to unstable so that you can install the last unstable kernel (>= 2.6.28) wich is ext4 capable.
If you try to install with the stable debian installer or any GNU/Linux distribution which is not ext4 capable here is a trick to use ext4 as your root filesystem.
First install your system with an ext3 filesystem and let /dev/sda1 be that partition. Then install grub2 and make sure it works perfectly. Then boot on a live system which is ext4 capable, backup all files so you can create an ext4 filesystem on /dev/sda1, put your backup back in it. Then change fstab in /dev/sda1 and replace ext3 with ext4 for the root filesystem. Check that grub.cfg in /dev/sda1 doesn’t use UUID to pass the root parameter to the kernel (actually they’ll change since you made a new filesystem) and use root=/dev/sda1 instead. Now reboot and your system should be running ext4 on the root filesystem.

GNU Flash Movie Player

Do you want flash for free ? I mean really free ? Try Gnash the GNU Flash Movie Player which can be run as a plugin from within Firefox (or Iceweasel).
Actually Gnash is SWF v7+ compliant which means it can play video, music and many website which randomly use it.
What more is it can be easily installed on x86_64 (64bits) and it is absolutly free software (GPL).

Watch your inodes !

Today I got a strange bug doing apt-get update which gave me 404 error for each repository. At first I though it was the apt package which ran out-of-date but when I tried to install it manually dpkg said something like : “No space left on device”. Trying to touch something achieved the same result. So I did :

# df -h /var

But it said that about 1GB were available on that filesystem. Then :

# tune2fs -l /dev/sda11 | grep “Free”
Free blocks: 276171
Free inodes: 0

There were no inodes availables on the filesystem. I always though that filesystem have enough inodes in it so we don’t have to care about that but actually squid created many small files, worrying about blocks usage but not about inodes usage. I got it fixed by deleting the squid’s cache directory and setting squid.conf to use less top-level and sub-level directories.

About ext4

The ext4 is a journaled file-system, the successor to ext3. In summary the ext4fs greatly improve overall performance, efficiently reduce fragmentation and is fscked much more faster than his predecessor. Actually it has many features which follow :

  • Large file system with now 16TB files and up to 1EB volume size.
  • Extents which reduce fragmentation and improve large file performance.
  • Compatibility with ext2 and ext3.
  • Preallocation.
  • Delayed allocation which improve block allocation decisions.
  • Break 32 000 subdirectory limit with now 64 000 and improved performance using htree by default.
  • Journal checksumming which improve reliability.
  • Online defragmentation (didn’t try yet).
  • Multiblock allocator which reduce fragmentation.
  • More precise timestamp and fix the 2038 bug.

If you want to create an ext4 file-system first get the linux kernel (>= 2.6.28) which contains the first stable version of the filesystem. Then enable CONFIG_EXT4_FS as module or built-in. If you want to try the large files and volume feature add CONFIG_LBD actually I didn’t try it since the largest I’ve got here is about 2TB so in what follows I’ll assume you won’t enable this feature. Then install e2fsprogs (>= 1.41) and check in /etc/mke2fs.conf for a line looking like this :

ext4 = {
features = has_journal, extents, huge_file, flex_bg, uninit_bg, dir_nlink, extra_isize
inode_size = 256
}

Checks the features and inode size (should be at least 256) and remove the huge_file feature since we won’t use it. Now reboot on your new kernel, create the partition with fdisk or any other tools and let /dev/sdb2 be that partition. Just do as root :

# mkfs.ext4 -I 256 -m 0 -L HOME /dev/sdb2

This will create an ext4fs on /dev/sdb2 with 0% of reserved blocks for root labelled as HOME (always label your file-systems it makes it easier to manage your partitions) and enable every features found in /etc/mke2fs.conf on it. Give it a try and mount it on /mnt try putting some file on it :

# mount -t ext4 /dev/sdb2 /mnt

Now in order to transfer your files to the newly created file-system just do :

# mount -t ext4 /dev/sdb2 /mnt && cp -aRv /home/* /mnt/ && rm -rf /home/* && umount /mnt && mount -t ext4 /dev/sdb2 /home

Your home directories should now be mounted on the new ext4 file-system. Be sure you didn’t misstyped the last command since it will delete files on the old file-system. Then just add a line for it in /etc/fstab in order to mount it automatically on each boot :

/dev/sdb2 /home ext4 noatime 0 2

Now your home directory will be mounted automatically. Repeat that step for each partition and it’s done.

The ext4 file-system is not shown in the squeeze’s debian installer so there are three solutions to take advantages of ext4 on the current stable :

  1. Using an ext3 partition and then mount it as ext4 using backward compatibility. I don’t use it since I heard that some features won’t be enabled that way especially the extents feature won’t if the inode size of the ext3 file-system is not at least 256.
  2. Using multiple ext4 partitions on top of an ext3 root instead of a single partition. This is the simplest solution which I’m using on my laptop right now.
  3. Tweaking the debian installer to install the system on a manually created ext4 file-system. This is the most boring solution since if it fails somewhere you have to restart the installation process from the beginning.

I’ll just describe briefly the second solution here since I don’t like the first one neither do I remember every step of the third one. When installing debian create two partition one for /boot (~200MB) and another for the root, I mean “/” (~1GB) flagged for use as ext3 or reiserfs (actually I’m using reiserfs). Then install only the base-system. Rebuild a new kernel with ext4 enabled in it, create partitions for /var, /usr, /tmp, /home and transfer documents as described above. Now continue the installation using aptitude and that’s it.