Author Topic: Getting all the applications (rtorrent, etc.) -- chrooted Debian Lenny  (Read 33014 times)

November 24, 2009, 10:48:47 AM
Read 33014 times

Bob

  • Newbie

  • Offline
  • *

  • 21
Hi,

so finally I got the debootstrap working. I bothered long enough to get rtorrent compiled when I tried this. With this installed, you have the full advantages of a Debian Linux. And this means getting all the applications like pure-ftpd, rtorrent, apache and a lot more on your WD TV Live. No optware required at all. However, like always, I'm not responsible for anything ;-) Here are the installation instructions:

Installing a small Debian
==============

Download http://rapidshare.com/files/311638905/wdtvlive-mipsel-debian-lenny.tar.bz2. It's a bootstraped Debian lenny system and was created with debootstrap.

Edit: If you're familiar with debootstrap, there's absolutely no need to download the file. It's just provided for convenience and for people not having a running Linux system at hand.

Copy it over to your WD TV Live to your external storage media (rsync or ftp). It has to be formatted with ext3/ext2. FAT or NTFS will not work. Log in via ssh to your WD TV Live and change into the folder where the tar.bz2 is located. Something like
 
 $ cd /tmp/mnt/<alongstring>/

Unpack it:

 $ tar xvf wdtvlive-mipsel-debian-lenny.tar.bz2

Now you have a folder called debian-lenny. That's actually a very small Debian system with a minimal package selection.

Do:

 $ mv debian-lenny .debian-lenny

This just renames the directory so that the mt-daapd service will not scan it. (causes the mt-daapd to run wild).

This is required to setup networking for the debian system (this has to be done everytime you reboot your WD TV Live):

 $ mount proc .debian-lenny/proc  -t proc
 $ cp /etc/resolv.conf .debian-lenny/etc/
 $ cp /etc/hosts .debian-lenny/

Now we're nearly finished. Change root into the new Debian (this has to be done everytime you reboot your WD TV Live):

 $ chroot .debian-lenny

Now you only see your Debian system when issuing a 'ls /'.

The wdtvlive-mipsel-debian-lenny.tar.bz2 only contained a half-ready system, so we have to finish the bootstrapping process:

 $ ./debootstrap/debootstrap --second-stage

Now the debootstrap program will set up the remaining bits of your Debian installation.

Now do:
 $ echo "deb http://ftp.de.debian.org/debian lenny main" > /etc/apt/sources.list

This will setup the main lenny repository for mipsel.

Now you're ready to install applications:

 $ apt-get update

 (and e.g.: $ apt-get install rtorrent)

That's it.

But finally: Kudos to all the Debian developers!

Setting up a convenient working environment with screen
==================================

It's annoying to loose your current status when logging out of the WD TV Live. So screen comes very handy. Download http://rapidshare.com/files/311656483/screen-0.1.app.bin and put it on the root filesystem of your /dev/sda1. On the next reboot of the WD TV Live, you should have an /apps/screen-0.1/bin/screen to execute. Refer to the /apps/screen/README on how to run it. For further information, please have a look at the screen documentation (it's worth it, really).

Now you can start one single screen on your WD TV Live box. Inside your screen. You can be chrooted into the debian lenny system (see above). From now on, whenever you log into your WD TV Live, you just issue /apps/screen/bin/screen -r and you're there where you left last time. Inside the Debian. And you never ever have to leave again :-)


I actually wrote this down a lot too fast to be able to play around with my new accomplishment, so drop any questions.
« Last Edit: November 24, 2009, 02:40:33 PM by Bob »

November 24, 2009, 01:17:20 PM
Reply #1

sandman

  • Newbie

  • Offline
  • *

  • 12
Notes:

Unpacking will not work with fat filesystem. Things to do before coping wdtvlive-mipsel-debian-lenny.tar.bz2:

Code: [Select]

cd /
umount -f /dev/sda1
mkfs.ext3 /dev/sda1


