Difference between revisions of "Debian Root File System"

From Gumstix User Wiki
Jump to: navigation, search
(Created page with "This how-to describes the procedure to build a Debian root file system. I originally installed an Emdebian file system, but had dependency problems with some packages. But with...")
 
m
 
(10 intermediate revisions by one other user not shown)
Line 1: Line 1:
This how-to describes the procedure to build a Debian root file systemI originally installed an Emdebian file system, but had dependency problems with some packages. But with the generous amount of memory on a micro SD card there's no reason not to build Debian itself.  I worked 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 wiki.  This will have the Angstrom distro that Gumstix uses.  We can take the kernel modules from the Angstrom root file system along with some other filesLog into Angstrom on Gumstix and go to /lib/modules. You will see a directory named something similar to 2.6.39This contains all the kernel modules. Tar it up:
+
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.
  
$ tar zcvf modules.tar.gz 2.6.39/
+
Start by creating some working directories in some place convenient:
  
Now copy it to your development machine:
+
$ mkdir images
 +
$ mkdir debian
  
$ scp module.tar.gz ip.address.of.dev.machine:/path/to/dev/area
+
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 can scp /etc/inittab, /etc/fstab and  /etc/network/interfaces as wellUse these as a reference in when you build your Debian root file system.
+
On top of that we need the Angstrom file systemThere 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.
  
The Debian root file system is built with 'debootstrap'.  Install it with apt-get, along with 'qemu-arm-static' (qemu-user-static on Debian):
+
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
 
  $ sudo apt-get install debootstrap qemu-arm-static
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=debootstrap,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 option must include debootstrap, the others 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.
+
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 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-are-static squeeze/usr/bin
+
  $ cp /usr/bin/qemu-arm-static squeeze/usr/bin
  
 
Now chroot into our new file system:
 
Now chroot into our new file system:
Line 29: Line 40:
 
  $ sudo chroot squeeze
 
  $ sudo chroot squeeze
  
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 35: Line 46:
 
Finish off the installation:
 
Finish off the installation:
  
  $ ./debootstap -- second-stage
+
  $ ./debootstrap --second-stage
  
 
The above command will install all the Debian packages into our file system.
 
The above command will install all the Debian packages into our file system.
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/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 [http://gumstix.org/create-a-bootable-microsd-card.html here], but use the above squeeze.tar.bz2 in place of roofs.tar.bz2.
 +
 
 +
You now have a bootable Debian micro SD card. Put it 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.
  
$ tar zxvf modules.tar.gz squeeze/lib/modules
+
You might also want to edit /etc/hostname.

Latest revision as of 15:02, 17 February 2013

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:

$ ./debootstrap --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.

You now have a bootable Debian micro SD card. Put it 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.