From Gentoo Wiki
Jump to:navigation Jump to:search
This article is a stub. Please help out by expanding it - how to get started.

mkstage4 is a Bash script to create stage 4 tarballs either for the running system, or for a system at a specified mount point.

Gentoo Stage 4 tarballs are used to provide the user with a fully built Gentoo system within a tarball, which can be installed similarly to a Stage 3 archive however with a greatly less amount of effort, time and steps.


To install mkstage4, the app-backup/mkstage4 package may need unmasking. This may not apply for all systems depending on prior-use and configuration.

To unmask, add the following to a file:

FILE /etc/portage/package.accept_keywords/mkstage4How to unmask the mkstage4 package


Install with the following command:

root #emerge --ask mkstage4


To produce a Stage 4 archive of the current system using mkstage4:

root #mkstage4 -s <name>

This will create a Stage 4 archive of all files under / (current root partition). Similarly, to specify a different location to make a Stage 4 archive of:

root #mkstage4 -t /custom/mount/point <name>

If using a smaller storage device, or just wish to not fill up internal storage, specify writing the Stage 4 tarball to a different partition/drive using:

root #cd <destination directory>
root # mkstage4 -s <name>

This will write the Stage 4 archive to the destination directory.


user $mkstage4 --help
	-b: excludes boot directory.
	-c: excludes some confidential files (currently only .bash_history and connman network lists).
	-k: separately save current kernel modules and src (creates smaller archives and saves decompression time).
	-l: excludes lost+found directory.
	-q: activates quiet mode (no confirmation).
	-C: specify tar compression (default: bz2, available: lz4 xz bz2 zst gz).
	-s: makes tarball of current system.
	-t: makes tarball of system located at the <target-mountpoint>.
	-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.
	-h: displays help message.

See also

  • Stage tarball — an archive of the basic files and packages used for the installation of Gentoo Linux.

External references