-
root access on you host system (just for completeness)
-
debootstrap: this tool can setup a minimal debian system without using a existing paketmanager for the target.
-
qemu: debootstrap can finish the first step for a clean new system, further setup is required from this system. So far this requires running on the target - or via qemu on an emulated target
In case you are running on debian jessie, install debootstrap from the backports (requires setting this repo up)
apt-get install -t jessie-backports debootstrap
apt-get install binfmt-support qemu qemu-user-static debootstrap
Verify that debootstrap is version 1.0.72 or higher
see Debians QEMU/debootstrap approach
debootstrap --foreign --arch armhf stretch arm-stretch http://httpredir.debian.org/debian/
Some important notes:
-
if you now (or later) get a message similar to
systemd-sysv pre-depends on systemd
, then your debootstrap version is too old. A fitting one should be available from jessie-backports or onwards from stretch -
if you get
/dev/null: Permission denied
or similar errors, this would mean the filesystem your new root resides on, is not mounted with dev permission (or explicitely with nodev). Find a fitting partition, and/or remout it withmount -o remount,rw,exec,dev /srv/chroot/wheezy
Prepare the quemu stub
cp /usr/bin/qemu-arm-static arm-stretch/usr/bin
DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true \
LC_ALL=C LANGUAGE=C LANG=C chroot arm-stretch /debootstrap/debootstrap --second-stage
DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true \
LC_ALL=C LANGUAGE=C LANG=C chroot arm-stretch dpkg --configure -a
Something that tends to break easily when moving the installation around, are the sticky and setuid bits. You won`t immediatly realise they are missing either, but some strange issues will creep up later. Its a good idea to list the special permissions and keep them together with the fileystem.
find arm-stretch -perm /6000 -exec stat -c "%a %n" {} \; | sort > arm-stretch.perms
Right now, you could easily chroot into your new OS, install further packages or make modifications. This is likely alot faster than doing it on the hardware.
chroot arm-stretch
# install a desktop environment
tasksel
apt-get install....
# If you are using this as a clean template, remove all temporary stuff
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/*
exit
Finally, tar everything up. I prefer using archives instead of using cp, it also serves as clean snapshot for later installations
tar cJf arm-stretch.tar.xz --numeric-owner -Xqemu-arm-static arm-stretch arm-stretch.perms
First, we would like to clean the partition, best to format it. I chosen ext4 without journaling, which is functional similar to ext2 but faster. Also the Journal can be easily reenabled at a later time. During setup I dont consider a journal essential.
mkfs.ext4 -O ^has_journal /dev/sdf3
Next, note the UUID from the partition
blkid /dev/sdf3
Now, setup the partition by unpacking the archive on top of it.
tar -xf arm-stretch.tar.xz --strip-components=1 -C<path_to_mounted_partiton>
# Last sanity check
find <path_to_mounted_partiton> -perm /6000 -exec stat -c "%a %n" {} \; | sort
This almost concludes the setup, a few default configurations need to be changed, most importantly the root password and mounting the root filesystem.
Also debootstrap will copy some network settings from the host, to gain internet access. This might be necessary to be corrected.
-
Changing the root password requires chrooting into the new System (TODO: move this to the installation part, requires quemu again..)
chroot <path_to_mounted_partiton> passwd
-
Mounting the root filesystem is ideally done by UUID
echo > <path_to_mounted_partiton>/etc/fstab \ "UUID=3239e943-0463-4259-88fd-9bea4935b81c / ext4 errors=remount-ro 0 1"
-
Change /etc/hostname
-
Change /etc/resolv.conf
-
Setup /etc/network/interfaces