Install Archlinux on Baytrail devices

From L1Wiki
Jump to: navigation, search

Install Arch Linux In Baytrail Devices


The braytrail processor is a low power x86 processor from intel that can be found in several tablets, phones and other devices. This tutorial is focused on installing arch linux in the cheap cenovo minipc, but its instructions should work other devices with this processor.

While the processor supports 64bits, many manufacturers only include a 32bit UEFI with the device, so the installation of linux in theses devices requires that the linux distro intall media contains a EFI file to boot from a 32bit UEFI, wich many do not have. On arch linux we need to create a 32bit EFI file and add it to the installation media.


For the preparation we need a another computer with linux installed or a linux livecd running and usb pen.

  • Download the latest archlinux iso (in this tutorial it is on /tmp/)
  • Get a iso label name with the command
file <ISO-FILE> | sed -e "s/.*'\(.*\)'.*/\1/"
  • Create the file /tmp/grub.cfg with the following content, replacing <FS-LABEL> with the text given by the previous command:
insmod part_gpt
insmod part_msdos
insmod fat
insmod efi_gop
insmod efi_uga
insmod video_bochs
insmod video_cirrus
insmod font

if loadfont "${prefix}/fonts/unicode.pf2" ; then
  insmod gfxterm
  set gfxmode="1024x768x32;auto"
  terminal_input console
  terminal_output gfxterm
