Intel® Makers
Intel® Edison, Intel® Joule™, Intel® Curie™, Intel® Galileo
Announcements
Welcome - This is a Peer-to-Peer Forum only. Intel has discontinued these products but you may find support from other customers on this Forum
9868 Discussions

Debian on Edison

RDrag
New Contributor I
4,605 Views

Hello everyone,

Has anyone tried to create a Debian image for the Edison yet? I understand that this should be easier to create than the Galileo one due to the fact that the Edison is Atom-based. But this is not something I've done before, so I thought I'd ask first before I start messing with it.

Thanks,

Razvan

1 Solution
Lucas_G_Intel
Employee
875 Views

Hi Razvan,

it is possible, I did it already.

There are two things you have to consider: the kernel itself and the root file system are two different things. When you are talking about having the Debian as Linux distribution running on the Edison you have to fulfil two tasks:

  1. 1) You have to build your own kernel and kernel modules with the Yocto SDK. Using the SDK is easier since it already patches the 3.10.17 kernel that it fits to the Edison. If you don't want to use the Yocto SDK you have at least to extract the patch file in the Yocto structure and patch the plain 3.10.17 vanilla kernel from kernel.org.
  2. 2) You have to bootstrap the Debian root file system. Bootstrapping is a mechanism which creates a minimal root file system in a local folder of your host machine. For the creation of that root file system in a folder on your host machine you can chose the Debian edition and what architecture (i686/x86_64) you want to use. The process downloads and installs all necessary files to that local folder. If this is done you can chroot into that folder and do the whole setup of the serial port (needed to have the login and debug output on serial port not on a X system) and install with apt different other needed packages. In that state you can customize your root file system like you need it. After that step you have to copy the firmware and kernel modules which you have built in the previous step to the according /lib/firmware and /lib/modules/ folder.

Having all that in place you can create the ext4 disk image file out of this folder and flash it like any other official release you get from the download page. You have to flash also the kernel itself that the kernel modules and kernel are matching each other. If you want to have the wireless features etc. also enabled you have to build the drivers against your newly build kernel and copy modules + firmware also to the Edison.

ATTENTION: this procedure can get your Edison in a state where it is really hard to recover it, so if you are not really familiar with the steps described above, consider not to do it!

View solution in original post

36 Replies
BWebb2
New Contributor III
728 Views

I've been wondering the same thing. It would be nice to have the option of a more standard Debian distribution.

Lucas_G_Intel
Employee
876 Views

Hi Razvan,

it is possible, I did it already.

There are two things you have to consider: the kernel itself and the root file system are two different things. When you are talking about having the Debian as Linux distribution running on the Edison you have to fulfil two tasks:

  1. 1) You have to build your own kernel and kernel modules with the Yocto SDK. Using the SDK is easier since it already patches the 3.10.17 kernel that it fits to the Edison. If you don't want to use the Yocto SDK you have at least to extract the patch file in the Yocto structure and patch the plain 3.10.17 vanilla kernel from kernel.org.
  2. 2) You have to bootstrap the Debian root file system. Bootstrapping is a mechanism which creates a minimal root file system in a local folder of your host machine. For the creation of that root file system in a folder on your host machine you can chose the Debian edition and what architecture (i686/x86_64) you want to use. The process downloads and installs all necessary files to that local folder. If this is done you can chroot into that folder and do the whole setup of the serial port (needed to have the login and debug output on serial port not on a X system) and install with apt different other needed packages. In that state you can customize your root file system like you need it. After that step you have to copy the firmware and kernel modules which you have built in the previous step to the according /lib/firmware and /lib/modules/ folder.

Having all that in place you can create the ext4 disk image file out of this folder and flash it like any other official release you get from the download page. You have to flash also the kernel itself that the kernel modules and kernel are matching each other. If you want to have the wireless features etc. also enabled you have to build the drivers against your newly build kernel and copy modules + firmware also to the Edison.

ATTENTION: this procedure can get your Edison in a state where it is really hard to recover it, so if you are not really familiar with the steps described above, consider not to do it!

RDrag
New Contributor I
728 Views

That sounds great! Would you mind making the image available with some installation instructions? Is it possible to revert to the default Edison firmware after this? The default flashing procedure asks you to upload the firmware files onto the mass storage that Edison creates when connected via USB, I'm assuming that no longer works when running Debian.

Also, some Android distributions allow you to run Debian under chroot (using the Android kernel), I wonder if this would work on the Edison as well. This would not require a reflash, it would run side by side with the original distribution. Has anyone tried this?

Lucas_G_Intel
Employee
728 Views

Hi Razvan,

let me check on your first point and see what I can do there, I'll keep this thread updated

The second point is not as easy as it seems like. Especially Android kernels have a lot of hooks and modifications to fit to the use-cases Android is intended for. Even the official x86 port of Android has a lot of custom adoptions. And if you then plan to run it on the Android you have to adopt the kernel patches made for the 3.10.17 vanilla kernel. Of course it is possible to use the x86 port for Android with a custom kernel, but this is also a little bit tricky.