Then remove and reattach you usb key.

PS! USB will not appear in osd anymore (maybe use another fs or multible partitions?)!

Otherwise great job! Long waited finally at hand. Will update mirrors asap.
« Last Edit: November 25, 2009, 01:14:10 AM by sandman »

November 24, 2009, 02:18:46 PM
Reply #2

Wevie

  • Newbie

  • Offline
  • *

  • 9
I get the following error;

# chroot debian-lenny/
chroot: cannot execute /bin/sh: No such file or directory


What to do?

November 24, 2009, 02:22:20 PM
Reply #3

Bob

  • Newbie

  • Offline
  • *

  • 21
Notes:

Unpacking will not work with fat filesystem. Things to do before coping wdtvlive-mipsel-debian-lenny.tar.bz2:

Thanks for the pointer. I added a note to the tutorial.

PS! USB will not appear in osd anymore (maybe use another fs or multible partitions?)!

Hm, USB shows up here, however, I cannot play any media. Now I moved the debian-lenny/ directory from / (of external storage) to /chroot/debian-lenny/, rebooted, followed the steps and now everything seems working ok. Maybe you could tri that for verification?

November 24, 2009, 02:23:27 PM
Reply #4

Bob

  • Newbie

  • Offline
  • *

  • 21
I get the following error;

# chroot debian-lenny/
chroot: cannot execute /bin/sh: No such file or directory


What to do?

What's in your debian-lenny/ directory? Is there a debian-lenny/bin/sh? Did you get any errors beforehand?

November 24, 2009, 02:32:31 PM
Reply #5

zoster

  • Full Member

  • Offline
  • ***

  • 154
Very nice!
Got it working after formating to ext2.
For the other linux noobs beside me here's an article about that rebootstrap / chroot business: link.

And if you're using a second usb device make sure to mount it under the debian-lenny folder before chrooting to it.

PS I got the "cannot execute /bin/sh" error on an NTFS formated usb device. The tar file unpacked without errors.
« Last Edit: November 24, 2009, 02:37:32 PM by zoster »

November 24, 2009, 02:33:42 PM
Reply #6

Bob

  • Newbie

  • Offline
  • *

  • 21
Ok, found something. Porcess mt-daapd is running while because it scans through the external storage but can't copete with the chrooted environments and loops endlessly. It can be solved with not using a "debian-lenny/" directory but a ".debian-lenny/", so mt-daapd skips it. Updating the tutorial...

November 24, 2009, 03:39:34 PM
Reply #7

b-rad.cc

  • Hero Member

  • Offline
  • *****

  • 833
  • Personal Text
    FW Hacker
    • B-RAD
Optware is being worked on atm. The one advantage to Optware is that unlike debian the binaries are compiled with size&speed in mind and not the kitchen sink ;)

Nice work though, makes for a killer development environment.

November 24, 2009, 10:19:57 PM
Reply #8

b-rad.cc

  • Hero Member

  • Offline
  • *****

  • 833
  • Personal Text
    FW Hacker
    • B-RAD
I made something I think you'll like Bob

debian-wdlxtv-live

directly bootable debian :D

This is alpha firmware, ethernet interface up is not working and maybe some other stuff. Will need to hammer out any little particulars. Right now you need to go the root.bin route too, direct filesystem booting is giving me a bit of difficulty. Will be enabling it as soon as I debug.

If you figure out the ethernet issue be sure to contact me with a patch ;D :D

Here is a preliminary root.bin
http://rapidshare.com/files/311874328/1.01.11_B-RAD.CC_DEBIAN_WDLXTV_LIVE-0.2.2.zip
NOTE: it is 256MB, with only 45MB of free space. If you want to get very crazy you'll have to resize it. For info on resizing refer to optware tips #1 on my site.

Thanks to Bob for the inspiration  ;D
« Last Edit: November 24, 2009, 10:43:47 PM by b-rad.cc »

