|
|
ViewsRunning Debian in a chrootFrom Internet Tablet Talk
Running Debian in a chrootRationaleDebian has a huge number of pre-compiled applications that run on the ITT. The problem is that they use a different kernel and different library versions, so you can't simply add the Debian repositories to your Application Manager and install the applications that interest you; you will almost surely destroy your operating system as the dependencies of almost every package will try to "upgrade" core components of your operating system. Running Debian apps in a "chroot" allows the user to run applications from two different operating systems side-by-side. They can share the same desktop, and, for most purposes, they will seem to be running in the same OS. They have access to all of the same hardware and connections (Internet, Bluetooth, etc). This method of running Debian does not require the same "level of commitment" as booting to Debian does; no custom initfs or bootmenu is required. It is a great way to test out different applications and see if they are worth any effort. HowtoPLEASE NOTE: This Wiki article is outdated. While the basic principles remain sound, the scripts have been significantly improved. All of the scripts are available for download here, and a package ("Easy Debian") that installs the scripts for you (and lets you download a Debian image file with pre-installed apps) is here. Prerequisites
Installing Debian
Before running the chroot scriptBefore running the script below, make sure you back up your system files in the Debian directory. The "cp" lines in the script below overwrite fairly important system files that may break your bootable Debian and will cause problems if you are using the beta3 bootable Debian. I would recommend doing the following (after mounting your partition to /opt), but before running the full chroot script chroot /opt cd /etc cp resolv.conf resolv.conf.deboot cp hosts hosts.conf.deboot cp group group.deboot cp passwd passwd.deboot exit When it is time to boot into Debian, you simply reverse the process, and copy the .deboot versions of the files back over the main versions. For instance, the mpd music player daemon installed in the beta3 Debian has an mpd user that is lost when you copy your /etc/passwd file from OS2008, and apt-get install complains bitterly about this missing user. I found the best thing to do was put back my .deboot backup files and do an "apt-get remove --purge mpd" to maintain my sanity. The chroot script
echo "Setting up the chroot..." export CHROOT=/opt ### #mount the Debian partition. insmod /mnt/initfs/lib/modules/2.6.21-omap1/mbcache.ko insmod /mnt/initfs/lib/modules/2.6.21-omap1/ext2.ko mount /dev/mmcblk0p4 $CHROOT -o noatime ### # Make the tablet's devices available to Debian. mount -o bind /dev $CHROOT/dev mount -o bind /proc $CHROOT/proc ### # Gentoo wiki says this will make X work. mount -t devpts none $CHROOT/dev/pts mount -o bind /tmp $CHROOT/tmp ### # Mount various external devices (SD cards, USB devices) mount -o bind /media $CHROOT/media mount -o bind /media/mmc1 $CHROOT/media/mmc1 mount -o bind /media/mmc2 $CHROOT/media/mmc2 mount -o bind /media/usb $CHROOT/media/usb ### # Mount the user's home directory mount -o bind /home/user $CHROOT/home/user ### # Make the Internet work. cp /etc/resolv.conf $CHROOT/etc/resolv.conf cp /etc/hosts $CHROOT/etc/hosts ### # Make permissions work. cp /etc/group $CHROOT/etc/group cp /etc/passwd $CHROOT/etc/passwd ### # Custom prompt. Reduces confusion. export PS1="[\u@Debian: \w]" ### # Actually chroot. echo "Everything set up, running chroot..." chroot $CHROOT $*
Running apps as a userYou can run Debian apps as a user (rather than as "root" which causes lots of problems for various apps), and even make menu items for Debian apps. Choose one of the following three methods for running apps as a user. All methods use the "common" portion below. 1: sudo methodThanks to Benson for this method. It is superior to the ssh method. As root, use visudo to add the following line to your /etc/sudoers file. Benson says, "This is only to be done using visudo; manually editing the sudoers file could leave it in an invalid state, which could result in a reboot loop. visudo checks the syntax when you're done editing, and throws you back till you get it right." user ALL = NOPASSWD: ALL ...and now the user "user", logged in on any machine, can execute any command without authentication. (optional) As root, make a one-line script, /usr/bin/debbie
sudo /root/debian hilda $* Make the script executable (chmod +x /usr/bin/debbie) 2: gainroot methodThanks to debernardis for this method. If you prefer to use gainroot for root access, you can make a one-line script, /usr/bin/debbie like the following: #!/bin/sh
if [ `id -u` != 0 ] ; then
#if not already root, call itself as root
sudo gainroot <<EOF
exec $0 $*
EOF
exit
fi
exec /home/user/MyDocs/bin/debian hilda $*
3: ssh methodYou will need to have ssh installed, and you will need to know how to set up passwordless ssh using ssh-keygen. (outside the scope of this howto) As root, make a one-line script, /usr/bin/debbie
ssh root@localhost "/root/debian hilda $*" Make the script executable (chmod +x /usr/bin/debbie) common portion
Assuming your chroot will be in /opt, make a script called /opt/usr/bin/hilda export DISPLAY=:0 echo running $* su user -c "$*" Make the script executable (chmod +x /opt/usr/bin/hilda) Now you can run, as user, the following command: debbie hilda abiword /home/user/MyDocs/demo.doc Making a menu icon for Debian appsAs root, copy an existing .desktop menu icon file. cp /usr/share/applications/hildon/mplayer.desktop /usr/share/applications/hildon/abiword-deb.desktop Edit the new .desktop file to look something like this (Changing the name, etc. of course): [Desktop Entry] Encoding=UTF-8 Name=Debian AbiWord Exec=/usr/bin/debbie abiword Icon=qgn_list_btno_gen_computer X-Osso-Type=application/x-executable X-HildonDesk-ShowInToolbar=true |