But what you are describing with the chroot command under Android is also possible under the pre-installed Yocto distribution. It is possible in the same way as under Android to change the root-fs with the chroot command and use the already running kernel with the Debian root-fs. Just as described above, bootstrap a Debian installation onto an USB stick, plug it into the Edison Arduino board and chroot to that system. Maybe you have to re-mount some special folders, but basically you are happy to go with the Debian system. Let me see what I can and if I find some time to write a short howto for that.

JBobe
New Contributor II
728 Views

I would certainly be among the many appreciative here if you were able to make your Debian image and instructions available. I've completed so much development of a particular application on the Raspberry Pi under Debian Wheezy, and having the ability to transition all of that work to the Edison form factor would be extremely helpful.

Jim

Lucas_G_Intel
Employee
728 Views

Here are the instructions for getting at least the chroot method working. The setup was prepared with a SD card and a Fedora 19 host machine. Before you can start make sure that you have your debootstrap application already installed on the host machine, otherwise install it with yum install deboostrap. After you have it in place, continue with the following steps:

  1. Create the mount point for the SD card: sudo mkdir /mnt/sdcard
  2. Mount the SD card (in this example the SD card is recognized by the system as mmcblk1): sudo mount /dev/mmcblk0p1 /mnt/sdcard
  3. Start bootstrapping the Debian system with: sudo debootstrap --arch i386 wheezy /mnt/sdcard/ http://http.debian.net/debian/ http://http.debian.net/debian/

     

    This will install a minimal base system for an 32 bit system and the newest Debian release called Wheezy
  4. The process of downloading the packages and installing the base system can take quite a few minutes. It depends mainly on the SD card class and your internet connection speed. When the process has finished you'll see this message: I: Base system installed successfully.
  5. After the base installation you can already chroot to the new file system and start installing additional apps like python or development tools: sudo chroot /mnt/sdcard /bin/bash
  6. When you are done, leave the chroot environment with exit and unmount the SD card: sudo umount /mnt/sdcard
  7. Start your Edison and log in to the system, plug in the SD card. The SD card should be get auto mounted to /media/sdcard.
  8. An important step is to remount the special directories from your actual root file system to the new one you will use later on, therefore execute the following commands:
    1. mount proc /media/sdcard/proc -t proc
    2. mount sys /media/sdcard/sys/ -t sysfs
    3. mount dev /media/sdcard/dev/ -t devtmpfs
  9. These are just the most important ones, when you are typing mount in the standard root file system you will get a list of all mount points and special file systems used in the system, you can than decide which you want to remount to your new file system, too.
  10. Now you can change into your new Debian root file system with: chroot /media/sdcard /bin/bash
JBobe
New Contributor II
728 Views

After an afternoon of playing with Lucas' solution, I was able to get it working without requiring an SD card on Edison. I followed his steps 1-6, but then copied the wheezy file structure to a /wheezy directory I created on Edison. Then, in analogy to what he did:

mount proc /wheezy/proc -t proc

mount sys /wheezy/sys/ -t sysfs

mount dev /wheezy/dev/ -t devtmpfs

chroot /wheezy /bin/bash

Then I did the "unthinkable" and installed Apache2 with PHP5, and gphoto2, from by simply using 'apt-get install' in the usual fashion. I tested the Apache2 server from another machine on my LAN and it works flawlessly in executing PHP5 scripts on (wireless) Edison. I haven't tested gphoto2 yet, since I'm lacking a suitable adapter to plug in my camera to the Edison's USB port.

Now if I can just figure out how to have Edison automatically shift to wheezy upon boot up.

Jim

RDrag
New Contributor I
728 Views

