Gentoo Stage 4 Utilities Suite
Find a file
2022-12-15 17:41:36 -05:00
.github/workflows Add compression types and multithread if possible. (#39) 2020-04-17 04:43:11 -04:00
tests Add -i option to include files prior to exclusion (#30) 2020-04-02 22:10:09 -04:00
.gitignore Initial commit 2014-05-18 23:52:33 +02:00
LICENSE Initial commit 2014-05-18 23:52:33 +02:00
mkstage4.sh Updated shebang 2022-12-15 17:41:36 -05:00
README.md Removed xattr-breaking command 2022-12-15 17:19:36 -05:00

mkstage4

CI

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 by Greg Fitzgerald (unmaintained as of 2012) which itself was a revamped edition of the original mkstage4 by Reto Glauser (unmaintained as of 2009).

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:

Installation

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):

git clone https://github.com/TheChymera/mkstage4.git /your/mkstage4/directory
cd /your/mkstage4/directory
chmod +x mkstage4.sh

For Gentoo Linux and Derivatives, mkstage4 is also available in Portage via the base Gentoo overlay. On any Gentoo system, just run the following command:

emerge app-backup/mkstage4

Usage

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!

Archive your current system (mounted at /):

mkstage4 -s archive_name

Archive a system located at a custom mount point:

mkstage4 -t /custom/mount/point archive_name

Command line arguments:

mkstage4.sh [-q -c -b -l -k -p] [-s || -t <target-mountpoint>] [-e <additional excludes dir*>] <archive-filename> [custom-tar-options]
  -q: activates quiet mode (no confirmation).
  -c: excludes connman network lists.
  -b: excludes boot directory.
  -l: excludes lost+found directory.
  -p: compresses parallelly using pbzip2.
  -e: an additional excludes directory (one dir one -e).
  -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 (shows available on runtime and default is bz2)
  -h: displays help message.

System Tarball Extraction

Single-threaded

Tarballs created with mkstage4 can be extracted with:

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

tar xvjpf archive_name.tar.bz2 --xattrs-include='*.*' --numeric-owner

If you use the -k option, extract the src and modules archives separately:

tar xvjpf archive_name.tar.bz2.kmod
tar xvjpf archive_name.tar.bz2.ksrc

Multi-threaded

If you have a parallel de/compressor installed, you can extract the archive with one of the respective commands:

pbzip2

tar -I pbzip2 -xvf archive_name.tar.bz2 --xattrs-include='*.*' --numeric-owner

xz

tar -I 'xz -T0' -xvf archive_name.tar.xz --xattrs-include='*.*' --numeric-owner

gzip

Similarly to other compressors, gzip uses a separate binary for parallel decompression:

tar -I unpigz -xvf archive_name.tar.gz --xattrs-include='*.*' --numeric-owner

Dependencies

Please note that these are very basic dependencies and should already be included in any Linux system.

Optionals: If one the following is installed the archive will be compressed using multiple parallel threads when available, in order of succession:


Released under the GPLv3 license. Project led by Horea Christian (address all correspondence to: chr@chymera.eu).