The Linux Kernel has a new feature called zram that allows RAM to be compressed. This could help out on the Zipit since it only has 32M. Back in September Wejp built a kernel with zram and a new Arch rootfs. I figured I’d try to get it going on OpenWrt and have succeed. I used anarsoul’s 3.6 tree but also had to add a patch that allows LZMA compression on JFFS2 filesystems so it can be used with slug’s in flash rootfs. This is a rough guide on how to get it working. At some point I would like to get the updated kernel into the OpenWrt-Zipit tree.
I have tested wireless with Slug’s rootfs and the new kernel which works as expected. The gmenu2x wifi scripts work the same as with the old 3.2 kernel. Also, I tested iwconfig and iwlist which both work.
Download the kernel and modules (with or without B.A.T.M.A.N.): openwrt_z2_3.6.0+_20121223.tar.bz2 (md5sum f3d65ba14663efd321fff3543b2daf59) openwrt_z2_3.6.0+_batman_20121223.tar.bz2 (md5sum 44f153debdea2120875e3d07e3c8068f)
Get an SD Card loaded with Slug’s gmenu2x rootfs and rename his kernel: cd /path/to/sd/ mv boot/uImage boot/uImage-3.2.0
Extract the new kernel to the SD Card: tar -xvf /path/to/newkernel.tar.bz2
Boot the Zipit with the SD card in, then load a shell.
Mount the in flash jffs2 partition: mkdir /mnt/mtdblock3 mount -t jffs2 /dev/mtdblock3 /mnt/mtdblock3
Remove the old 3.2 kernel modules and copy over the new ones: rm -rf /mnt/mtdblock3/lib/modules/3.2.0 cp -R /lib/modules/3.6.0+ /mnt/mtdblock3/lib/modules/
Copy the kernel into flash: dd if=/boot/uImage of=/dev/mtdblock2
Use the ‘poweroff’ command to turn off the Zipit and then remove the sd card.
Power on the Zipit and press a key immediately to get the uboot prompt. We need to add an init option to the uboot arguments with the following commands: setenv bootargs “$bootargs init=/etc/preinit” saveenv boot
Now the Zipit should boot into your exisiting rootfs with the new 3.6.0 kernel. To get zram working as swap space we need to get the modules loaded and define how much to use for swap. We can set everything up to load automatically at boot.
Add the following to /etc/modules.d/05-zram: zsmalloc zram
Next, create a symlink to that file so it loads at boot: ln -s /etc/modules.d/05-zram /etc/modules-boot.d/05-zram
Add the following to /etc/rc.local for a 16M zram swapsize: echo 16000000 >/sys/block/zram0/disksize mkswap /dev/zram0 swapon /dev/zram0
Reboot the Zipit and zram should be enabled automatically at boot. Open a shell and type ‘free’ to verify the 16M swap space.