Archive for November, 2006

Building a Gentoo and Debian chroot Environment

Written on November 29th, 2006 by
Categories: Information Insemination

If you’re wondering how to create a chroot environment in the first place while reading my previous post, then this post is for you.

Gentoo:

  • Download gentoo stage 3 installer
  • wget http://mirror.gentoo.gr.jp/releases/x86/2006.1/stages/stage3-i686-2006.1.tar.bz2
  • Create a chroot folder
  • mkdir chroot-gentoo
  • Extract it
  • sudo tar xvjf stage3-i686-2006.1.tar.bz2 -C chroot-gentoo
  • Mount proc and dev
  • sudo mount -o bind /dev chroot-gentoo/dev
    sudo mount -o bind /proc chroot-gentoo/proc
  • And possibly some other directories too
  • sudo mount -bind /usr/portage chroot-gentoo/usr/portage
  • And that’s it, you can start chrooting now
  • sudo chroot chroot-gentoo /bin/bash
  • You might want to install some essential packages
  • emerge --sync
    emerge vim 
    
  • Exit when you're done
  • exit
  • Dont forget to unmount what you have mounted
  • sudo umount chroot-gentoo/dev chroot-gentoo/proc chroot-gentoo/usr/portage

You can have a debian chroot system too

  • Install essential package
  • as root

    echo "dev-util/debootstrap ~x86" >> /etc/portage/package.keywords
    emerge debootstrap 
  • Populate your chroot folder using debootstrap
  • debootstrap sid chroot-debian http://mirror.pacific.net.au/debian/
  • Mount proc and dev
  • sudo mount -o bind /dev chroot-debian/dev
    sudo mount -o bind /proc chroot-debian/proc
  • Start chrooting now
  • sudo chroot chroot-debian /bin/bash
  • Install your favorite packages
  • apt-get update
    apt-get install <list your package here>
  • Exit once done playing with the chroot environment
  • exit
  • Clean up some mess
  • sudo umount chroot-debian/dev chroot-debian/proc

Just do whatever you wish with your chroot environment, and you can just delete the chroot folder when you realized that you messed up too much already.

Development Platform The chroot Way

Written on November 28th, 2006 by
Categories: Information Insemination

As opposed to some people, I prefer to use chroot rather than qemu ( or vmware, etc2, just name it) when doing my development, whenever possible. By this I don’t need to worry about damaging my system, and not having to deal with overheads introduced by virtualisation.

What I use for the purpose are my 40GB removable harddisk, and gentoo’s stage3 install package. Here’s how it goes;
shakir@herugrim ~ $ cat temp/bin/xxusbhd

#!/bin/bash
MOUNT=/mnt/usbhd

sudo mkdir $MOUNT

sudo mount -t reiserfs -o exec,rw /dev/`cat /proc/partitions | grep 39069680 | gawk ‘{ print $4 }’` $MOUNT

shakir@herugrim ~ $ temp/bin/xxusbhd
shakir@herugrim ~ $ cd /mnt/usbhd/chroot/uclinux/
shakir@herugrim /mnt/usbhd/chroot/uclinux $ cat /home/shakir/temp/bin/xxchroot.gentoo
#!/bin/bash

sudo mkdir -p usr/portage/distfiles
sudo mount –bind /usr/portage usr/portage
sudo mount –bind /home/gentoo/distfiles/ usr/portage/distfiles
sudo mount –bind /dev dev/
sudo mount –bind /proc proc/
sudo chroot . /bin/bash

sudo umount dev/
sudo umount proc/
sudo umount usr/portage/distfiles/
sudo umount usr/portage/

## Second check
echo "## Second check.. Please ignore the errors"
sudo umount dev/
sudo umount proc/
sudo umount usr/portage/distfiles/
sudo umount usr/portage/

shakir@herugrim /mnt/usbhd/chroot/uclinux $ /home/shakir/temp/bin/xxchroot.gentoo
herugrim / # ls -l
total 12
drwxr-xr-x  2 root root  3464 Aug  3 15:39 bin
drwxr-xr-x  2 root root    96 Aug  3 14:24 boot
drwxr-xr-x 14 root root 13280 Nov 28 08:37 dev
drwxr-xr-x 30 root root  2336 Nov 28 08:18 etc
drwxr-xr-x  2 root root    72 Aug  3 14:23 home
drwxr-xr-x  7 root root  3736 Nov 10 11:45 lib
drwxr-xr-x  4 root root   120 Aug  3 14:23 mnt
-rw-r–r–  1 root root     0 Nov 14 12:57 modules.dep
drwxr-xr-x  2 root root    72 Aug  3 14:23 opt
dr-xr-xr-x 79 root root     0 Nov 28 08:36 proc
drwx——  2 root root    72 Aug  3 15:39 root
drwxr-xr-x  2 root root  3344 Aug  3 15:39 sbin
drwxr-xr-x  2 root root    72 Aug  3 14:23 sys
drwxrwxrwt  2 root root    80 Nov 28 08:18 tmp
drwxr-xr-x 18 root root   744 Nov 28 08:18 uClinux-dist
drwxr-xr-x 13 root root   368 Nov  9 12:17 usr
drwxr-xr-x 12 root root   288 Aug  3 15:38 var
herugrim / # exit
exit
## Second check.. Please ignore the errors
umount: dev/: not mounted
umount: proc/: not mounted
umount: usr/portage/distfiles/: not mounted
umount: usr/portage/: not mounted
shakir@herugrim /mnt/usbhd/chroot/uclinux $ cd
shakir@herugrim ~ $ cat temp/bin/xxusbhd.clean
#!/bin/bash

MOUNT=/mnt/usbhd

sudo umount $MOUNT
sudo rmdir $MOUNT

shakir@herugrim ~ $ /home/shakir/temp/bin/xxusbhd.clean
shakir@herugrim ~ $ ls /mnt/
cdrom  cf  floppy  sdb1  sdc1  thumb  windoze
shakir@herugrim ~ $

Terminal’s output copy-paste is a lazy but definitive way of explaining this (stress on the later :) ).. /home/shakir/temp/bin is actually already in my path, and so I just need to type my script’s name to execute it (please refer to my previous post).

(Un)Expected downtime

Written on November 8th, 2006 by
Categories: Nerd Public Journal?

It has been a quiet but busy October that I was on a work trip to Sabah to bring up some wifi links over there. It’s quite a large scale implementation, and so expect me to be offline again :)

I’m serious with this site, that even that were on an island that most people would just think to enjoy the sandy beaches, we went through all the hassle of bringing up a 7.5 km cross ocean wifi link on a very hazy environment (these Indonesians never learn..) just to get connected to mohdshakir.net :)

Ok, it was not all about that, but thanks to Linux that powers our SBC (single board computer), it’s possible to do just that.