Skip to content

Commit

Permalink
Merge branch 'master' of github.com:zhovner/OneFileLinux
Browse files Browse the repository at this point in the history
  • Loading branch information
zhovner committed Mar 4, 2018
2 parents 6b56e21 + b88300e commit e749fb7
Showing 1 changed file with 105 additions and 46 deletions.
151 changes: 105 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,77 +1,136 @@
## One File Linux
<img width=700 alt="One File Linux" src="https://habrastorage.org/webt/yo/oo/1e/yooo1e0i2u4frjrlhnmtqifmpsy.png" />
Live linux distro combined in one ~20MB file. Runs on any UEFI computer (PC or Mac) without installation. Just copy one file to EFI system partition and boot.

Live linux distro combined in one EFI file.
<img width=600 alt="One File Linux" src="https://hub.zhovner.com/img/one-file-linux.png" />

Download here https://github.com/zhovner/OneFileLinux/releases
**Download:** https://github.com/zhovner/OneFileLinux/releases

More information in russian https://habrahabr.ru/post/349758/
About in russian: https://habrahabr.ru/post/349758/
### Main advantages

## Install on Mac
* **No installation required** — no need to create additional paritions. Just copy one file to EFI system partition and add new boot entry to NVRAM.

* **No USB flash needed** — once copied to EFI partition, OneFileLinux can boot any time from system disk.

* **No Boot Manager required (GRUB, rEFInd)** — boots directly by UEFI firmware, no additional software needed.

* **Doesn't change the boot sequence** — can boot only once, next reboot will return default settings.

* **Compatible with disk encryption** — works with macOS FileVault and dm-crypt. Because EFI system parition is not encrypted.

### 1. Mount EFI System Partition
```
diskutil mount disk_NUMBER
```
To find out EFI partition disk number use `diskutil list`
<img src="https://habrastorage.org/webt/_y/h2/j5/_yh2j5hz9dqthcegf5sebnmxmui.png" width="500">
### Why?

The command is as follows in my case:
```
diskutil mount disk0s1
```
This can be useful when you need Linux on bare metal and can't use USB flash. In comparison with Live USB flash, one file Linux setups permanently in EFI partition and can boot any time later.
My personal goal is to use laptop's internal PCIe WiFi card for cracking WiFi with <b>aircrack-ng</b> and <b>reaver</b> software, since PCIe devices can't be forwarded into virtual machine.

### 2. Copy OneFileLinux.EFI to EFI Partiotion
`cp ~/Downloads/OneFileLinux.efi /Volumes/EFI`
## Run on Macbook

#### 1. Download OneFileLinux.efi from link above.



### 3. Set NVRAM to boot linux once
`sudo bless --mount /Volumes/EFI --setBoot --nextonly --file /Volumes/EFI/OneFileLinux.efi`
#### 2. Mount EFI System Partition

This command will boot linux only once. Next reboot will return previous boot sequence.
`diskutil mount diskN`

**!!!** Note that System Integrity Protection (SIP) prohibits to change boot options.
You can run `bless` from Recover Mode console. Press CMD+R while power on and go to "Utilities —> Terminal"
where diskN is your EFI disk number.
To find your EFI disk number use `diskutil list` command.

<img width="500" alt="macOS diskutil list EFI partition" src="https://hub.zhovner.com/img/diskutil-list-efi.png" />

## Install on PC
For me it will be: `diskutil mount disk0s1`

If your motherboard has UEFI Shell, just choose the path to OneFileLinux.efi on ESP.
Otherwise add new boot options to NVRAM and choose it from boot menu.



#### 3. Copy OneFileLinux.efi to EFI partition

`cp ~/Downloads/OneFileLinux.efi /Volumes/EFI/`

Example for ThinkPad x220


#### 4. Set boot option in NVRAM

