gen2stage4/README.md

159 lines
7.2 KiB
Markdown
Raw Normal View History

2017-03-22 11:01:02 -04:00
# mkstage4
2014-05-18 17:52:33 -04:00
![CI](https://github.com/TheChymera/mkstage4/workflows/CI/badge.svg)
2019-03-18 10:53:49 -04:00
This is a Bash script to create stage 4 tarballs either for the running system, or a system at a specified mount point.
The script was inspired by an earlier [mkstage4 script](https://github.com/gregf/bin/blob/master/mkstage4) by Greg Fitzgerald (unmaintained as of 2012) which itself was a revamped edition of the [original mkstage4](http://blinkeye.ch/dokuwiki/doku.php/projects/mkstage4) by Reto Glauser (unmaintained as of 2009).
2014-05-18 17:52:33 -04:00
2020-02-04 23:02:12 -05:00
More information on mkstage4 can be found on the following blogs, though instructions may be outdated compared to the current version, best documented by this `README` file:
* English: [mkstage4 - Stage 4 Tarballs Made Easy](http://tutorials.chymera.eu/blog/2014/05/18/mkstage4-stage4-tarballs-made-easy/).
2018-05-11 00:27:22 -04:00
2017-03-22 11:01:02 -04:00
## Installation
2014-09-18 02:18:20 -04:00
The script can be run directly from its containing folder (and thus, is installed simply by downloading or cloning it from here - and adding run permissions):
2014-05-18 17:52:33 -04:00
```bash
2014-05-18 17:59:40 -04:00
git clone https://github.com/TheChymera/mkstage4.git /your/mkstage4/directory
2014-05-18 17:52:33 -04:00
cd /your/mkstage4/directory
chmod +x mkstage4.sh
```
2019-08-02 11:28:43 -04:00
For [Gentoo Linux](http://en.wikipedia.org/wiki/Gentoo_linux) and [Derivatives](http://en.wikipedia.org/wiki/Category:Gentoo_Linux_derivatives), mkstage4 is also available in [Portage](http://en.wikipedia.org/wiki/Portage_(software)) via the base Gentoo overlay.
On any Gentoo system, just run the following command:
```bash
emerge app-backup/mkstage4
```
2014-09-18 02:18:20 -04:00
2017-03-22 11:01:02 -04:00
## Usage
2014-09-18 02:18:20 -04:00
2016-02-19 15:23:40 -05:00
*If you are running the script from the containing folder (first install method) please make sure you use the `./mkstage4.sh` command instead of just `mkstage4`!*
Note that the extension will automatically be appended to the `archive_name` string based on the compression type, which can be specifiled via the `-C` parameter, if another compression than the default (`.tar.bz2`) is desired.
### Examples
2014-05-18 17:52:33 -04:00
Archive your current system (mounted at /):
```bash
mkstage4 -s archive_name
2014-05-18 17:52:33 -04:00
```
2020-02-04 23:02:12 -05:00
Archive a system located at a custom mount point:
2014-05-18 17:52:33 -04:00
```bash
mkstage4 -t /custom/mount/point archive_name
2014-05-18 17:52:33 -04:00
```
### Command line arguments
2014-05-18 17:52:33 -04:00
2020-08-31 19:47:47 -04:00
```console
usage:
mkstage4 [-q -c -b -l -k] [-s || -t <target-mountpoint>] [-e <additional excludes dir*>] [-i <additional include target>] <archive-filename> [custom-tar-options]
-q: activates quiet mode (no confirmation).
-c: excludes some confidential files (currently only .bash_history and connman network lists).
-b: excludes boot directory.
-l: excludes lost+found directory.
-e: an additional excludes directory (one dir one -e, donot use it with *).
-i: an additional target to include. This has higher precedence than -e, -t, and -s.
-s: makes tarball of current system.
-k: separately save current kernel modules and src (creates smaller archives and saves decompression time).
-t: makes tarball of system located at the <target-mountpoint>.
-C: specify tar compression (default: bz2, available: lz4 xz bz2 zst gz).
-h: displays help message.
2016-02-23 00:38:51 -05:00
```
2014-05-18 17:52:33 -04:00
2020-08-31 19:32:51 -04:00
## System Tarball Extraction
2022-12-15 17:41:42 -05:00
### Automatic (Multi-threaded)
We provide a script for convenient extraction, `exstage4`, which is shipped with this package.
Currently it simply automates the Multi-threaded extraction selection listed below and otherwise has no functionality except checking that the file name looks sane.
If in doubt, use one of the explicit extraction methods described below.
### Explicit Single-threaded
2014-05-18 17:52:33 -04:00
Tarballs created with mkstage4 can be extracted with:
2020-02-04 23:08:50 -05:00
To preserve binary attributes and use numeric owner identifiers (considered good practice on Gentoo), you can simply append the relevant flags to the respective `tar` commands, e.g.:
```bash
tar xvjpf archive_name.tar.bz2 --xattrs-include='*.*' --numeric-owner
```
2020-08-31 19:46:24 -04:00
If you use the `-k` option, extract the `src` and modules archives separately:
2018-05-11 00:27:22 -04:00
```bash
tar xvjpf archive_name.tar.bz2.kmod
tar xvjpf archive_name.tar.bz2.ksrc
```
2022-12-15 17:41:42 -05:00
### Explicit Multi-threaded
2020-08-31 19:32:51 -04:00
2020-08-31 19:30:09 -04:00
If you have a parallel de/compressor installed, you can extract the archive with one of the respective commands:
2020-08-31 19:32:51 -04:00
#### `pbzip2`
```bash
tar -I pbzip2 -xvf archive_name.tar.bz2 --xattrs-include='*.*' --numeric-owner
```
2020-08-31 19:32:51 -04:00
#### `xz`
2020-02-04 23:02:12 -05:00
```bash
tar -I 'xz -T0' -xvf archive_name.tar.xz --xattrs-include='*.*' --numeric-owner
```
2020-08-31 19:32:51 -04:00
#### `gzip`
2020-08-31 19:30:09 -04:00
Similarly to other compressors, `gzip` uses a separate binary for parallel decompression:
```bash
tar -I unpigz -xvf archive_name.tar.gz --xattrs-include='*.*' --numeric-owner
```
2017-03-22 11:01:02 -04:00
## Dependencies
2014-05-18 17:52:33 -04:00
*Please note that these are very basic dependencies and should already be included in any Linux system.*
* **[Bash](https://en.wikipedia.org/wiki/Bash_(Unix_shell))** - in [Portage](http://en.wikipedia.org/wiki/Portage_(software)) as **[app-shells/bash](https://packages.gentoo.org/packages/app-shells/bash)**
* **[tar](https://en.wikipedia.org/wiki/Tar_(computing))** - in Portage as **[app-arch/tar](https://packages.gentoo.org/packages/app-arch/tar)**
* **[bzip2](https://gitlab.com/federicomenaquintero/bzip2)** - in Portage as **[app-arch/bzip2](https://packages.gentoo.org/packages/app-arch/bzip2)** (single thread, default compression)
**Optionals**:
*If one the following is installed the archive will be compressed using multiple parallel threads when available, in order of succession:*
* `-C xz`:
* **[xz](https://tukaani.org/xz/)** - in Portage as **[app-arch/xz](https://packages.gentoo.org/packages/app-arch/xz-utils)**, (parallel)
* **[pixz](https://github.com/vasi/pixz)** - in Portage as **[app-arch/pixz](https://packages.gentoo.org/packages/app-arch/pixz)**, (parallel, indexed)
* `-C bz2`:
* **[pbzip2](https://launchpad.net/pbzip2/)** - in Portage as **[app-arch/pbzip2](https://packages.gentoo.org/packages/app-arch/pbzip2)**, (parallel)
* **[lbzip2](https://github.com/kjn/lbzip2/)** - in Portage as **[app-arch/lbzip2](https://packages.gentoo.org/packages/app-arch/lbzip2)**, (parallel, faster and more efficient)
* `-C gz`:
* **[gzip](https://www.gnu.org/software/gzip/)** - in Portage as **[app-arch/gzip](https://packages.gentoo.org/packages/app-arch/gzip)**, (single thread)
* **[pigz](https://www.zlib.net/pigz/)** - in Portage as **[app-arch/pigz](https://packages.gentoo.org/packages/app-arch/pigz)**, (parallel)
* `-C lrz`:
* **[lrzip](https://github.com/ckolivas/lrzip/)** - in Portage as **[app-arch/lrzip](https://packages.gentoo.org/packages/app-arch/lrzip)**, (parallel)
* `-C lz`:
* **[lzip](https://www.nongnu.org/lzip/)** - in Portage as **[app-arch/lzip](https://packages.gentoo.org/packages/app-arch/lzip)**, (single thread)
* **[plzip](https://www.nongnu.org/lzip/plzip.html)** - in Portage as **[app-arch/plzip](https://packages.gentoo.org/packages/app-arch/plzip)**, (parallel)
2019-11-03 15:17:17 -05:00
* `-C lz4`:
* **[lz4](https://github.com/lz4/lz4)** - in Portage as **[app-arch/lz4](https://packages.gentoo.org/packages/app-arch/lz4)**, (parallel)
2019-11-03 15:17:17 -05:00
* `-C lzo`:
* **[lzop](https://www.lzop.org/)** - in Portage as **[app-arch/lzop](https://packages.gentoo.org/packages/app-arch/lzop)**, (parallel)
2014-05-18 17:52:33 -04:00
* `-C zstd`:
* **[zstd](https://facebook.github.io/zstd/)** - in Portage as **[app-arch/zstd](https://packages.gentoo.org/packages/app-arch/zstd)**, (parallel)
2014-05-18 17:52:33 -04:00
---
2014-05-18 17:52:33 -04:00
Released under the GPLv3 license.
2019-04-26 18:20:33 -04:00
Project led by Horea Christian (address all correspondence to: chr@chymera.eu).