Skip to content

re-ws.pl

ReverseEngineering WorkStation

  • Home
  • Tutorials
  • Random
  • About

Creating one-file Linux distribution with docker

Posted on May 9, 2021 by Kamil (aka. v3l0c1r4pt0r)
linux logo

Few months ago I wrote a tutorial about creating Linux distribution consisting of just busybox as its userspace. In the meantime I worked a bit with docker and it sounded like nice next step in learning docker to automate the process of creating Linux distribution using it. As a result, today I present Linux distribution built with docker and based on my previous tutorial. I called it busy-linux due to it consisting of only busybox at the moment. My plan is to develop it further, most likely for private purposes only, so there might not be much happening in the project, but for sure I want to create dynamically linked variant in the near future, as this is what my use case requires. In the meantime feel free to try it yourself.

Installation

Installation is as simple as copying binary that is available on Github to your EFI partition. If you do not have EFI partition yet, or want to set up new one on other device, I already described the process in my previous article on the matter: Busybox-based Linux distro from scratch (section Preparing new EFI system partition). As soon as you do that, you should already see new entry in your EFI boot manager, or if using default one, you may have to add it manually, which is as simple as:

efibootmgr --create --disk /dev/sdz --part 1 --loader /EFI/linux/linux.efi --label "My Own Linux Distro" --verbose

This is also in mentioned tutorial.

Building

Some people prefer to build things from source, instead of trusting third parties that this third party did things honestly. If you are of those, building with docker is extremely easy. What is more, this process should work all the time, once Dockerfile has been written once. In case of busy-linux, it is just matter of cloning one-file repo from here and calling usual docker build command with arguments of your preference, like tag name:

docker build -t busy-dev

At the end, you should get an image with EFI binary inside, which can be extracted after running the container with:

docker run --detach --name busy-dev -it busy-linux

With container running simple docker cp is enough to have Linux outside:

docker cp busy-dev:/root/busy-linux.efi ./

Afterwards, you can go back to installation section.

Summary

Comparing to manually following steps from my previous tutorial, this method is really fast. What makes it even faster is that docker has built-in caching mechanism, which rebuilds only parts of Dockerfile. In this case I used another feature of modern docker, which is multistage build. Result of this is the fact that only part of the modified stage is rebuilt after any change and obviously all stages that depends on this one. The result is that only small fraction of whole container is built from scratch. Side effect is that final container is reduced in size it requires, but in this case, I am not using this fact in any way, as I am not publishing my container to docker hub, or any other registry.

Posted in UncategorizedTagged busybox, docker, English, hacking, kernel, Linux, PC, UEFi

Post navigation

Reading and programming 93Cx6 EEPROM with Digispark
My small library of KiCAD footprints

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Tags

Android assembly busybox C CAN can-hacking cc-factory cmake compiler docker Dreamspark electronics English gcc hacking hardware JavaCard JCOP kernel KiCAD library Linux PC PCB pinout PKI polski programming Python radio Raspberry Pi Reverse Engineering RTL-SDR SDC SDM SDR smart card software tor tty UART UEFi Windows X.509 Xperia Pro

Recent Posts

  • PHP build for use bundled in Android applications
  • Running graphical apps inside Docker containers
  • Plugin architecture demo for Python projects
  • Authorizing adb connections from Android command line (and making other service calls from cli)
  • How to recover torrent from rtorrent meta files

Recent Comments

  • pomi on Playing with GF-07 GPS device
  • pomi on Playing with GF-07 GPS device
  • Hamdy Abumgata on Playing with GF-07 GPS device
  • Mousum Gogoi on Playing with GF-07 GPS device
  • Eason on Sniffing USB traffic with DSLogic logic analyzer into pcap file

Categories

  • News
  • Random
  • Reversing LKV373A
  • Setting up new v3 Hidden Service with ultimate security
  • Tutorials
  • Uncategorized
  • Understanding JCOP

Links

  • Me @ github
  • LKV373A Wiki
  • DevTomek

Archives

  • December 2024
  • November 2024
  • May 2024
  • July 2023
  • October 2022
  • August 2022
  • July 2021
  • June 2021
  • May 2021
  • December 2020
  • November 2020
  • October 2020
  • August 2020
  • December 2019
  • November 2019
  • October 2019
  • August 2019
  • July 2019
  • February 2019
  • November 2018
  • October 2018
  • June 2018
  • May 2018
  • March 2018
  • February 2018
  • January 2018
  • December 2017
  • November 2017
  • September 2017

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
Proudly powered by WordPress | Theme: micro, developed by DevriX.