Building Rootfs

From Manjaro-Arm Building
Jump to: navigation, search

Building the Rootfs is the first major step in creating a release. There are several ways to do this will guide you through the process of using Manjaro-Tools on your x86_64 machine. Manjaro-Tools is a set of scripts and tools used to build the Manjaro ISOs. While we dont package in an ISO or need most of the tools that come packaged with it, it may come in handy for future expansion. Artoo on the Manjaro-Team has show interest in adapting Manjaro-Tools to support Manjaro-Arm. In the future, using the profiles and build scripts could make Manjaro-Arm building far easier and more open to community editions.

The overall process is simple, use basestrap to create a rootfs. A rootfs is Root File System. Its what you see in / on any Linux install. It contains the necessary binaries, configs, libraries and anything else that is used to run Linux. If you had an empty partition and could use pacman, you could build a rootfs by running pacman -S base. It will install all the necessary files and configs. Since we can't use the same pacman configuration that we use on our x86_64 machines for ARM, we need the basestrap script that allows us to specify what packages to download and install (ones that correspond to the particular arch being used).

Prerequisite

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.

# pacman -S manjaro-tools arch-install-scripts

Procedure

Everything below is general procedure on how we currenly build the rootfs. It can always be changed or tweaked to better suite the builder

Get Pacman.conf

Download the default pacman.conf that is used on all Manjaro-Arm Releases.

$ 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 the 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 could change in the future

Once downloaded, simply change the Architecture value to the architecture you are building for. EX:

Architecture = armv7h

Changing your mirrorlist to use Manjaro-Arm's

Backup your original mirrorlist

# mv /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist-orig

Create a new one with Manjaro-Arm mirror Code: [Select]

$ echo "Server = https://ftp.osuosl.org/pub/manjaro-arm/repo/stable/\$arch/\$repo/" > mirrorlist
# 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

Be sure to keep track of the rootfs directories. Give them certain names

$ mkdir rootfs_armv7

Create the rootfs with basic packages

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

Once finished, restore the original mirrorlist so that you can continue updating packages on your Manjaro machine

# 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.

Chrooting in

First you must install qemu and some helper packages

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

Once these three are installed, copy the static binary into the rootfs at /usr/bin/

# cp /usr/bin/qemu-arm-static rootfs/usr/bin     //replace qemu-arm-static with qemu-aarch64-static for aarch64 rootfs

Enable binfmts for qemu-arm

# sudo update-binfmts --enable qemu-arm

It is easiest to chroot into the rootfs using arch-chroot. You can do it manually, just be sure to mount all directories properly.

# arch-chroot rootfs /bin/bash

Finishing up

Once you are in, you can create users, install packages, configure other parts of the system. The first step would obviously be installing the boot necessities for your device and starting the systemd services needed to boot. (networkd.service, sshd.service, getty, etc...) Also be sure to setup any keys or keyrings so that package integrity can remain intact. For more information Keyring Setup

While in the chroot session, you will have to configure localizations 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
# tar -cpvzf Manjaro-Arm.tar.gz .

Or you can create an image that can be dumped to your sdcard or released. Packaging Releases