Tuesday, 9 November 2010

Building and using a Linux initramfs

If your kernel needs to do 'stuff' during boot up or load modules that aren't compiled into it then an initramfs provides a way (initramfs supersedes the old initrd approach). Basically it is a file (cpio and gzipped) that contains a directory hierarchy containing all the necessary items to provide for loading of modules etc.

To enable the use of the initramfs you'll need to enable the relevant kernel option (e.g. General Setup --> Initial RAM filesystem and RAM disk (initramfs/initrd) support) and them supply the appropriate boot arguments to your boot loader (e.g. append initrd=my-initrd .....). At the very beginning of boot up you should see [on the console] the initrd being loaded (Loading initrd................), then further down it executes the ./init script within the initrd.

To build an initramfs from a suitably populated directory:
find . -print0 | cpio --null -ov --format=newc | gzip -9 > ../my-initrd
To check the contents of an initramfs:
gunzip -c my-initrd | cpio -t
To extract the contents of an initramfs into the current directory (you might want to create a temporary directory to unpack it into mkdir initrd.d ; cd initrd.d):
gunzip -c ../my-initrd | cpio -i -d -H newc --no-absolute-filenames

If you've been trying to use an initramfs and you're getting this error on boot up:
Failed to execute /init
Kernel panic - not syncing: No init found.  Try passing init= option to kernel.
Then maybe your ramfs image doesn't contain init, or it's not executable, or you're trying to use a shell within init that incompatible with your kernel's architecture (e.g. trying to use an amd64 arch shell with an i686 kernel).

There's a good Gentoo guide on building them.

On Ubuntu/debian there's a command to build an initrd called mkinitramfs. When running mkinitramfs whilst you can use an alternative config directory, it can only obtain kernel modules from /lib/modules/<kernel_version>. So you can run it using chroot, though its only a shell script so it can of course be tweaked....

Friday, 29 October 2010

Firefox sync is useless for bookmarks - doesn't sync subfolders

I've been [blindly] using Mozilla's Firefox Sync (aka Weave) plugin (v1.5) thinking it was such a great thing (apart from the lengthy freezes whilst it was 'syncing')...Only to realise that it does NOT sync my Bookmark's subfolders/subdirectories (folders below the main directory) - which makes it effectively useless! Unless your bookmarks are flat then it's total a waste of time.

What a dumb plugin??! I expect more from Mozilla. Go click here for my bug report and click on 'I have this problem too'.

Anyone got any better suggestions....

Wednesday, 6 October 2010

Enabling X/X11 tunnelling/forwarding on OSX

It seems that X11 forwarding is not enabled as default on OSX so if you connect to machine using ssh and then try to run an X command (e.g. /usr/X11R6/xterm) it fails with: "unable to open display"

To enable X11 forwarding on your_osx_host machine edit /etc/sshd_config e.g.
sudo vi /etc/sshd_config
And add the following line:
X11Forwarding yes
Then restart the sshd service:
sudo launchctl stop com.openssh.sshd
sudo launchctl start com.openssh.sshd 
or
sudo service ssh restart

Then from your remote machine logout and log back in and you should be able to use forwarded X11 apps - you may need to enable [trusted] X11 forwarding on your client as well e.g:
ssh -XY your_osx_host

Friday, 6 August 2010

How to convert .ipcc file to .bundle

So you've got an .ipcc file and you want to unpack the .bundle directory - well it's just a zip file (like a few other things e.g. .jar files). So just run unzip:
$ unzip random.ipcc
You can find a list of them from http://phobos.apple.com/version - go to that page and sift through the XML till you find the one you need and copy the link and paste it into your browser to download it (or use wget or curl to get it).

Wednesday, 28 July 2010

Where OSX are kernel modules located?

The OSX uses loadable kernel (like BSD and Linux) modules (or kexts) - each one is stored in its own directory (e.g. Dont Steal Mac OS X.kext ) and these are mostly stored in a couple of directories:
/Library/Extensions
/System/Library/Extensions/
Though some others are stored in some other directories (e.g.  /Library/StartupItems/). You can list the currently loaded kernel modules using the kextstat command.

There also some info more info another post of mine on tracking down problem kernel modules in osx.

Friday, 16 July 2010

Ubuntu 10.04 USB Mouse keyboard problems - fixed

After the problems I had after 9.10 upgrade I held off on upgrading to Ubuntu's latest 10.04 (Lucid something-or-other), with kernel 2.6.32-21. Sadly it was another disaster - after upgrade neither my mouse nor keyboard worked beyond the Grub screen.

I looked into it; initially I thought it was an X thing with their new nouveau Nvidia driver but it wasn't that. I then noticed that the devices weren't actually being seen by the system on the USB bus - i.e. when I ran lsusb I only saw a couple of USB hubs (no mouse or keyboard listed) where normally I saw about 6 USB devices - yes they were plugged in and were recognised fine by an older kernel (9.10). I messed about with usbhid kernel module to no avail. I then tried 10.04 live CD and it worked ok with exact same USB setup?! I dumped the output from dmesg and then compared it with dmesg from my machine running the installed version on the exact same kernel version. It seemed that my installed version was failing to recognise the actual PCI USB host controllers on bootup - WTF?! It seems that the ehci-hcd module was not finding the USB hardware.... Smells like a kernel bug.

Finally I tried altering various boot args for the kernel in /boot/grub/menu.lst which didn't work initially, but then I hit upon the right one: pci=noacpi. It now works though my fans seem to be going full speed at all times...

[updated: 21aug10] Unfortunately after the kernel latest update (2.6.32-24) it seems to be totally broken and my fix doesn't work so I've had to revert to using 2.6.32-21 - If you run any DKMS modules (e.g. nvidia) you'll need to have the kernel header files installed that kernel.

Another BIG waste of time....I really am having my doubts about Ubuntu.

Thursday, 1 July 2010

Don't bother: iOS4 on iphone 3G

Yeah the move to iOS4 has not been good:
1) The install process sucked; The 'backup' stage of the upgrade took forever - so instead I ended up using the 'restore' function from iTunes (once I'd got iOS4 downloaded in iTune 9.2). It still took HOURS.
2) The number new features on the 3G is hardly worth it (Folders, Spell checker, Threaded mail,...)
3) It seems less stable and slower than iOS 3.2.x - have to reboot it more
4) A number of my apps crash ALOT like MobileRSS, OffMaps - not handy. (though I guess they probably need to be updated...)
5) Quite a few Apps aren't iOS4 ready - e.g. Skype

Maybe 4.x will help but who knows when that's due......

[5nov10]: 4.1 definitely improves things (and the relevant apps have mostly been updated)