Building root filesystems

From wiki
Jump to: navigation, search


Debian based images

Preparing the image

Create a .img file and a folder to mount it

touch debian.img

mkdir mount

Fill the image file with zeros - defining its size (1GB in example). Change count=1024 to the size you need.

dd if=/dev/zero of=debian.img bs=1M count=1024

 Format the image

mkfs.ext4 -F debian.img

Build the filesystem

Get the necessary packages

apt-get install debootstrap

Mount the prepared image

mount debian.img ./mount -o loop

Building the filesystem (debian wheezy standard)

debootstrap --arch=armhf --foreign wheezy ./mount

Building the filesystem (debian wheezy minimal) - do not use this if you are new. No support for anything inside the image! (no network etc...)

debootstrap --arch=armhf --variant=minbase --foreign wheezy ./mount

Install the system

Get the necessary packages

apt-get install qemu-user-static binfmt-support

Copy the qemu-arm-static and (if needed) the hosts resolv.conf to the filesystem

cp /usr/bin/qemu-arm-static ./mount/usr/bin/
cp /etc/resolv.conf ./mount/etc

Chroot to the new enviroment

chroot ./mount

Install the system in the new enviroment

/debootstrap/debootstrap --second-stage

Setup the system

Setup apt

nano /etc/apt/sources.list

add file content:

deb wheezy main contrib non-free
deb-src wheezy main contrib non-free
deb wheezy-updates main contrib non-free
deb-src wheezy-updates main contrib non-free
deb wheezy/updates main contrib non-free
deb-src wheezy/updates main contrib non-free
nano /etc/apt/apt.conf.d/71-no-recommends

add file content:

APT::Install-Recommends "0";
APT::Install-Suggests "0";

Setup the network

nano /etc/network/interfaces

add file content:

allow-hotplug eth0
iface eth0 inet dhcp

Update the system

apt-get update

apt-get upgrade

Install some basic packages

apt-get install locales dialog

Configure packages

dpkg-reconfigure locales

If you need remote login

apt-get install ssh-server ntpdate

At this point you can install whatever you need inside the new filesystem!

Set the hostname

echo debian-armhf > /etc/hostname

Finish the installation

Leave the chroot enviroment


Remove the host files copied into the enviroment

rm ./mount/etc/resolv.conf
rm ./mount/usr/bin/qemu-arm-static

Unmount the new filesystem image

umount ./mount

Now you have your own basic debian filesystem for armhf architacture. You can use it with How_to_make_a_update.img_booting_from_SD_Card_or_Nand.

Personal tools