Building the Rootfs

From Manjaro-Arm
Jump to: navigation, search

These guides are not meant to be to be extremely easy to follow but to be used in creating wiki pages that are. This is an overview of the process and the commands involved. These may change frequently as new methods are discovered or current methods are streamlined. The most important part to remember is, there are many ways to do this, we just use this method for the official Manjaro-Arm images

Creating the Rootfs[edit]

Prerequisite[edit]

All of these instructions are for the x86_64 machine unless stated otherwise. If you haven't yet installed the manjaro-tools package, please do so in order to complete this process. In particular, assure that the arch-install-scripts package has been installed.

$ sudo pacman -S manjaro-tools
 

Getting a default pacman.conf to use[edit]

$ wget http://manjaro-arm.org/downloads/pacman.conf.default
 

Notice that the pacman.conf has the siglevel changed to Never. This is because there is no keyring on rootfs and since the full manjaro-tools suite is still not completely available for Manjaro-Arm, there is no clean way to utilize the signatures until after the rootfs has been built. This will change in the future

Changing your mirrorlist to use Manjaro-Arm's[edit]

Backup the original[edit]

Currently Manjaro-Tools uses the host machine's mirrorlist. Until the tools suite is ported to work with Manjaro-Arm fully, we must alter our machine's mirrorlist in order to pull Manjaro-Arm packages. We will restore it to normal upon completion.

$ sudo mv /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist-orig
 

Create a new one with Manjaro-Arm mirror[edit]

$ echo "Server = http://repo.manjaro-arm.org/stable/\$arch/\$repo/" > mirrorlist
$ sudo mv mirrorlist /etc/pacman.d/mirrorlist
 

This process will also be changed when Manjaro-Tools becomes fully functional with Manjaro-Arm. Until then, be sure to backup your original.

Create your rootfs dir[edit]

This is the working directory that will essentially be the / directory on the booted image.

$ mkdir rootfs
 

Create the rootfs with basic packages[edit]

Start the build with:

$ basestrap -G -C pacman.conf.default rootfs base base-devel manjaro-system manjaro-arm-keyring manjaro-release lsb-release pacman-mirrorlist yaourt
 

Note: execv failures are expected and can be ignored.

Restore your original mirrorlist[edit]

Dont forget to restore the computer's original mirrorlist so that you can continue using the system normally

$ sudo mv /etc/pacman.d/mirrorlist-orig /etc/pacman.d/mirrorlist
$ sudo pacman -Syy
 

You now have a very basic rootfs with Manjaro-Arm base. This will not boot nor will it be complete by any means.

Installing QEMU[edit]

Qemu is a tool that allows virtualization of different architectures in order to allow things like chroot

Install required Qemu tools[edit]

The below packages were working as of Aug 01. 2016

$ sudo pacman -S qemu
 

The rest will come from AUR

$ yaourt -S binfmt-support
$ yaourt -S qemu-user-static
 

Setup Qemu to work with ARM or AARCH64[edit]

Copy the arm or aarch64 binary to the rootfs and enable arm emulation. Without this, you will not be able to chroot into the rootfs.

Copy[edit]

In order to chroot, the rootfs needs to have the qemu static binary. This tells the system to use the qemu virtualization.

$ sudo cp /usr/bin/qemu-arm-static rootfs/usr/bin
 

Enable[edit]

We are doing this for ARM devices. It encompasses both armv7 and armv6. Qemu can emulate far more architectures but for our purposes, we only need arm

$ sudo update-binfmts --enable qemu-arm
 

Chroot into the system[edit]

The cleanest way to do this is to use arch-chroot, else look at the manjaro or arch wiki on how to do a full chroot (mounting proc, sys, dev and resolv) in order to chroot

$ sudo arch-chroot rootfs /bin/bash
 

Once you are in, you can create users, install packages, configure other parts of the system.

Basic setup for boot[edit]

We would obviously recommend installing the boot necessities for your device and starting the systemd services needed to boot. (networkd.service, sshd.service, getty, etc...). Every device is different so there is no one package to solve the boot firmware. Please look at the device information pages in order to find the packages you need. If Manjaro-Arm does not offer these packages, please contact one of the maintainers and discuss adding these packages to the Repos.

Also be sure to setup any keys or keyrings so that package integrity can remain intact. Suggested keyrings are manjaro-arm-kerying, archlinux-keyring, and archlinuxarm-keyring.

Note: Please follow the manual intervention instructions in order to setup/update keys and sign packages within this chroot session. You may need to set your localization settings (edit /etc/locale.gen, run locale-gen, create /etc/locale.conf, and set your time zone) prior to finishing Manual intervention Forum Post

Extra Configurationg[edit]

While in the chroot session, you will have to configure localization manually, as using the daemon commands for the target environment (such as timedatectl) won't work until you actually boot from the SD card. Manually editing the configuration files, or creating a softlink (as below) and substituting your actual zone/subzone should work well within the chroot session.

ln -sf /usr/share/zoneinfo/Zone/SubZone /etc/localtime
 

Once you are done with your desired customizations to the environment, and setting up the necessary firmware/boot files, exit the chroot session, and umount the directories mounted for the chroot session. When you're ready to proceed with making a bootable SD card, you can either tar up your work with:

$ cd rootfs
$ sudo tar -cpvzf Manjaro-Arm.tar.gz .
 

There is more information and instructions about proper packaging of both the tarballs and the images in the Guide for packaging on the wiki.