You know what would be a cool addition to all this? Using kexec (see http://vince-debian.blogspot.ro/2008/01/creating-and-booting-ia32-debian-system.html YANUB: yet another (nearly) useless blog: Creating and booting an ia32 debian system from an amd64 one for instance) to load a new kernel and then use the Debian root you've created. You would then be able to create your own kernel without messing with the Intel default (and possibly bricking your Edison).

Lucas_G_Intel
Employee
728 Views

Hi Jim,

that sounds good. You can achieve the "auto-chroot" by editing the .profile (vi ~/.profile) file in your home directory of the main root file system. Busybox uses the ash shell and .profile is the auto load file after logging in into the system. Just add these few lines:

mount proc /wheezy/proc -t proc

mount sys /wheezy/sys/ -t sysfs

mount dev /wheezy/dev/ -t devtmpfs

chroot /wheezy /bin/bash

And you automatically change root to the Debian system.

FMutt
Novice
619 Views

I suggest also to set up the DNS and the repo (that is needed in my case):

sudo cp /etc/resolv.conf /var/chroot/trusty/etc/resolv.conf (from the Ubuntu host)

sudo cp /etc/apt/sources.list /var/chroot/trusty/etc/apt/ (from the Ubuntu host)

I have installed the new Ubuntu release 14.04 LTS (Trusty). The procedure is very similar to the Debian one.

At this moment I have a problem with the gpg key of the repo but it works.

HKrat
Innovator
728 Views

Hi!

I created a script to install a Debian chroot directly on the Edison without the need to prepare anything on a PC.

The /home partition is usually mounted with nodev and cdebootstrap does not like that so one needs to remount the /home partition:

mount /home/ -o dev,remount

Running the attached bootstrap-debian-edison.sh shell script on the Edision creates a wheezy Debian chroot in /home/root/debian

Afterwards /home can be remounted with nodev again, the chroot will use a bind mount to the original /dev anyway:

mount /home/ -o nodev,remount

The setup-chroot-mounts.sh shell script sets up the mounts for /sys, /proc and /dev in the chroot.

To switch to the chroot use:

chroot /home/root/debian/ /bin/bash

 

-- Hans

RDrag
New Contributor I
728 Views

Wow, this worked great for me! Intel should really do this by default, it's pretty cool and far more powerful than the builtin Yocto-based distribution.

RDrag
New Contributor I
728 Views

BTW, you're also going to have to set up the mount point for /dev/pts (separate from /dev) - with "mount --bind /dev/pts $DEBIAN_CHROOT/dev/pts ".

RDrag
New Contributor I
728 Views

A few apt-gets later I have a web browser, a terminal and Bitcoin Core running on the Edison side by side, in an X session (using VNC to view it). It's really amazing that something the size of a postage stamp can run all this perfectly.

JBobe
New Contributor II
728 Views

Yes! On wheezy I just installed Apache2 and PHP5, and made/installed the latest gphoto2 (2.5.5) from source after installing various dependencies with apt-get. It's sweet having a Debian system.

JRodr46
Beginner
619 Views

Congratulation!

Very good.

Josemar

AAliY
Novice
619 Views

Running the bootstrap-debian-edison.sh. im getting these in the beginning, everything else is currently running smoothly

I: Can't find keyring debian-archive-keyring.gpg

P: Retrieving InRelease

W: Couldn't download InRelease!

P: Retrieving Release

W: Couldn't validate Release!

P: Parsing Release

Normal?

JBobe
New Contributor II
728 Views

One problem I'm stuck on is a "broken" sudo after I chroot into Debian. I need to execute a command with root privileges from a perl script that is executed by Apache2. Apache2 executes the script as user 'www-data'. In a normal Debian environment, I can use sudo within the perl script, e.g. system("sudo command ..."); and make it work. With this chroot setup on Edison, the Apache2 error log shows the error 'sudo: effective uid is not 0, is sudo installed setuid root?'. I Googled this error and attempted to apply remedies I found there, but to no avail. Any ideas?

Jim

HKrat
Innovator
728 Views

rubidium wrote:

One problem I'm stuck on is a "broken" sudo after I chroot into Debian. I need to execute a command with root privileges from a perl script that is executed by Apache2. Apache2 executes the script as user 'www-data'. In a normal Debian environment, I can use sudo within the perl script, e.g. system("sudo command ..."); and make it work. With this chroot setup on Edison, the Apache2 error log shows the error 'sudo: effective uid is not 0, is sudo installed setuid root?'. I Googled this error and attempted to apply remedies I found there, but to no avail. Any ideas?

The problem is that /home is mounted nosuid. Should work after remounting it with the suid option enabled:

mount /home/ -o suid,remount

-- Hans

 

JBobe
New Contributor II
728 Views

Thanks, but that doesn't seem to change anything. As a more concrete example of what I'm attempting to do, consider having Apache2 run a perl script that includes a command that generally requires root privileges, e.g.:

# !/usr/local/bin/perl

use strict;

use warnings;

system("mount /dev/sda1 /usbdrive");

When run from the console (i.e. as 'root') the simple script above works fine. However, it fails when Apache2 runs it, giving the error in /var/log/apache2/error.log:

.

.

mount: only root can do that

I fully expect that error, since Apache2 runs the script as user 'www-data'. So, to avoid that error, I add 'sudo' to the above perl script:

# !/usr/local/bin/perl

use strict;

use warnings;

system("sudo mount /dev/sda1 /usbdrive");

My /etc/sudoers looks like this:

#

# This file MUST be edited with the 'visudo' command as root.

#

# Please consider adding local content in /etc/sudoers.d/ instead of

# directly modifying this file.

#

# See the man page for details on how to write a sudoers file.

#

Defaults env_reset

Defaults mail_badpass

Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification

root ALL=(ALL:ALL) ALL

www-data ALL=(ALL:ALL) ALL

# Allow members of group sudo to execute any command

%sudo ALL=(ALL:ALL) ALL

# See sudoers(5) for more information on "# include" directives:

# includedir /etc/sudoers.d

Again, when I run the revised perl script from the console (i.e. as 'root') it works fine. However, it still fails when Apache2 runs it, giving the error in /var/log/apache2/error.log:

.

.

sudo: effective uid is not 0, is sudo installed setuid root?

Any way to get past this?

Reply