Difference between revisions of "Debian Wheezy Instructions"

From odroid US
Jump to: navigation, search
(Availability)
Line 11: Line 11:
  
  
'''Note''': For each of the versions exists a root filesystem only release ('''rootfs''') if you just want to update system files.
+
'''Note''': For each of the versions exists a root filesystem only release ('''rootfs''') if you just want to update system files.<br/>
 +
The tarball with the -rootfs.tgz suffix is just the content of the rootfs partition of the SD card. 
  
 +
If you have flashed the Ubuntu SD-Card image and want to try the Debian system, you can just mount the partition, delete all the files and then extract the tarball onto the SD card.
 +
 +
See this tutorial for step-by-step instructions: [[Updating from Root File System Images]]
 +
 +
== Features ==
 +
Writing the '''base''' SD-card image and booting will give you a completely up-to-date, headless Debian 7.0 system. <br/>
 +
Headless, meaning only the Linux console is active -- not the HDMI display.
 +
 +
The network will come up automatically, using DHCP.
 +
 +
The login is: user/password or root/root.  Specifically, this means username: user and password: password will get you in.
 +
Or you can use username: root, password: root.
 +
 +
If you log in as user, you can use command ''su'' to become root.
  
 
==== Checking archive Integrity with md5sum ====
 
==== Checking archive Integrity with md5sum ====
Line 20: Line 35:
 
# odroidu2_20130104-debian-wheezy-3.img.xz: OK
 
# odroidu2_20130104-debian-wheezy-3.img.xz: OK
 
</pre>
 
</pre>
 
  
 
==== The Image structure ====
 
==== The Image structure ====
Line 30: Line 44:
 
