All Projects → viralpoetry → Packer Bare Metal

viralpoetry / Packer Bare Metal

Building bare metal OS images with Packer, VirtualBox and qemu-img

Programming Languages

shell
77523 projects

Projects that are alternatives of or similar to Packer Bare Metal

Aros
Main AROS repository for active development. Contains the main Operating System components and Build System.
Stars: ✭ 146 (+26.96%)
Mutual labels:  bare-metal, operating-system
Rust Raspberrypi Os Tutorials
📚 Learn to write an embedded OS in Rust 🦀
Stars: ✭ 7,275 (+6226.09%)
Mutual labels:  bare-metal, operating-system
register-rs
Unified interface for type-safe MMIO and CPU register access in Rust
Stars: ✭ 48 (-58.26%)
Mutual labels:  operating-system, bare-metal
Alchemy
A toy operating system written in Rust.
Stars: ✭ 16 (-86.09%)
Mutual labels:  bare-metal, operating-system
packer-templates
Packer templates for creating Amazon EC2 images, Proxmox templates and Vagrant boxes
Stars: ✭ 70 (-39.13%)
Mutual labels:  packer, operating-system
Gentoo Build
shell scripts that builds systemd based gentoo box for x86_64 platform
Stars: ✭ 24 (-79.13%)
Mutual labels:  bare-metal, packer
Rcore Tutorial Book V3
v3.5 https://rcore-os.github.io/rCore-Tutorial-Book-v3/
Stars: ✭ 102 (-11.3%)
Mutual labels:  operating-system
Jingos
JingOS - The World’s First Linux-based OS design for Tablets
Stars: ✭ 101 (-12.17%)
Mutual labels:  operating-system
Cirnos
Bringing the workflow of Arduino to the Raspberry Pi
Stars: ✭ 101 (-12.17%)
Mutual labels:  bare-metal
Upx Visual Studio
Compile UPX 3.96 and belong librarys on Visual Studio! Source also include LZMA, UCL and zlib ✒️
Stars: ✭ 96 (-16.52%)
Mutual labels:  packer
Tiny Os
《操作系统真象还原》一书实现的系统代码
Stars: ✭ 112 (-2.61%)
Mutual labels:  operating-system
Tofita
🍬 All-new kernel for @GreenteaOS
Stars: ✭ 112 (-2.61%)
Mutual labels:  operating-system
Minios
Simple DIY OS
Stars: ✭ 106 (-7.83%)
Mutual labels:  operating-system
Furikuri
(In dev)furikuri is framework for code protection
Stars: ✭ 103 (-10.43%)
Mutual labels:  packer
Papers Notebook
📄 🇨🇳 📃 论文阅读笔记(分布式系统、虚拟化、机器学习)Papers Notebook (Distributed System, Virtualization, Machine Learning), created by @gaocegege
Stars: ✭ 1,678 (+1359.13%)
Mutual labels:  operating-system
Packer Ubuntu 1804
This build has been moved - see README.md
Stars: ✭ 101 (-12.17%)
Mutual labels:  packer
Snakeware
A free Linux distro with a Python-based userspace
Stars: ✭ 1,514 (+1216.52%)
Mutual labels:  operating-system
Axel
Operating System
Stars: ✭ 96 (-16.52%)
Mutual labels:  operating-system
Puredarwin
Darwin is the Open Source core of macOS, and PureDarwin is a community project to extend Darwin into a complete, usable operating system.
Stars: ✭ 1,592 (+1284.35%)
Mutual labels:  operating-system
Toc
A Table of Contents of all Gruntwork Code
Stars: ✭ 111 (-3.48%)
Mutual labels:  packer

Building bare metal images with Packer, VirtualBox and qemu-img

This repository should demonstrate that it is possible to provision OS with Packer, then create raw disk image that can be booted directly on bare metal.

I am using random Alpine Packer builder from the GitHub (thanks!) because of Alpine small size.

Firstly, run packer build packer_template.json to create VirtualBox OVA archive which contains disk and configuration files.

Then decompress OVA tar archive and convert VMDK to RAW:

$ cd output-virtualbox-iso
$ tar xvf alpine-clean-3.6.1.ova
$ qemu-img convert -f vmdk alpine-clean-3.6.1-disk001.vmdk -O raw alpine-clean-3.6.1.raw

Check that RAW file is actual disk file:

$ fdisk -l alpine-clean-3.6.1.raw
Disk alpine-clean-3.6.1.raw: 2 GiB, 2147483648 bytes, 4194304 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x1de52f32

Device                  Boot   Start     End Sectors  Size Id Type
alpine-clean-3.6.1.raw1 *       2048  206847  204800  100M 83 Linux
alpine-clean-3.6.1.raw2       206848 1255423 1048576  512M 82 Linux swap / Solaris
alpine-clean-3.6.1.raw3      1255424 4194303 2938880  1.4G 83 Linux

Partition offset is 1255424 sectors * 512 bytes per sector, so if you want to mount it, you can use mount command with the appropriate offset:

$ mkdir /tmp/loop
$ sudo mount -o ro,loop,offset=642777088 alpine-clean-3.6.1.raw /tmp/loop
$ mount | grep alpine-clean-3.6.1.raw
alpine-clean-3.6.1.raw on /tmp/loop type ext4 (ro,relatime,data=ordered)

If you want to create bootable USB, make sure that your USB is not mounted. If mounted, use umount command.

$ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
...
sda      8:0    0   477G  0 disk
├─sda1   8:1    0   512M  0 part /boot/efi
├─sda2   8:2    0 460.6G  0 part /
└─sda3   8:3    0  15.9G  0 part
sdb      8:16   1   7.3G  0 disk /media/user/ABCD-EFGH  <--- our mounted USB stick

$ sudo umount /media/user/ABCD-EFGH  

Finally, write raw disk to the USB memory stick

$ sudo dd if=./alpine-clean-3.6.1.raw of=/dev/sdb bs=4k

131072+0 records in
131072+0 records out
536870912 bytes (537 MB, 512 MiB) copied, 139.334 s, 3.9 MB/s

TODO:

  1. Shrink disk image using zerofree / other tools
  2. ?
  3. Profit

Sources:
https://major.io/2010/12/14/mounting-a-raw-partition-file-made-with-dd-or-dd_rescue-in-linux/
https://blog.filippo.io/converting-a-partition-image-to-a-bootable-disk-image/
https://wiki.hackzine.org/sysadmin/kvm-import-ova.html

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