Difference between revisions of "Debian Root File System"

From Gumstix User Wiki
Jump to: navigation, search
Line 1: Line 1:
This how-to describes the procedure to build a Debian root file systemEmdebian is smaller, but I've had dependency problems with some packages. With the generous amount of memory on a micro SD card there's no reason not to use Debian.  I built the Debian root file system from the command line of Ubuntu.
+
Embedded Linux has always been constrained by available memory, cut-down distributions such as Angstrom and EmDebian have addressed those constraintsDebian 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.
  
Start by creating a bootable micro SD card following the instructions on the Gumstix wikiThis will have the Angstrom distro that Gumstix uses.  We can use the kernel modules from the Angstrom root file system along with some other files.
+
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 [http://gumstix.org/create-a-bootable-microsd-card.html here].  We'll follow the same procedure but will substitute our Debian root file system for the Gumstix Angstrom one.
  
To get the kernel modules you can either log onto your Gumstix, tar them up from there, and then scp them to your host machine.  Or you can unzip the Angstrom root file system to the working directory of your host machine.  Change directory to /lib/modules of either your Gumstix machine or your untarred Angstrom file system.  You will see a directory named something like 2.6.39.  This contains all the kernel modules.  Tar them up:
+
Start by creating some working directories in some place convenient:
  
  $ tar zcvf modules.tar.gz 2.6.39/
+
  $ mkdir images
 +
$ mkdir debian
  
Now copy or scp the tarred file to the working directory of your host machine.
+
Now Download some required images from the [http://cumulus.gumstix.org/images/angstrom/developer/ Gumstix repository].  This includes the bootloaders MLO and u-boot.bin.  We also need uImage, the Linux kernel.  Put them in the 'images' directory.  
  
You will also need to edit some of the configuration files of your Debian file system once it's builtOf particular importance is /etc/fstab.  You can use what's in Angstrom as long as you take it from the image for the SD card rather than from the 'nand' oneAnother important file is /etc/inittab, if this isn't right then you won't be able to log onto the consoleYou can use the one from Angstrom as well.  Also /etc/network/interfaces.   
+
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 filesWe 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 fsystem
 +
$ cd fsystem
 +
$ 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):
 
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):
Line 17: Line 28:
 
Once these are installed run the following:
 
Once these are installed run the following:
  
  $ sudo debootstrap --foreign --verbose --arch=armel --include=vim-nox,openssh-server --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 options 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 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.
  
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 onto our development machine 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:
  
 
  $ cp /usr/bin/qemu-arm-static squeeze/usr/bin
 
  $ cp /usr/bin/qemu-arm-static squeeze/usr/bin
Line 29: Line 40:
 
  $ sudo chroot squeeze
 
  $ sudo chroot squeeze
  
Chroot has trapped us in our new root file system.  You will see a directory named debootstrap.  Go to it:
+
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
 
  $ cd debootstrap
Line 51: Line 62:
 
  $ exit
 
  $ exit
  
Our root file system needs kernel modules:
+
Our root file system needs kernel modules.  You'll find a directory under /your-path-to/images/fsystem/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:
  
  $ tar zxvf modules.tar.gz squeeze/lib/modules
+
  $ sudo cp -r ../images/fsystem/lib/modules/3.0.0/  squeeze/lib/modules/
  
Copy the fstab, inittab and interfaces files that you took from Anstrom into your Debian file systemOther files that need our attention are /etc/hostname and /etc/apt/sources.listEdit interfaces and change eth2 to eth1.
+
We also need the fstab and inittab configuration files from Angstrom:
 +
 
 +
$ sudo cp ../images/fsystem/etc/inittab squeeze/etc
 +
$ sudo cp ../images/fsystem/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/fsystem/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:
 
Now go to the root directory of your Debian file system:
Line 63: Line 87:
 
And tar it up:
 
And tar it up:
  
  $ sudo tar -czf ../squeeze.tar.gz *
+
  $ sudo tar -cjvf ../squeeze.tar.bz2 *
 +
 
 +
Create a bootable micro SD card following the Gumstix tutorial found [http://gumstix.org/create-a-bootable-microsd-card.html 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 [http://wiki.gumstix.org/index.php?title=Overo_Wifi 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.
  
And that's about it.  Follow the same procedure that you did when you originally installed Angstrom on your SD card, this time using the Debian squeeze tarball.
+
You might also want to edit /etc/hostname.

Revision as of 23:22, 7 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 fsystem
$ cd fsystem
$ 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 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.

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/fsystem/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/fsystem/lib/modules/3.0.0/   squeeze/lib/modules/

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

$ sudo cp ../images/fsystem/etc/inittab  squeeze/etc
$ sudo cp ../images/fsystem/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/fsystem/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.