Saturday, September 18, 2010

Duh Zombies?! - Rise of the zombie tomatoes

Recently when I logged in to my Tomato-powered Linksys WRT54GL via SSH I was quite disturbed when top showed quite a lot of zombie processes like this (I excluded the other normal processes):

19082 root 0 Z [cp]
19084 root 0 Z [cp]
19087 root 0 Z [cp]
19090 root 0 Z [cp]
19092 root 0 Z [cp]
19100 root 0 Z [cp]
19103 root 0 Z [cp]
19105 root 0 Z [cp]
19107 root 0 Z [cp]
25903 root 0 Z [cp]
26035 root 0 Z [cp]

I wonder where they come from. A little bit of guessing by the process ID and comparing these with the numbers from the log from other processes allowed me to narrow down the time when they „spawned“. This is based on the assumption that Linux assigns process IDs ascendingly (until it hits the max number then it should start at the bottom again). The log shows no other irregularities, though connection logging for example is disabled.

The brackets around cp probably mean that these were kernel services, though this is just a guess. Other than that the router is behaving like normal. When searching the internet I also found out that it's not possible to get rid of zombies in any way other than a reboot. Guess they will stay there for a while, however I will closely monitor the situation.

Friday, September 17, 2010

Grub setup for multiple OSes in a neat way

Armed with a grub CD I proceeded with the Windows 7 installation. First I made a backup of the Vista partition just in case, then I formatted it and installed Windows 7. The Windows 7 installation created a Boot directory on my WinXP partition along with bootmgr, the Vista/7 boot manager. The installation also added a note to boot.ini that this is the WinXP boot configuration. If you install Windows Vista/7 on a new harddrive, this stuff will be put onto a hidden partition.

Quote:
;
;Warning: Boot.ini is used on Windows XP and earlier operating systems.
;Warning: Use BCDEDIT.exe to modify Windows Vista boot options.
;

Of course it also updated the MBR to point to the new boot manager.

In order to set things up like I wanted, I first copied the Boot directory and bootmgr to my Win7 partition. Then I booted into Win7 and used bootsect (a tool located on the Win7 install DVD in the boot folder) to write a Windows 7 boot record to the Win7 partition and a WinXP boot record including ntldr to the WinXP partition.

Commands used (I first moved to the directory where bootsect resides):
bootsect /nt60 C: (NT 6.0 boot record for Win7 partition)
bootsect /nt52 D: (NT 5.2 boot record for XP partition)

Then I booted to Ubuntu Linux using the Grub Boot CD to setup Grub again. I used the below-mentioned commands.

From the standard Ubuntu terminal:
sudo grub

Commands for the grub CLI:
find /boot/grub/stage1 //returns where grub is actually installed
root (hd0,0) //type here whatever find returned
setup (hd0) //this installs grub into the MBR, if you want to put it into a specific partition use the (hd0,x) syntax to specify a partition
quit


Finally I cleaned up the boot.ini file using a simple text editor and removed unnecessary options from the Windows 7 boot manager (basically to make it boot instantly once selected from Grub) using bcdedit.

From the Windows 7 CLI (with admin rights):
bcdedit /v //this command displays a list of entries, basically needed to get the ID of the legacy entry
bcdedit /delete {ID} /f //substitute ID with the ID obtained from the previous command

I also removed bootmgr and the Boot directory from the Windows XP partition. In order to accomplish this you need to first claim ownership of the files and then set the priviledges for your user / group to be allowed to delete them.

The end result is a clean boot setup with grub as the main boot manager, which is used to boot Ubuntu Linux, Windows XP and Windows 7 without nested selection screens. The great thing about this setup is, that it is scalable, supporting an virtually arbitrary number of boot options without interfering with each other.

Note that the order in which the different operating systems are installed is largely unimportant as long as one knows where lies what and how to restore overwritten boot configuration or work around that using a prepared boot manager CD (it's also possible to put one on a separate hard drive or even USB drive).