November 25, 2009, 02:35:37 AM
Reply #9

Bob

  • Newbie

  • Offline
  • *

  • 21
I made something I think you'll like Bob

debian-wdlxtv-live

directly bootable debian :D

Wow, if you come to think "that was easy", you don't think about making it even more easy anymore ;-)

Quote
If you figure out the ethernet issue be sure to contact me with a patch ;D :D
Just add the following two lines to /etc/network/interfaces:
 auto eth0
 iface eth0 inet dhcp

And the box comes up with dhcp. At least here ;-)

Quote
Here is a preliminary root.bin
http://rapidshare.com/files/311874328/1.01.11_B-RAD.CC_DEBIAN_WDLXTV_LIVE-0.2.2.zip
NOTE: it is 256MB, with only 45MB of free space. If you want to get very crazy you'll have to resize it. For info on resizing refer to optware tips #1 on my site.
Yes, 45MB is quite less. Installing rtorrent works, but pure-ftpd afterwards doesn't even anymore :) However, the guide provided by you is also quite self explanatory, so that should be fine for everyone.

Oh, and please remember to set the root password to something like wdtvlive when doing the next release ;-)

Thanks,
 Bob (...who still can't believe that this name wasn't already taken ;-))

November 25, 2009, 05:07:23 AM
Reply #10

ProphetVX

  • Newbie

  • Offline
  • *

  • 35
Forgive my naivety here, but does this mean I can download any source packages I want now, compile them under the debian bootstrap, then move them into a folder in the native WDTV filesystem and launch them without the bootstrap afterwards?  I have experience with linux, but never using it on embedded systems before.  I want to get rtorrent, lighttpd, an SVN server, and rtgui up and running on this device, all of their codebases aren't overly complex, I can't imagine there'd be too many dependancies required.

November 25, 2009, 05:32:31 AM
Reply #11

Bob

  • Newbie

  • Offline
  • *

  • 21
No, you just log into your WD TV Live and do 'apt-get install <everything you want>'. That's it.

November 25, 2009, 05:46:30 AM
Reply #12

ProphetVX

  • Newbie

  • Offline
  • *

  • 35
No, you just log into your WD TV Live and do 'apt-get install <everything you want>'. That's it.
I understand that, but I would have thought this method would have had some unnecessary overheads.  I was thinking the bootstrap would be used as a compilation tool.  I'm not all that clued up on bootstrapping, but virtualisation on a device with such limited resources seems like a not-so-ideal solution especially if you're using it to run more than 2 or 3 extra services and still play full HD video.  I'd be interested to see how it performs.

I've had all those services I mentioned earlier running with apt-get, but was contemplating downloading the sources, building them manually and having them run from isolated folders within WDTV Live, but if it's not possible then I won't try.

Thank you very much for your work BTW, this is the breakthrough I was waiting for to make my device useful until optware comes out.

November 25, 2009, 06:00:54 AM
Reply #13

Bob

  • Newbie

  • Offline
  • *

  • 21
There's not at all any virtualization in place. It's just plain binary files you can execute. It's like copying a program to your external storage and running it from there. I don't think you will get any less performance than compiling it yourself and running it straigt without a chroot.

And while Debian is building for mipsel, they also need a proper toolchain which most likely has some optimizations. When I look at the optware packages for the WD TV, for all packages I've seen there are no optimization patches, but just wrappers and a properly configured toolchain.

Edit: Of course, you can use this perfectly for building applications. But unless you use a more optimized toolchain and do some optimization patches, this will have absolutely no advantages on performance, speed, etc.

November 25, 2009, 06:11:23 AM
Reply #14

ProphetVX

  • Newbie

  • Offline
  • *

  • 35
I understand how it works now cheers.  Thanks for your patience, I feel like such an idiot now hah.  It's been a while since I've worked with linux.  I should have paid more attention to the commands rather than just copying and pasting them in.

It's great to finally have some useful apps running on this device now.