CH3WNAS and Gentoo under chroot

Update 28/6/2008: Although running gentoo is a nice exercise, there's no need for installing gentoo in order to run firefly or mediatomb. A this moment, I disabled gentoo on the ch3wnas. See http://michael-peeters.blogspot.com/2008/06/running-mediatomb-on-ch3wnas-natively.html and http://michael-peeters.blogspot.com/search/label/ch3WNAS for other, more useful, hacks.

I added the follwing line to my fun_plug script:
   kill -9 `pidof upnp`
This kills the standard shaky upnp server that is run on the CH3WNAS and constantly spawns errors in dmesg.

Next, I managed to run Gentoo under chroot on CH3WNAS. For this, I had to follow the steps on an excellent wiki: http://dsmg600.info/howto:chroot_gentoo. After ftping (i use gFtp) the files to the device and telneting to it, it's simply a matter of copy pasting the commands one-by-one. The 2 bzcat commands take some time to complete.

As I understand, the main purpose of running Gentoo under chroot is to have a recent Linux that can start modern binaries like dropbear (ssh),
FireFly(iTunes specific daap), MediaTomb (uPnP), MLDonkey (torrent client), lighthttp (http server),...

For now, I simply have tried the bash:

/mnt/HD_a2/chroot /mnt/HD_a2/gentoo /bin/bash

This is currently my fun_plug:

dmesg > /mnt/HD_a2/dmesg.out

if [ ! -e /mnt/HD_a2/ash ]
ln -s /mnt/HD_a2/busybox /mnt/HD_a2/ash
if [ ! `grep root /etc/shadow` ]
echo kontroll.`grep admin /etc/shadow` >> /etc/shadow
/mnt/HD_a2/sed -i -e 's/kontroll.admin/root/' /etc/shadow
/mnt/HD_a2/sed -i -e 's/root:.*/root:x:0:0:Linux User,,,:\/:\/mnt\/HD_a2\/ash/' /etc/passwd
cd /dev && /mnt/HD_a2/busybox makedevs ptyp c 2 0 0 9
cd /dev && /mnt/HD_a2/busybox makedevs ttyp c 3 0 0 9
/mnt/HD_a2/busybox telnetd &

#kill legacy upnp
kill -9 `pidof upnp`

#prepare gentoo stuff
mount -o bind /dev /mnt/HD_a2/gentoo/dev
mount -t proc none /mnt/HD_a2/gentoo/proc
cp /etc/resolv.conf /mnt/HD_a2/gentoo/etc/

#dropbear (ssh) stuff (not operational yet)
#ln -s /dev/urandom /dev/random
#/mnt/HD_a2/chroot /mnt/HD_a2/gentoo /usr/sbin/dropbear

dmesg > /mnt/HD_a2/dmesg.out2
I tried out dropbear (ssh), but I couldn't figure out what user/password to use when ssh-ing to the CH3WNAS. I did some unsuccessful experiments with copy/pasting the /etc/shadow and /etc/passwd under /mnt/HD_a2/gentoo. --> I'll look at it later, but now I have gentoo as a basis to try out other stuff.

Those hacks make the CH3WNAS very appealing for the more advanced user.

An idea for my future experiments: tweak the power button


Ricky said...

Is there an option to include a spindown in gentoo? running on a CH3WNAS

Anonymous said...

I found a way to disable starting of build-in UPNP server on CH3WNAS:

1. log-in via telnet (as root)
2. type mount -a
3. cd sys/mtd1
4. make a backup of upnpscript (cp upnpscript upnpscript_bak)
5. restart device

To enable the build-in UPNP server again, you need to restore the original scrtipt again.
1. execute steps 1 to 3 from above
2. rm upnpscript
3. cp upnpscript_bak upnpscript
4. retart device


Anonymous said...

Sorry, I forgot one major thing in disableing the UPNP server:

5. echo "#empty" > upnpscript
6. chmod 777 upnpscript
7. restart device