### 1. Copy OneFileLinux.efi to EFI Partition
On macOS since El Capitan enabled by default SIP (System Integrity Protection) prohibits to change boot options.
To check SIP state run `csrutil status`. In normal situation it should be enabled.

If SIP is enabled you can run `bless` only from Recovery console, otherwise it returns error.
To boot in Recovery mode press <b>CMD+R</b> while boot and go to **_Utilities —> Terminal_** from top menu.
In recovery console follow steps 2 and 4 every time you need to boot OneFileLinux.

### 2. Add NVRAM entry
`bless --mount /Volumes/EFI --setBoot --nextonly --file /Volumes/EFI/OneFileLinux.efi`


This command sets NVRAM option to boot OneFileLinux.efi only once. Next reboot will return default boot order.



### 5. Reboot

Reboot to run OneFileLinux. Once you've done, type `reboot` in Linux console and go back to macOS.
Every time when you need it again, follow steps 2 and 4 from recovery console.



## Run on PC
There are few ways how to run OneFileLinux on PC motherboard. Some motherboards have builtin UEFI Shell that can run any efi binary from console.
I will describe setup process for my old ThinkPad X220 that doesn't have UEFI shell.

#### 1. Copy OneFileLinux.efi to EFI partition

If you use Windows 10 installed in EFI mode, you have EFI system partition 100 MB in size.
You need to find out how to mount by itself. You can do this with OneFileLinux.efi run from USB flash or any other linux distro.


#### 2. Add NVRAM boot option

I can't find out how to do this in Windows, so you probably need Linux for this.
Replace `/dev/sda` to you disk path and `--part 2` to your EFI partition number.

`efibootmgr --disk /dev/sda --part 2 --create --label "One File Linux" --loader /OneFileLinux.efi`

### 3. Choose new entry from boot menu
Press F12 while power on and choose new boot entry
#### 3. Choose One File Linux from boot menu

On my ThinkPad X220 I press F12 while power on to open boot menu. Hotkey depends on your motherboard.

<img alt="ThinkPad X220 boot menu" width="600" src="https://hub.zhovner.com/img/thinkpad-x220-boot-menu.png" />



## Run from USB flash
The only benefit from running OneFileLinux from USB flash, is that no additional software is required to create bootable flash drive.
Just format flash drive as FAT32 in GPT scheme and copy OneFileLinux.efi to default path:

`\EFI\BOOT\BOOTx64.EFI`

![Thinkpad x220 boot menu](https://habrastorage.org/webt/wv/6f/tm/wv6ftmykf6wncgtkzx7chiiz-cm.png)

#### Format in GPT scheme in Windows

## Building
This project is based on vanilla linux kernel `4.16-rc1`
and Alpine Linux Minimal root filesystem https://alpinelinux.org/downloads/
Windows does not allow to format flash drive in GPT scheme from GUI, so you need to use command line tool.
1. Open `cmd.exe` as administrtor
2. Type`diskpart`
3. `list disk` to see all disks
4. `select disk <disknumber>`
5. `clean` do delete parition table
6. `convert gpt` to convert disk in GPT scheme
7. `exit`

### Download kernel
Then format drive from `diskmgmt.msc` in FAT32.

`https://git.kernel.org/torvalds/t/linux-4.16-rc1.tar.gz` and extract it to `linux-4.16-rc1`
This repository contatins `linux-4.16-rc1/.config` file with kernel config.

### Edit root filesystem

Chroot into root filesystem
`chroot ./alpine-minirootfs /bin/ash`
## Build your own

Edit what you need. Install packages with `apk` packet manager.
You can build your own version of One File Linux.
It based on Alpine Linux and vanilla kernel.

1. Clone repositry
`git clone https://github.com/zhovner/OneFileLinux`

### Build
2. Make changes in root filesystem and kernel
`chroot alpine-minirootfs /bin/ash`

Run bulding script
```
./build.sh
```
3. Build
`./build.sh`

0 comments on commit e749fb7

Please sign in to comment.