Difference between revisions of "Debian Root File System"

From Gumstix User Wiki
Jump to: navigation, search
Line 17: Line 17:
 
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 --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.  You can use a closer Debian mirror rather than the one that I've used in the above example.
+
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.
  
 
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 onto our development machine earlier, copy the relevant file:

Revision as of 05:21, 7 March 2012

This how-to describes the procedure to build a Debian root file system. Emdebian 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.

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 use the kernel modules from the Angstrom root file system along with some other files.

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:

$ tar zcvf modules.tar.gz 2.6.39/

Now copy or scp the tarred file to the working directory of your host machine.

You will also need to edit some of the configuration files of your Debian file system once it's built. Of 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' one. Another important file is /etc/inittab, if this isn't right then you won't be able to log onto the console. You can use the one from Angstrom as well. Also /etc/network/interfaces.

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 --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.

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:

$ 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. 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:

$ tar zxvf modules.tar.gz squeeze/lib/modules

Copy the fstab, inittab and interfaces files that you took from Anstrom into your Debian file system. Other files that need our attention are /etc/hostname and /etc/apt/sources.list. Edit interfaces and change eth2 to eth1.

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

$ cd squeeze

And tar it up:

$ sudo tar -czf ../squeeze.tar.gz *

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.