menuentry "Arch Linux archiso x86_64" {
  set gfxpayload=keep
  search --no-floppy --set=root --label <FS-LABEL>
  linux /arch/boot/x86_64/vmlinuz archisobasedir=arch archisolabel=<FS-LABEL> add_efi_memmap
  initrd /arch/boot/x86_64/archiso.img

menuentry "UEFI Shell x86_64 v2" {
  search --no-floppy --set=root --label <FS-LABEL>
  chainloader /EFI/shellx64_v2.efi
menuentry "UEFI Shell x86_64 v1" {
  search --no-floppy --set=root --label <FS-LABEL>
  chainloader /EFI/shellx64_v1.efi
  • run the command to generate the bootia32.efi file:
grub-mkstandalone -d /usr/lib/grub/i386-efi/ -O i386-efi --modules="part_gpt part_msdos" --fonts="unicode" --locales="uk" --themes="" -o "/tmp/bootia32.efi" "boot/grub/grub.cfg=/tmp/grub.cfg" -v
  • prepare the usb pen (sdb in this tutorial) by wiping it and creating a EFI System partition using all space:
gdisk /dev/sdb
Command (? for help): x
Expert command (? for help): z
About to wipe out GPT on /dev/sdb. Proceed? (Y/N): y
GPT data structures destroyed! You may now partition the disk using fdisk or  other utilities.
Blank out MBR? (Y/N):  y

gdisk /dev/sdb
Command (? for help): n
Hex code or GUID (L to show codes, Enter = 8300): ef00
Command (? for help): w
  • format the pen, extract the archlinux iso, copy the EFI file and umount it (replace <ISO-FILE> and <FS-LABEL> with your own):
mkfs.vfat -F 32 -n <FS-LABEL> /dev/sdb1
mkdir /tmp/archinstall
mount /dev/sdb1 -t vfat /tmp/archinstall
bsdtar -x --exclude=isolinux/ --exclude=EFI/archiso/ --exclude=arch/boot/syslinux/ -f <ISO-FILE> -C /tmp/archinstall/
cp /tmp/bootia32.efi /tmp/archinstall/EFI/boot/bootia32.efi
umount /tmp/archinstall
rm -rif /tmp/archinstall
Following the instructions in this tutorial will erase all data from the device. If you want to make a backup, you can use Clonezilla (AMD64 Ubuntu-based version of alternative) which supports booting from 32bit UEFI-only devices without any modification.


Boot from the usb pen. On the cenovo mini pc it can be done by:

  1. Going to the bios by pressing escape
  2. Goto to Save & Exit -> Boot Override -> Select usb pen

Initial configuration

after booting the install media, load the keymap and start the wired network

loadkeys uk
ip addr
dhcpcd enp0s20u2

Creating partitions and filesystems

wipe the device:

gdisk /dev/mmcblk0
Command (? for help): x
Expert command (? for help): z
About to wipe out GPT on /dev/sdb. Proceed? (Y/N): y
GPT data structures destroyed! You may now partition the disk using fdisk or other utilities.
Blank out MBR? (Y/N):  y

format the device and create a 512mb EFI system partition, a 2gb swap partition and a ext4 filesytem with the remaining space:

Using a swap partition on this device will increase the number of writes on the flash chip and reduce its lifespan as result. I you are going to use memory intense programs, even if only sporadically, you can set the system to use the swap only when really necessary by setting the swappiness value to 0. If you not going to use it, ignore the second partition creation in the following step. If you are unsure, you can create the partition now and disable it later you don't want to use it anymore.

gdisk /dev/mmcblk0

Command (? for help): n
Partition Number: 
First Sector: 
Last Sector: 512M
Hex code or GUID: ef00

Command (? for help): n
Partition Number: 
First Sector: 
Last Sector: 2560M
Hex code or GUID: 8200

Command (? for help): n
Partition Number: 
First Sector: 
Last Sector: 
Hex code or GUID: 8300

Command (? for help): w

check your partitions by running the commands:

gdisk /dev/mmcblk0
Command (? for help): p
Command (? for help): q

format the partition by running the following commands:

mkfs.vfat -F 32 /dev/mmcblk0p1 
mkswap /dev/mmcblk0p2
mkfs.ext4 /dev/mmcblk0p3

Starting the installation

start the installation with:

mount /dev/mmcblk0p3 /mnt
pacstrap /mnt base base-devel
genfstab -L -p /mnt >> /mnt/etc/fstab
arch-chroot /mnt

Setting the regional settings

Configure the hostname:

echo cenovo > /etc/hostname

Setup your location:

ln -s /usr/share/zoneinfo/Europe/London /etc/localtime

On the file /etc/vconsole.conf


On the file /etc/locale.gen uncomment the needed locales and run:


Setup locale preferences in /etc/locale.conf and possibly $HOME/.config/locale.conf:

echo LANG=uk_UK.UTF-8 > /etc/locale.conf

On the file /etc/mkinitcpio.conf and insert keymap on the HOOKS line and run:

mkinitcpio -p linux

Installing the bootloader

Install the grub and efibootmgr

pacman -S grub efibootmgr 
mkdir /boot/efi
mount /dev/mmcblk0p1 -t vfat /boot/efi
grub-install --target=i386-efi --efi-directory=/boot/efi/ --bootloader-id=grub

To prevent a (harmless) error message at boot time run:

cp /usr/share/locale/en\@quot/LC_MESSAGES/ /boot/grub/locale/

Change GRUB timeout on by modifying the file /etc/default/grub:


Generate GRUB2 configuration:

grub-mkconfig -o /boot/grub/grub.cfg

Optional: setting options for reducing write wear

Most of these options can be applied later after the installation. The only exception is the first one because it is required to be executed in a livecd since the file system must be read-only.

  • Disable journaling on the ext4 file system. It is necessary to leave the chroot, umount partitions, apply the config, remount the partition and run chroot again. All this can be accomplished with the following commands:
umount /mnt/boot/efi
umount /mnt
tune2fs -O "^has_journal" /dev/mmcblk0p3
fsck.ext4 -f /dev/mmcblk0p3
mount /dev/mmcblk0p3 /mnt
arch-chroot /mnt
mount /dev/mmcblk0p1 -t vfat /boot/efi
  • Optimize the file systems by editing /etc/fstab and :
    • Adding the noatime (no access time), no diratime (same for directories instead of files) and data=writeback options for the data partition
    • Adding highly used directories to the ram. The size assigned to each partition might depend of you usage. ATENTION: The data on this directories will not persist after reboot.
/dev/mmcblk0p3  /                 ext4    rw,data=writeback,noatime,nodiratime 0 1
tmpfs           /tmp              tmpfs   defaults,noatime,nodev,nosuid,size=200M,mode=0755 0 0
tmpfs           /var/tmp          tmpfs   defaults,noatime,nodev,nosuid,size=100M,mode=0755 0 0
tmpfs           /var/log 	   tmpfs   defaults,noatime,nodev,nosuid,size=100M,mode=0755 0 0
tmpfs           /var/cache 	   tmpfs   defaults,noatime,nodev,nosuid,size=200M,mode=0755 0 0
# Not necessary if cups is not installed
tmpfs           /var/spool/cups   tmpfs   size=100M,defaults,noatime,mode=0755 0 0 
  • Setup journald to store journals in RAM by creating a custom configuration file. (Might not be needed depending on the folders that were added to ram in previous step)

Create the file /etc/systemd/journald.conf.d/usbstick.conf and add the following content:

  • Change the disk scheduler better suited for less writes (some detailed info can be found here and here). This requires to create a script to apply the setting and a systemd unit to run the script at startup.

Create the file /usr/bin/startup with:

echo noop > /sys/block/mmcblk0/queue/scheduler
echo 1 > /sys/block/mmcblk0/queue/iosched/fifo_batch

Make it executable with:

chmod 755 /usr/bin/startup

Create the file /etc/systemd/system/startup.service with:

Description=Startup script and application at startup



Start the service with the command:

systemctl enable startup.service

Finish the installation

Run the following commands to end the installation:

umount /mnt/boot/efi
umount /mnt

Post Installation Configuration

For lan auto configuration start the dhcp client service with the command(replace <LAN-DEVICE> with device given by the ip addr):

ip addr
ip link set <LAN-DEVICE> up 
systemctl start dhcpcd@<LAN-DEVICE>.service 
systemctl enable dhcpcd@<LAN-DEVICE>.service

Add a user:

useradd -m -g users -G wheel cenovouser
passwd cenovouser

Allow the user to use sudo by editing the file /etc/sudoers and adding:

cenovouser ALL=(ALL) ALL

Add extra software repos by editing /etc/pacman.conf and adding:

SigLevel = Optional TrustAll
Server =
Include = /etc/pacman.d/mirrorlist

Install yoaourt package manager with:

 pacman -Sy yaourt

Setup yaourt to ask less questions by editing /etc/yaourtrc file and setthe following parameters:

# Prompt
#UP_NOCONFIRM=0     # No prompt while build upgrades (including -Sbu)
BUILD_NOCONFIRM=1  # Only prompt for editing files
PU_NOCONFIRM=1     # Add --noconfirm to $PACMAN -U

Hardware Installation


The cenovo mini pc has rtl8723bs chipset and there is a package for archlinux. After installing the package it is necessary to copy its firmware to the system firmware folder. All this can be done with:

sudo pacman -S linux-headers git
yaourt -S aur/rtl8723bs-dkms-git
cd /tmp/
git clone
cp rtl8723bs/rtl8723bs_*bin /usr/lib/firmware/rtlwifi/ 


The cenovo has a rt5640 chipset that is common with many of these low power devices and unfortunately the the driver is a work in progress. In the bios there is a option change what type of device the card will be recognized (ACPI device or PCI) but the driver doesn't register the card with either option even after testing several with several firmware files. Some people managed to get it recognized by fiddling and compiling the module on some but some devices, but so far I haven't managed to have success with this card.

For now, the only solution for many users with this chipset and similar ones is to use a usb soundcard.

Optional: Install SSH Server

Install openssh server with:

pacman -S openssh
systemctl start sshd.service
systemctl enable sshd.service

Optional: Install Kodi

To install kodi and set it up to boot at startup run the following command:

yaourt -S kodi libcec kodi-standalone-service lm_sensors pulseaudio alsa-utils alsa-firmware pulseaudio-alsa xf86-video-intel mesa-libgl xf86-input-evdev xf86-input-mouse xf86-input-keyboard

Select mesa-libgl. Run the following commands to finish installation:

sudo systemctl enable kodi
sudo chown -R kodi:kodi /usr/share/kodi
sudo chown -R kodi:kodi /var/lib/kodi
sudo gpasswd -a kodi audio
sudo gpasswd -a kodi video
sudo gpasswd -a kodi power
sudo gpasswd -a kodi input
sudo gpasswd -a kodi storage

Setup the sound levels with with root:


Setup lm_sensors with:


Setup kodi to read the system temperatures a tweak the performance by editing the /var/lib/kodi/.kodi/userdata/advancedsettings.xml and and adding:

 <cputempcommand>sensors|sed -ne "s/Core 3: \+[-+]\([0-9]\+\).*/\1 C/p"</cputempcommand>
 <gputempcommand>sensors|sed -ne "s/Core 3: \+[-+]\([0-9]\+\).*/\1 C/p"</gputempcommand>

More information about some of these settings and others can be found here and here.

It is necessary to install additional packages depending of the functionalities of kodi that you want to use like the nfs-utils package for accessing nfs shares or bluez and related packages for Bluetooth support.

Start kodi with:

sudo systemctl enable kodi

Optional: Install Desktop

If you installed kodi-standalone-service you can disable temporary (or permanently) with the command:

sudo systemctl disable kodi

Install xorg and basic tools:

pacman -S xf86-video-intel mesa-libgl xf86-input-evdev  xf86-input-mouse xf86-input-keyboard xorg-twm xorg-xclock xterm

Test xorg with:


Install a login manager with:

sudo pacman -S lightdm lightdm-gtk-greeter

Configure the greeter for lightdm by editing /etc/lightdm/lightdm.conf file and change the greeter-session variable to:


Set to enable at startup with:

systemctl enable lightdm

Install Mate Desktop

This is my preferred desktop. For other desktops or window manager consult the archlinux wiki for specific configuration.

Install mate with:

sudo pacman -S mate mate-terminal upower udisks

Setup permissions to reboot and disk mounting:

gpasswd -a cenovouser power 
gpasswd -a cenovouser disk

Install Networkmanager

Install networkmanager packages by running:

pacman -S gnome-keyring networkmanager network-manager-applet dnsmasq wpa_supplicant wireless_tools
systemctl enable NetworkManager.service
systemctl enable NetworkManager-dispatcher.service
systemctl start NetworkManager.service
systemctl start NetworkManager-dispatcher.service

Add the user to the network group:

gpasswd -a cenovouser network

Add a rule to allow the networkmanager to use network devices by editing the file /etc/polkit-1/rules.d/50-org.freedesktop.NetworkManager.rules and adding:

polkit.addRule(function(action, subject) {
  if ("org.freedesktop.NetworkManager.") == 0 && subject.isInGroup("network")) {
    return polkit.Result.YES;

Sources / Additional Links