TL; DR You can fit a full-fledged Linux Live distribution in one file, if you compile into the kernel initramfs with the root file system. Computers with UEFI can download such a file directly, without the help of a GRUB loader. I managed to fit the distribution with the programs
aircrack-ng, reaver and drivers for Wi-Fi cards in a file of
12 megabytes in size (you can probably use even less).
Main advantages
- It works on any computers with UEFI - the same file will work on PC and Mac.
- No installation required - just copy one file to the EFI partition and specify the path to this file in NVRAM variables.
- No need to install GRUB loaders, rEFInd - Linux kernel compiled with EFI support Stub can be loaded directly without an intermediate loader.
- No USB flash drives needed - the distribution kit copied to the EFI partition remains there forever, and it can be downloaded at any time. It does not occupy space on the main system partition, since the EFI partition is not used in the OS.
- Does not change the boot process - the system can be booted once, without changing the boot order in the UEFI settings. The next computer restart will load the normal operating system. No trace of Linux in the boot sequence will remain.
- Compatible with FileVault disk encryption, etc. - The file is copied to the EFI System Partition, a special reserved disk partition. On Macs, its size is about 200 megabytes. It is dedicated to Boot Camp and is not normally used.
Why do you need it?
For all cases when you need a native Linux without a virtual machine.
To use PCIe devices in Linux, when they can not be thrown into a virtual machine. For example, a built-in Wi-Fi card for packet injection. When lazy to install a virtual machine and download a large ISO file with the distribution. When you do not want to mess with USB flash drives.
Once the file is copied, it will always allow you to have a Linux distribution at hand that will survive even a reinstallation of the system.
')
Mac Installation Instructions
All commands need to run from macOS.
BootCamp, rEFInd, and any other non-standard configurations do not matter if the boot configuration does not matter. Mac computers no older than 2009 are supported (performance on older ones has not been verified, but it can earn).
- Download OneFileLinux.efi file (20 megabytes)
- Mount EFI-partition in the system.
diskutil mount disk__
You can find out the EFI partition number using the diskutil list command.

In my case, the command will look like this:
diskutil mount disk0s1
- Copy OneFileLinux.efi to EFI section
cp ~/Downloads/OneFileLinux.efi /Volumes/EFI/
- Add boot option to NVRAM
bless --mount /Volumes/EFI --setBoot --nextonly --file /Volumes/EFI/OneFileLinux.efi
The nextonly option means that this boot option will be executed once. The next reboot will restore the previous settings. Therefore, to return from Linux to macOS, just reboot again.
The latest versions of macOS, starting with El Capitan, use System Integrity Protection (SIP) technology, the so-called “no root mode”. This technology prohibits the modification of system files and variables, even the superuser. SIP is enabled by default, so the last bless command will return an error. It can be done from the Recovery Mode. To do this, hold down cmd + R when you turn on the computer and open the console
Utilities -> Terminal . In the console, perform steps 2 and 4. Commands in the Recover console need to be entered without sudo .
Now, every time you need to download OneFileLinux.efi, it’s enough to perform steps 2 and 4 in the Recovery console, or from the main system if SIP is turned off.
You can probably do bless without mounting the partition, but I didn’t find how to do it. Then one command would be enough.PC instructions
Download options on the PC set. If your motherboard has a built-in UEFI Shell, it is enough to specify the path to the OneFileLinux.efi file in it to boot into Linux once. I will describe the setup process on my Thinkpad X220.
- Download OneFileLinux.efi and put it on the EFI partition
- Add download option to NVRAM
efibootmgr --disk /dev/sda --part 2 --create --label "One File Linux" --loader /OneFileLinux.efi
- During boot, press F12 and select the desired option.

Assembly instructions from source
Project sources
github.com/zhovner/OneFileLinuxThe distribution is built on a clean kernel
4.16-rc1 with kernel.org and the Alpine Linux
Mini Root filesystem .
It can be easily assembled by yourself.
Preparing initramfs
Initramfs is a disk image that is mounted in memory when the kernel boots. In regular distributions it contains the drivers required at an early stage of loading. You can put a full root file system into it.
I used the root filesystem from Alpine Linux. This is a minimalistic distribution for embedded systems and containers. It has a delivery option without a kernel and pre-installed programs, only the root file system based on busybox and the package manager
apk .
chroot-name alpine linux:
chroot ./alpine-minirootfs /bin/ash
Being inside the environment, you can make the necessary changes. Add packages via “apk add”, modify services using openrc.
All the necessary information is in the
wiki .
Assembly
Run the build script. It will assemble the kernel modules, put them in the initramfs, and assemble the kernel.
./build.sh
Help !! 111
At the moment, the distribution is pretty curved. If you know Linux, I will be very grateful for any help. It will be cool if you can finish this project to an acceptable level.
Known issues:
Loading of kernel modules is disabled - all drivers are compiled into the kernel.
Probably the right way to make them separate modules and put in the initramfs
✓ FixedFonts on HiDPI displays - due to the huge resolution of HiDPI screens,
standard 8x16 fonts look very fine. I compiled a 16x32 font that looks fine with a high pixel density, but too large for regular screens. In a good way, the font should be selected depending on the screen resolution.
✓ Fixed. Now a large font for HiDPI screens is automatically selected. You can also change the font size at any time with the fontsize command.Only one WiFi card driver - now one driver is compiled for the Broadcom 43602 adapter embedded in MacBooks. In an amicable way, you need to assemble all the popular drivers as kernel modules, as well as firmware for them.
✓ Fixed. Added support for many popular WiFi adapters.Is udev / mdev broken? - I do not know how it works. How to load modules depending on the hardware configuration?
✓ Fixed- Garbage - now a large number of outdated drivers are being installed along with the kernel. Uncompressed kernel modules weigh over 100 megabytes. Most of them can be excluded.
I invite everyone to commit and create issues about problems
github.com/zhovner/OneFileLinux .