All Projects → mkaczanowski → Packer Builder Arm

mkaczanowski / Packer Builder Arm

Licence: apache-2.0
Packer plugin to build ARM images

Programming Languages

go
31211 projects - #10 most used programming language

Labels

Projects that are alternatives of or similar to Packer Builder Arm

Furikuri
(In dev)furikuri is framework for code protection
Stars: ✭ 103 (-11.97%)
Mutual labels:  packer
Azops
This container image can be used to deploy ARM templates at Tenant, Management Group, Subscription and Resource Group scope and export current Azure configuration hierarchy in Git repository.
Stars: ✭ 109 (-6.84%)
Mutual labels:  arm
Mmusiccast
Chromecast emulator that works on any platform. Stream videos from youtube to raspberry pi or any computer with the chromecast protocol.
Stars: ✭ 113 (-3.42%)
Mutual labels:  arm
Pyobfx
Python Obfuscator & Packer
Stars: ✭ 106 (-9.4%)
Mutual labels:  packer
Bin2llvm
A binary to LLVM translator
Stars: ✭ 108 (-7.69%)
Mutual labels:  arm
Keystone
Keystone assembler framework: Core (Arm, Arm64, Hexagon, Mips, PowerPC, Sparc, SystemZ & X86) + bindings
Stars: ✭ 1,654 (+1313.68%)
Mutual labels:  arm
Inline Hook
simple inline-hook framework works for x86, x64, arm and thumb
Stars: ✭ 102 (-12.82%)
Mutual labels:  arm
Raspberry Pi Os
Learning operating system development using Linux kernel and Raspberry Pi
Stars: ✭ 11,000 (+9301.71%)
Mutual labels:  arm
Ollydbg Scripts
Unpacking scripts for Ollydbg.
Stars: ✭ 109 (-6.84%)
Mutual labels:  packer
Nailgun
Nailgun attack on ARM devices.
Stars: ✭ 114 (-2.56%)
Mutual labels:  arm
Tensorflow Mtcnn
C++ and python Inference only for MTCNN face detector on Tensorflow. Based on davidsandberg's facenet project:
Stars: ✭ 106 (-9.4%)
Mutual labels:  arm
Jingos
JingOS - The World’s First Linux-based OS design for Tablets
Stars: ✭ 101 (-13.68%)
Mutual labels:  arm
Toc
A Table of Contents of all Gruntwork Code
Stars: ✭ 111 (-5.13%)
Mutual labels:  packer
Jesfs
Jo's Embedded Serial File System (for Standard Serial NOR-Flash)
Stars: ✭ 104 (-11.11%)
Mutual labels:  arm
Arm Vo
Efficient monocular visual odometry for ground vehicles on ARM processors
Stars: ✭ 115 (-1.71%)
Mutual labels:  arm
Bap
Binary Analysis Platform
Stars: ✭ 1,385 (+1083.76%)
Mutual labels:  arm
Peda Arm
GDB plugin peda for arm
Stars: ✭ 110 (-5.98%)
Mutual labels:  arm
Adfs2
Multi Vagrant environment with Active Directory
Stars: ✭ 117 (+0%)
Mutual labels:  packer
Packer Bare Metal
Building bare metal OS images with Packer, VirtualBox and qemu-img
Stars: ✭ 115 (-1.71%)
Mutual labels:  packer
Walter
6DOF Industrial Robot, vintage style
Stars: ✭ 113 (-3.42%)
Mutual labels:  arm

Packer builder ARM

Build Status GoDoc GoReportCard Docker Cloud Build Status Docker Pulls Docker Image Size

This plugin allows you to build or extend ARM system image. It operates in two modes:

  • new - creates empty disk image and populates the rootfs on it
  • reuse - uses already existing image as the base
  • resize - uses already existing image but resize given partition (ie. root)

Plugin mimics standard image creation process, such as:

  • builing base empty image (dd)
  • partitioning (sgdisk / sfdisk)
  • filesystem creation (mkfs.type)
  • partition mapping (losetup)
  • filesystem mount (mount)
  • populate rootfs (tar/unzip/xz etc)
  • setup qemu + chroot
  • customize installation within chroot

The virtualization works via binfmt_misc kernel feature and qemu.

Since the setup varies a lot for different hardware types, the example configuration is available per "board". Currently the following boards are supported (feel free to add more):

  • bananapi-r1 (Archlinux ARM)
  • beaglebone-black (Archlinux ARM, Debian)
  • jetson-nano (Ubuntu)
  • odroid-u3 (Archlinux ARM)
  • odroid-xu4 (Archlinux ARM, Ubuntu)
  • parallella (Ubuntu)
  • raspberry-pi (Archlinux ARM, Raspbian)
  • raspberry-pi-3 (Archlinux ARM (armv8))
  • raspberry-pi-4 (Archlinux ARM (armv7), Ubuntu 20.04 LTS))
  • wandboard (Archlinux ARM)
  • armv7 generic (Alpine, Archlinux ARM)

Quick start

git clone https://github.com/mkaczanowski/packer-builder-arm
cd packer-builder-arm
go mod download
go build

sudo packer build boards/odroid-u3/archlinuxarm.json

Run in Docker