See [http://odroid.us/mediawiki/index.php?title=Debian-wheezy-revision-history here] for all revision history.
 
See [http://odroid.us/mediawiki/index.php?title=Debian-wheezy-revision-history here] for all revision history.
  
== Features ==
 
Writing the base SD-card image and booting will give you a completely pristine, up-to-date, headless Debian 7.0 system.  Headless, meaning only the Linux console is active -- not the HDMI display.
 
 
The network will come up automatically, using DHCP.
 
 
The login is: user/password or root/root.  Specifically, this means username: user and password: password will get you in.
 
Or you can use username: root password: root.  Yes, I do let root log in to the console...
 
 
If you log in as user, you can su to become root.
 
  
 
== Security Issues and Initialization ==
 
== Security Issues and Initialization ==
Line 55: Line 60:
  
 
</pre>
 
</pre>
 
== Root Filesystem Images ==
 
The tarball with the -rootfs.tgz suffix is just the content of the rootfs partition of the SD card. 
 
 
If you have flashed the Ubuntu SD-Card image and want to try the Debian system, you can just mount the partition, delete all the files and then extract the tarball onto the SD card.
 
 
See this tutorial for step-by-step instructions: [[Updating from Root File System Images]]
 
  
 
== Debian Tips ==
 
== Debian Tips ==
Line 67: Line 65:
  
 
== Image Creation Details ==
 
== Image Creation Details ==
This section details how a Debian root file system for the odroid can be created.  Following the steps will not give you exactly the same results as in the prepared images because packages are periodically updated.
 
 
Debian is Debian.  If you have any Debian system, it can be updated or upgraded -- without having to go through your own bootstrap process.  It can be difficult to go through a bootstrap for a number of reasons including:
 
:<li>Crossing processor architectures is always an issue. If you are building for x86, no problem.  Most utilities work.  But, most people are not faced with building custom x86 distros
 
:<li>Debian has been around a long time.  Tools and approaches are always changing.  Googling is helpful, but you get a lot of information that is dated.
 
:<li>If you are bringing up a new platform, you don't have a known-good starting point.  For example, to do a network install, you need to have a root file system of some sort and you need a working network connection.
 
 
I did not invent any of this stuff, I just put it together and tested it specifically for use on an odroid target.
 
 
The bootstrap approach I show was tested on a clean Debian 6 machine, a VMWare virtual machine. You can find your own copy here: [http://www.trendsigma.net/vmware/debian6t.html Debian6t VM]  VMWare Player is free as well: [https://my.vmware.com/web/vmware/free#desktop_end_user_computing/vmware_player/4_0 VMWare Player].
 
 
 
=== Setup sudo on the host ===
 
You might want to install the sudo package and add yourself to the sudoers list if you have not already done it.  This section is optional, but if you object to using sudo, there are commands you need to run as root.
 
 
As root (on the host):
 
<pre>
 
apt-get install sudo
 
# You need to add yourself to the "sudoers list", and how exactly that is done depends on the distribution.
 
# This hack works for Debian Wheezy
 
# as root, add normal user (named user) to adm group
 
adduser user adm
 
# configure the adm group to have no restrictions
 
echo "%adm ALL=(ALL) ALL" >> /etc/sudoers
 
# sudo will complain if it cannot resolve the hostname
 
echo "127.0.0.1  $(hostname )" >> /etc/hosts
 
</pre>
 
You need to logout/login after making the change to the sudoers list in order for it to take effect
 
 
 
 
=== Install Prerequisites ===
 
<pre>
 
sudo apt-get update
 
sudo apt-get install binfmt-support qemu qemu-user-static debootstrap
 
</pre>
 
 
We must have the qemu-arm-static binary to bring up the system and qemu version 0.12.5 is known to fail. As of this writing, qemu 1.4.0 is current and is known to work.  Interim versions might also work. 
 
 
If it helps, you might be able to use one of the binaries I built, posted here: [http://odroid.us/odroid/users/osterluk/debian-armhf/ http://odroid.us/odroid/users/osterluk/debian-armhf/] 
 
 
<pre>
 
wget http://odroid.us/odroid/users/osterluk/debian-armhf/debian-armhf.tgz
 
wget http://odroid.us/odroid/users/osterluk/debian-armhf/debian-armhf.tgz.md5sum
 
md5sum -c debian-armhf.tgz.md5sum
 
# if the checksum is OK, then extract the files:
 
tar -xvzf debian-armhf.tgz
 
</pre>
 
 
The files are:
 
<pre>
 
launch-wheezy-no-bridge  A script to launch the root file system on the host using qemu-system-arm
 
qemu-arm-static-i386    Statically built, current version of qemu-arm for 32-bit Linux host
 
qemu-arm-static-x86_64  Statically built, current version of qemu-arm for 64-bit Linux host
 
zImage-vexpress-a9      A kernel built for a cortex-a9 machine, vexpress-a9 that is a good stand-in for
 
</pre>
 
 
The -i386 version will probably run on and x86 Linux host, but only because it is statically linked.  Just rename it to qemu-arm-static.  The x86_64 will not run on a 32-bit host.
 
 
Check the "Building QEMU" section of this tutorial if you need to build an updated qemu-arm-static binary:
 
[http://odroid.us/mediawiki/index.php?title=Step-by-step_Using_qemu_to_Boot_an_Emulated_Odroid Building QEMU]
 
 
 
=== Use debootstrap to Create Debian Root File System ===
 
To get started, we need a root file system that has all the components needed to boot Debian.  Once we have that, we can configure the system and add more packages. This technique uses qemu-system-arm, so qemu (quick emulator) needs to be installed.
 
 
<pre>
 
# Go to a convenient directory
 
cd $HOME
 
# make a place to work
 
mkdir debian-bootstrap
 
# and go there
 
cd debian-bootstrap
 
# Create the root file system, this can take some time...
 
sudo debootstrap --verbose --arch armhf --foreign wheezy $PWD/armhf http://ftp.at.debian.org/debian
 
# Now the directory $HOME/debian-bootstrap/armhf holds a wheezy root file system, built from binary packages
 
</pre>
 
 
We are going to chroot into the the armhf directory and we need qemu-arm-static available to be able to run the bootstrap script while hiding the rest of the host files from the process.  qemu-arm-static knows how to run armhf binaries on our x86 machine -- cool when you think about it.  Quite a nice piece of work.
 
 
Find qemu-arm-static:
 
<pre>
 
$(which qemu-arm-static)
 
</pre>
 
/usr/local/bin/qemu-arm-static
 
 
Make a local copy, for clarity: (copy from your downloads folder, if you plan to use the pre-built binary)
 
<pre>
 
sudo cp /usr/local/bin/qemu-arm-static .
 
</pre>
 
 
copy qemu-arm-static into what will be the chroot jail:
 
<pre>
 
sudo cp qemu-arm-static armhf/usr/bin
 
</pre>
 
 
Run debian second stage: (this is the place where a downlevel qemu-arm-static will fail)
 
<pre>
 
DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true \
 
LC_ALL=C LANGUAGE=C LANG=C sudo chroot armhf /debootstrap/debootstrap --second-stage
 
</pre>
 
 
Trigger post-install scripts:
 
<pre>
 
DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true \
 
LC_ALL=C LANGUAGE=C LANG=C sudo chroot armhf dpkg --configure -a
 
</pre>
 
 
 
 
=== Fixup Virgin Root File System ===
 
Edit inittab to put a getty on the serial console -- and also to boot to the root shell since I don't know the default username/password. (maybe there is a better, more general way to do this)
 
 
Make sure to notice: if you want to boot with qemu, then you must change ttySAC1 below to ttyAMA0.  If you do not do this, you will not get an initial console and the problem will not be obvious...
 
 
As root, in armhf/etc/inittab, change:
 
<pre>
 
#T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100
 
</pre>
 
to
 
<pre>
 
# To use with qemu, in next line, replace ttySAC1 with ttyAMA0
 
T0:23:respawn:/sbin/getty -L ttySAC1 115200 vt102
 
</pre>
 
 
As root, in armhf/etc/inittab, change:
 
<pre>
 
id:2:initdefault:
 
</pre>
 
to
 
<pre>
 
id:1:initdefault:
 
</pre>
 
 
 
 
==== Drop in Kernel Modules ====
 
Kernel modules must always match the kernel in use.  If you don't care about bring up the network, you can come back to this step later.
 
 
See the main page for a list of kernel building tutorials: [http://odroid.us/mediawiki/index.php?title=Main_Page#Tutorials]
 
 
You need to either build a custom kernel and the kernel modules (drivers) that go with it or you need to extract the kernel modules from an existing root file system that you know has a set matching the kernel you want to use.  Kernel modules would be stored at /lib/modules/3.0.68 for example, if you have a set for 3.0.68.
 
 
[TODO: add a link to the HardKernel kernel update repository ]
 
 
 
 
==== Add Device Nodes ====
 
 
Drop in some device nodes to let us run the root file system with qemu or real hardware
 
<pre>
 
sudo mknod  armhf/dev/ttyAMA0 c 204 64
 
sudo mknod  armhf/dev/ttySAC0 c 204 64
 
</pre>
 
 
 
=== Create a Root File System Tarball ===
 
It is convenient to make a tarball of the root file system.
 
 
<pre>
 
cd $HOME/debian-bootstrap/armhf
 
sudo tar -cvzf ../rootfs-wheezy-custom.tgz .
 
cd ..
 
</pre>
 
 
Mount the SD-Card on your host and follow the tutorial: [[Updating from Root File System Images]] to update your SD-Card.
 
 
 
 
 
=== Create a File System Image to use with QEMU (optional) ===
 
 
Convert the root file system to a filesystem image.  If you host has enough memory, you could increase the 500M to some larger value.
 
<pre>
 
qemu-img create rootfs-wheezy.ext4 500M
 
sudo mkfs.ext4 rootfs-wheezy.ext4
 
</pre>
 
 
And the second step:
 
<pre>
 
# We are going to need a mount point
 
mkdir mnt
 
sudo mount -o loop rootfs-wheezy.ext4 mnt
 
sudo cp -a armhf/* mnt
 
sync
 
sudo umount mnt
 
# Now rootfs-wheezy.ext4 has the same contents as the bootstrapped Debian
 
</pre>
 
 
 
==== Boot with QEMU ====
 
 
TBD show how to use the qemu example to boot the RFS
 
 
 
=== Boot the Target ===
 
The system will come up in a root shell.  We should change the passwords.  If you want to match the Hardkernel Ubuntu image, set the root password to root and the user password to password.
 
<pre>
 
passwd root
 
# answer with the root password you will remember -- consider making a note
 
# Add a user to login with
 
adduser user
 
</pre>
 
 
As root, in armhf/etc/inittab, change back to a password-protected shell, and make sure the serial console name
 
and terminal type are correct:
 
<pre>
 
id:1:initdefault:
 
T0:23:respawn:/sbin/getty -L ttyAMA0 9600 vt100
 
</pre>
 
to
 
<pre>
 
id:3:initdefault:
 
T0:23:respawn:/sbin/getty -L ttySAC1 115200 vt102
 
</pre>
 
 
You probably want to change the hostname too.  For the debootstrap build, the hostname will be the same as the host you built it on.  To set the hostname to odroidu2, do this: (as root)
 
<pre>
 
echo odroidu2 > /etc/hostname
 
</pre>
 
 
No need to keep the binary packages (about 50MiB) so clean them up like this: (as root)
 
<pre>
 
apt-get clean
 
</pre>
 
 
 
And reboot
 
 
Now, we can (as root) set the apt sources, bring up the network and update.  You should choose a nearby mirror (respository)
 
<pre>
 
echo "deb http://ftp.us.debian.org/debian wheezy main" > /etc/apt/sources.list
 
dhclient eth0
 
apt-get update
 
</pre>
 
  
The system is complete.
+
You can compile a custom version of Debian root filesystem image, just read [[Custom_Debian_Root_Filesystem_Image|here]].

Revision as of 07:51, 7 April 2013


Availability

An SD Card image of Debian system for odroid-u2 is available here: Debian-wheezy

The .img means it is a SD card image and .xz shows the file compression type.

There are two versions:

  • minimal system (base)
  • larger development version (devel) (includes a native gcc compiler and all locales)


Note: For each of the versions exists a root filesystem only release (rootfs) if you just want to update system files.
The tarball with the -rootfs.tgz suffix is just the content of the rootfs partition of the SD card.

If you have flashed the Ubuntu SD-Card image and want to try the Debian system, you can just mount the partition, delete all the files and then extract the tarball onto the SD card.

See this tutorial for step-by-step instructions: Updating from Root File System Images

Features

Writing the base SD-card image and booting will give you a completely up-to-date, headless Debian 7.0 system.
Headless, meaning only the Linux console is active -- not the HDMI display.

The network will come up automatically, using DHCP.

The login is: user/password or root/root. Specifically, this means username: user and password: password will get you in. Or you can use username: root, password: root.

If you log in as user, you can use command su to become root.

Checking archive Integrity with md5sum

  • Files next to SD images (with the .md5sum extensions) give you an easy way to check validity after downloading, using md5sum like this:
md5sum -c odroidu2_20130104-debian-wheezy-3.img.xz.md5sum 
# odroidu2_20130104-debian-wheezy-3.img.xz: OK

The Image structure

The non-filesystem area, including the bootloader(s) generally follow the HardKernel ubuntu images, like odroidu2_20130125-linaro-ubuntu-desktop-uSDeMMC.img.xz. The partition layout is the same, the bootloaders are the same.

The boot partition holds the kernel, initrd and u-boot boot scripts. These will not exactly track the HK releases.

Revision History

See here for all revision history.


Security Issues and Initialization

When you use an existing image, you pick up some keys that you should change for security reasons. Once you boot your system the first time do this: (as root)

rm /etc/ssh/*.pub /etc/ssh/*_key
#images starting at debian-wheezy-base-6.1 should have openssh-server installed
# re-generate the host ssh keys
dpkg-reconfigure openssh-server

It is best to set a unique persistent MACID. This script will do it:

echo $( ifconfig | grep HWaddr | awk '{ print $5 }' ) >/etc/smsc95xx_mac_addr

Debian Tips

This page is for Debian Tips Debian Tips

Image Creation Details

You can compile a custom version of Debian root filesystem image, just read here.