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 files either for the running system, or for a system at a specified mount point.

Gentoo Stage 4 files are used to provide the user with a fully built Gentoo system within an archive, which can be installed similarly to a stage 3 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
app-backup/mkstage4 ~amd64


Install with the following command:

root #emerge --ask app-backup/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.


root #mkstage4 -h
	mkstage4 [-b -c -k -l -q] [-C <compression-type>] [-s || -t <target-mountpoint>] [-e <additional excludes dir*>] [-i <additional include target>] <archive-filename> [custom-tar-options]
	-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: 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, do not 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 file — an archive containing a minimal Gentoo environment, typically serving as a seed for a Gentoo install.

External references