This is an old revision of the document!


HowTo create your own (RaspberryPi) image file

It is written based upon how it works for the RPiv1, basically all archlinux images should follow the same concepts. You only need the correct Archlinux.tar file and qemu kernel file. The scripts that help during the creation can be found on the Github: arch_rpi_image_prepare.

Software Requirements

  • qemu with support for armv6 (for raspberry emulation)
  • workin “sudo” environment
  • losetup from util-linux 2.2 (at least)
  • mkfs.vat
  • mkfs.ext4
  • wget
  • fdisk
  • git

Create the basic Image file

Choose a working directory

 mkdir -p ~/tmp
 cd ~/tmp
 git clone https://github.com/PirateBox-Dev/arch_rpi_image_prepare.git
 cd  arch_rpi_image_prepare/
  

Get latest service & motd file

  cd staging_packages
  wget https://raw.githubusercontent.com/PirateBox-Dev/PirateBoxScripts_Webserver/master/BuildScripts/piratebox.service    
  wget https://raw.githubusercontent.com/PirateBox-Dev/PirateBoxScripts_Webserver/master/BuildScripts/RPi_motd.txt

Prepare Bootstrap image, which runs the emulation. That image will be created based upon the latest archlinux-armv6 file

   make create_arch_image

Create an installation qemu image

Create a woring qemu image once (only needed on first setup).

  cd qemu-arm-rpi
  cp ../raw_arch_image_file  install_qemu_image

Now you need X. Startup the qemu instance. it will mount the raw_arch_image_file as a 2nd device.

  ./run_qemu.sh

HINT: The emulation may have a different keyboard setting. The first bootup usually fails, because the fstab is not correct. After the bootup failed, login in maintenance mode using root-password “root”, then run the following command:

  echo "" > /etc/fstab
  reboot

Prepare the imagefile for distribution

(Re)Start the emulation:

  ./run_qemu.sh

After bootup, login using username: root ; password: root

HINT: To leave the emulation with the mouse, press CTRL+ALT

Enable network inside the emulation

  dhcpcd eth0

Start prepare the image..

  sh /prebuild/staging/install_packages.sh

As there is currently no pacman Package for PirateBox run:

  pacman --noconfirm -r /mnt/image -S   python2 lighttpd bash iw hostapd dnsmasq bridge-utils avahi wget wireless_tools netctl perl iptables zip unzip cronie net-tools
  # for development version of PirateBox & LibraryBox additional packages:  pacman --noconfirm -r /mnt/image -S  radvd proftpd php php-cgi php-sqlite lftp imagemagick php-gd

Further configuration of the image file

Prepare for chroot into the environment

  mount -o bind /run /mnt/image/run
  mount -o bind /dev /mnt/image/dev
  mount -o bind /proc /mnt/image/proc

Change root environment….

  chroot /mnt/image /bin/bash

Do customization for running PirateBox

  systemctl enable sshd
  ln /usr/bin/python2 /usr/bin/python
  cd root
  wget http://downloads.piratebox.de/piratebox-ws_current.tar.gz
  tar xzf piratebox-ws_current.tar.gz
  cp -rv piratebox/piratebox /opt
  groupadd nogroup && usermod -a -G nogroup nobody
  /opt/piratebox/bin/install_piratebox.sh  /opt/piratebox/conf/piratebox.conf  part2
  /opt/piratebox/bin/install_piratebox.sh  /opt/piratebox/conf/piratebox.conf imageboard
  cp /prebuild/staging/piratebox.service  /etc/systemd/system 
  cp /prebuild/staging/RPi_motd.txt /etc/motd

leave chroot environment

  exit

Do some cleanup on the image file

  pacman --noconfirm -r /mnt/image -Scc

Tidy up and exit the qemu-vm

  umount -R /mnt/image
  reboot

Then pack the file

  zip -9 <zip filename> raw_arch_image_file

Troubleshooting

If you encounter the following error

  /dev/loop0p1: No such file or directory
  Makefile:65: recipe for target 'format_p1' failed

Then do

  make free_lo

Then try again… sometimes the kernel isn't fast enough on the first try…