Difference between revisions of "Debian Root File System"

From Gumstix User Wiki
Jump to: navigation, search
Line 30: Line 30:
 
  $ sudo debootstrap --foreign --verbose --arch=armel --include=vim-nox,openssh-server,ntpdate,less --exclude=nano squeeze ./squeeze http://ftp.au.debian.org/debian
 
  $ sudo debootstrap --foreign --verbose --arch=armel --include=vim-nox,openssh-server,ntpdate,less --exclude=nano squeeze ./squeeze http://ftp.au.debian.org/debian
  
The --include and --exclude packages are optional.  I prefer vim to the standard vim-tiny, vim-nox is the non-gui version.  I don't use nano so I've excluded it from the build.  The above command will download the required packages and create a squeeze root file system in a directory called squeeze.  You can use a closer Debian mirror rather than the one that I've used in the above example.
+
The --include and --exclude packages are optional.  I prefer vim to the standard vim-tiny, vim-nox is the non-gui version.  I don't use nano so I've excluded it from the build.  The above command will download the packages required to create a basic squeeze root file system in a directory called squeeze.  You can use a closer Debian mirror rather than the one that I've used in the above example.
  
 
Now we chroot into our newly created file system to finish off.  But the packages in the new file system are for the arm architecture so we need an emulator.  We installed it earlier, copy the relevant file:
 
Now we chroot into our newly created file system to finish off.  But the packages in the new file system are for the arm architecture so we need an emulator.  We installed it earlier, copy the relevant file:

Revision as of 00:28, 8 March 2012

Embedded Linux has always been constrained by available memory, cut-down distributions such as Angstrom and EmDebian have addressed those constraints. Debian is a stable, full featured distribution that has a very large repository of packages. With the generous amount of memory available on a micro SD card there's no reason not to use it.

This how-to describes the procedure to build a Debian root file system for a micro SD card. Gumstix's how-to on creating a bootable micro SD card can be found here. We'll follow the same procedure but will substitute our Debian root file system for the Gumstix Angstrom one.

Start by creating some working directories in some place convenient:

$ mkdir images
$ mkdir debian

Now Download some required images from the Gumstix repository. This includes the bootloaders MLO and u-boot.bin. We also need uImage, the Linux kernel. Put them in the 'images' directory.

On top of that we need the Angstrom file system. There are several to chose from, don't use any with 'nand' in the name. The one you want will be called something like, omap3-console-image-overo.tar.bz2. We'll pilfer the kernel modules from this tarball along with some important configuration files. We can, or course, build our own kernel and modules, but this way will prove to be quick and easy.

Create a directory to extract the downloaded file system and then untar it.

$ cd /your-path-to/images
$ mkdir angstrom
$ cd angstrom
$ tar xjvf ../omap3-console-image-overo.tar.bz2

Leave this for now, we'll get back to it later.

$ cd ../../debian

The Debian root file system is built with 'debootstrap'. Install it onto your host machine with apt-get, along with 'qemu-arm-static' (qemu-user-static on Debian):

$ sudo apt-get install debootstrap qemu-arm-static

Once these are installed run the following:

$ sudo debootstrap --foreign --verbose --arch=armel --include=vim-nox,openssh-server,ntpdate,less --exclude=nano squeeze ./squeeze http://ftp.au.debian.org/debian

The --include and --exclude packages are optional. I prefer vim to the standard vim-tiny, vim-nox is the non-gui version. I don't use nano so I've excluded it from the build. The above command will download the packages required to create a basic squeeze root file system in a directory called squeeze. You can use a closer Debian mirror rather than the one that I've used in the above example.

Now we chroot into our newly created file system to finish off. But the packages in the new file system are for the arm architecture so we need an emulator. We installed it earlier, copy the relevant file:

$ cp /usr/bin/qemu-arm-static squeeze/usr/bin

Now chroot into our new file system:

$ sudo chroot squeeze

Chroot has trapped us in our new root file system, isolating us from the file system of the host computer. You will see a directory named debootstrap. Go to it:

$ cd debootstrap

Finish off the installation:

$ ./debootstap --second-stage

The above command will install all the Debian packages into our file system.

We now need to create a password for the root user or we'll have a system that we can't log into:

$ passwd

Delete the .deb packages now that we've installed them:

$ apt-get clean

With that done we can exit:

$ exit

Our root file system needs kernel modules. You'll find a directory under /your-path-to/images/angstrom/lib/modules with a name that reflects the kernel version. In this example it's '3.0.0'. Copy the whole directory to the new Debian file system:

$ sudo cp -r ../images/angstrom/lib/modules/3.0.0/   squeeze/lib/modules/

We also need the fstab and inittab configuration files from Angstrom:

$ sudo cp ../images/angstrom/etc/inittab  squeeze/etc
$ sudo cp ../images/angstrom/etc/fstab  squeeze/etc

If fstab is wrong then our new Debian system won't boot properly.

If inittab is wrong then we won't get a console login prompt, we'll get an error along the lines of "init: Id 'x' respawning too fast: disabled for 5 minutes".

You can also copy the interfaces file:

$ sudo cp ../images/angstrom/etc/network/interfaces  squeeze/etc/network/

Edit the newly copied file and change eth0 to eth1.

Now go to the root directory of your Debian file system:

$ cd squeeze

And tar it up:

$ sudo tar -cjvf ../squeeze.tar.bz2 *

Create a bootable micro SD card following the Gumstix tutorial found here, but use the above squeeze.tar.bz2 in place of roofs.tar.bz2.

Put the SD card in your Gumstix COM and boot it up. If all goes well you should get a logon prompt at the console.

There are still a couple of things left to do. The kernel module dependencies need to be set up. On your new Debian install go to the modules directory:

$ cd /lib/modules/3.0.0
$ depmod

The above command will build the modules dependencies files. When you reboot, the kernel will find its modules and use them.

If you have wifi on your COM you'll have to install some more software. But first we need to put something in /etc/apt/sources.list.

$ vi /etc/apt/sources.list

Put in something like the following, replace with your closest mirror. Make sure you include the 'non-free' repositories:

deb http://ftp.iinet.net.au/debian/debian squeeze main non-free
$ apt-get update

Install wifi packages.

$ apt-get install wireless-tools libertas-firmware

There's a wifi howto at the Gumstix wiki here.

I like to edit the vimrc configuration file and un-comment the lines to enable syntax highlighting and mouse. It's at /etc/vim/vimrc.

You might also want to edit /etc/hostname.