This method is primarily for macOS users where is no native way to use qemu-user-static (or Linux users, who do not want to setup packer and all the tools).

Usage via container from Docker Hub:

docker run --rm --privileged -v /dev:/dev -v ${PWD}:/build mkaczanowski/packer-builder-arm build boards/raspberry-pi/raspbian.json

More system packages (e.g. bmap-tools, zstd) can be added via the parameter -extra-system-packages=...:

docker run --rm --privileged -v /dev:/dev -v ${PWD}:/build mkaczanowski/packer-builder-arm build boards/raspberry-pi/raspbian.json -extra-system-packages=bmap-tools,zstd

Usage via local container build:

Build the container locally:

docker build -t packer-builder-arm -f docker/Dockerfile .

Run packer via the local built container:

docker run --rm --privileged -v /dev:/dev -v ${PWD}:/build packer-builder-arm build boards/raspberry-pi/raspbian.json

Dependencies

  • sfdisk / sgdisk
  • e2fsprogs
  • parted (resize mode)
  • resize2fs (resize mode)
  • qemu-img (resize mode)

Configuration

Configuration is split into 3 parts:

  • remote file config
  • image config
  • qemu config

Remote file

Describes the remote file that is going to be used as base image or rootfs archive (depending on image_build_method)

"file_urls" : ["http://os.archlinuxarm.org/os/ArchLinuxARM-odroid-xu3-latest.tar.gz"],
"file_checksum_url": "http://hu.mirror.archlinuxarm.org/os/ArchLinuxARM-odroid-xu3-latest.tar.gz.md5",
"file_checksum_type": "md5",
"file_unarchive_cmd": ["bsdtar", "-xpf", "$ARCHIVE_PATH", "-C", "$MOUNTPOINT"],
"file_target_extension": "tar.gz",

The file_unarchive_cmd is optional and should be used if the standard golang archiver can't handle the archive format.

Raw images format (.img or .iso) can be used by defining the file_target_extension appropriately.

Image config

The base image description (size, partitions, mountpoints etc).

"image_build_method": "new",
"image_path": "odroid-xu4.img",
"image_size": "2G",
"image_type": "dos",
"image_partitions": [
    {
        "name": "root",
        "type": "8300",
        "start_sector": "4096",
        "filesystem": "ext4",
        "size": "0",
        "mountpoint": "/"
    }
],

The plugin doesn't try to detect the image partitions because that varies a lot. Instead it solely depend on image_partitions specification, so you should set that even if you reuse the image (method = reuse).

Qemu config

Anything qemu related:

"qemu_binary_source_path": "/usr/bin/qemu-arm-static",
"qemu_binary_destination_path": "/usr/bin/qemu-arm-static"

Chroot provisioner

To execute command within chroot environment you should use chroot communicator:

"provisioners": [
 {
   "type": "shell",
   "inline": [
     "pacman-key --init",
     "pacman-key --populate archlinuxarm"
   ]
 }
]

This plugin doesn't resize partitions on the base image. However, you can easily expand partition size at the boot time with a systemd service. Here you can find real-life example, where a raspberry pi root-fs partition expands to all available space on sdcard.

Flashing

To dump image on device you can use custom postprocessor (really wrapper around dd with some sanity checks):

"post-processors": [
 {
     "type": "flasher",
     "device": "/dev/sdX",
     "block_size": "4096",
     "interactive": true
 }
]   

Other

Generating rootfs archive

While image (.img) format is useful for most cases, you might want to use rootfs for other purposes (ex. export to docker). This is how you can generate rootfs archive instead of image:

"image_path": "odroid-xu4.img" # generates image
"image_path": "odroid-xu4.img.tar.gz" # generates rootfs archive

Resizing image

Currently resizing is only limited to expanding single ext{2,3,4} partition with resize2fs. This is often requested feature where already built image is given and we need to expand the main partition to accomodate changes made in provisioner step (ie. installing packages).

To resize a partition you need to set image_build_method to resize mode and set selected partition size to 0, for example:

"builders": [
  {
    "type": "arm",
    "image_build_method": "resize",
    "image_partitions": [
      {
        "name": "boot",
        ...
      },
      {
        "name": "root",
        "size": "0",
        ...
      }
    ],
    ...
  }
]

Complete examples:

Docker

With artifice plugin you can pass rootfs archive to docker plugins

"post-processors": [
    [{
        "type": "artifice",
        "files": ["rootfs.tar.gz"]
    },
    {
        "type": "docker-import",
        "repository": "mkaczanowski/archlinuxarm",
        "tag": "latest"
    }],
    ...
]

CI/CD

This is the live example on how to use github actions to push image to docker image registry:

cat .github/workflows/archlinuxarm-armv7-docker.yml

How is this plugin different from solo-io/packer-builder-arm-image

https://github.com/hashicorp/packer/pull/8462

Examples

For more examples please see:

tree boards/

Troubleshooting

Many of the reported issues are platform/OS specific. If you happen to have problems, the first question you should ask yourself is:

Is my setup faulty? or is there an actual issue?

To answer that question, I'd recommend reproducing the error on the VM, for instance:

cd packer-builder-arm
vagrant up
vagrant provision

Note: For this the disksize plugin is needed if not already installed vagrant plugin install vagrant-disksize

Demo

asciicast

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].