This is a template that is used as part of the Installation instructions, to describe the process of partitioning and filesystem creation. Templates are being used to allow multiple variant install guides that use most of the same re-usable parts.
Prepare Hard Disk
Funtoo Linux fully supports traditional MBR partitions, as well as newer GPT/GUID partition formats. See below to determine which partitioning scheme to use:
- Recommended if your system disk is <=2TB in size
- Legacy, DOS partitioning scheme
- Only 4 primary partitions per disk; after that, you must use "logical" partitions
- Does not support 2 TB+ disks for booting
- Compatible with certain problematic systems (such as the HP ProBook 4520)
- Dual-boot with Windows for BIOS systems (Windows handle GPT only on true EFI systems, whatever version it is)
- Multiple boot loader options, e.g. GRUB 2, GRUB Legacy, lilo
Due to the fact that it is more widely supported on PC hardware, it is best to use MBR partitions if possible.
- Recommended if your disk is >2TB in size
- Newer format for Linux systems
- Supports 2 TB+ hard drives for booting
- Supports hundreds of partitions per disk of any size
- Requires legacy BIOS boot partition (~32 MB) to be created if system does not use EFI
- Requires bootloader with support for GPT such as GRUB 2, EXTLINUX, or a patched version of GRUB Legacy
If you have a system disk that is 2TB or greater and want to use the space beyond 2TB, you must partition using the GPT/GUID format. Otherwise, MBR is recommended as the most reliable boot method.
Advanced users may be interested in the following topics:
- GUID Booting Guide
- LVM Install Guide
- Rootfs over encrypted lvm
- Rootfs over encrypted lvm over raid-1 on GPT
- NEW! ZFS Install Guide (Also contains instructions for Rootfs over Encrypted ZFS!)
Below are our partitioning recommendations in table form. For MBR-based partitions, use the MBR Block Device and MBR code columns with
fdisk. For GPT-based partitions, use the GPT Block Device and GPT Code columns with
|Partition||Size||MBR Block Device (
||GPT Block Device (
||Filesystem||MBR Code||GPT Code|
|GRUB boot loader partition||1 MB||not required for MBR||
||For GPT/GUID only, skip for MBR - no filesystem.||N/A||EF02|
|swap||2x RAM for low-memory systems and production servers; otherwise 2GB.||
||Rest of the disk, minimum of 10GB. Note: to compile the
||XFS recommended, alternatively ext4||83||8300|
||User storage and media. Typically most of the disk.||
||XFS recommended, alternatively ext4||83||8300|
|LVM (optional)||If you want to create an LVM volume.||
Partitioning Using fdisk (MBR)
These install instructions assume you are installing Funtoo Linux to an hard disk using Master Boot Record partition tables (MBR). If you are installing Funtoo Linux on a machine where another OS is installed, there is an existing Linux distribution on your system that you want to keep or any other scenario (such as differing swap size requirements), then you will need to adapt these instructions to suit your needs.
fdisk is the tool used to create an MBR partition table. MBR is well-supported on PCs and is recommended if your system disk is 2TB or smaller.
First, it's a good idea to make sure that you've found the correct hard disk to partition. Try this command and verify that
/dev/sda is the disk that you want to partition:
# fdisk -l /dev/sda Disk /dev/sda: 640.1 GB, 640135028736 bytes, 1250263728 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: gpt # Start End Size Type Name 1 2048 1250263694 596.2G Linux filesyste Linux filesystem
Now, it's recommended that you erase any existing MBR or GPT partition tables on the disk, which could confuse the system's BIOS at boot time. We do this using
This will make any existing partitions inaccessible! You are strongly cautioned and advised to backup any critical data before proceeding.
# sgdisk --zap-all /dev/sda Creating new GPT entries. GPT data structures destroyed! You may now partition the disk using fdisk or other utilities.
This output is also nothing to worry about, as the command still succeded:
*************************************************************** Found invalid GPT and valid MBR; converting MBR to GPT format in memory. ***************************************************************
Now we will use
fdisk to create the MBR partition table and partitions:
# fdisk /dev/sda
fdisk, follow these steps:
Empty the partition table:
Command (m for help): o ↵
Create Partition 1 (boot):
Command (m for help): n ↵ Partition type (default p): ↵ Partition number (1-4, default 1): ↵ First sector: ↵ Last sector: +128M ↵
Create Partition 2 (swap):
Command (m for help): n ↵ Partition type (default p): ↵ Partition number (2-4, default 2): ↵ First sector: ↵ Last sector: +2G ↵ Command (m for help): t ↵ Partition number (1,2, default 2): ↵ Hex code (type L to list all codes): 82 ↵
Create the root partition:
Command (m for help): n ↵ Partition type (default p): ↵ Partition number (3,4, default 3): ↵ First sector: ↵ Last sector: ↵
Verify the partition table:
Command (m for help): p Disk /dev/sda: 298.1 GiB, 320072933376 bytes, 625142448 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x82abc9a6 Device Boot Start End Blocks Id System /dev/sda1 2048 264191 131072 83 Linux /dev/sda2 264192 4458495 2097152 82 Linux swap / Solaris /dev/sda3 4458496 625142447 310341976 83 Linux
Write the parition table to disk:
Command (m for help): w
Your new MBR partition table will now be written to your system disk.
Before your newly-created partitions can be used, the block devices need to be initialized with filesystem metadata. This process is known as creating a filesystem on the block devices. After filesystems are created on the block devices, they can be mounted and used to store files.
You will not create a filesystem on your swap partition, but will initialize it using the
mkswap command so that it can be used as disk-based virtual memory. Then we'll run the
swapon command to make your newly-initialized swap space active within the live CD environment, in case it is needed during the rest of the install process.
Note that we will not create a filesystem on the GRUB boot loader partition, as GRUB writes binary data directly to that partition when the boot loader is installed, which we'll do later.
You can see the commands you will need to type below. Like the rest of this document, it assumes that you are using a GPT partitioning scheme. If you are using MBR, your root filesystem will likely be created on
/dev/sda3 instead and you will need to adjust the target block devices. If you are following our recommendations, then simply do this:
We generally recommend XFS for root filesystems, although ext4 is also a good choice. This tutorial assumes the use of XFS. If you want to use ext4, then be sure that your
/etc/fstab file reflects this.
When deploying an OpenVZ host, please use ext4 exclusively. The Parallels development team tests extensively with ext4, and modern versions of
openvz-rhel6-stable are not compatible with XFS, and you may experience kernel bugs.
To use ext4 as your root filesystem:
# mke2fs -t ext2 /dev/sda1 # mkfs.ext4 /dev/sda3 # mkswap /dev/sda2 # swapon /dev/sda2
To use XFS as your root filesystem:
# mke2fs -t ext2 /dev/sda1 # mkfs.xfs /dev/sda3 # mkswap /dev/sda2 # swapon /dev/sda2
Mount the newly-created filesystems as follows, creating
/mnt/funtoo as the installation mount point:
# mkdir /mnt/funtoo # mount /dev/sda3 /mnt/funtoo # mkdir /mnt/funtoo/boot # mount /dev/sda1 /mnt/funtoo/boot
Optionally, if you have a separate filesystem for
/home or anything else:
# mkdir /mnt/funtoo/home # mount /dev/sda4 /mnt/funtoo/home
If you have
/var/tmp on a separate filesystem, be sure to change the permissions of the mount point to be globally-writeable after mounting, as follows:
# chmod 1777 /mnt/funtoo/tmp
Setting the Date
If your system's date and time are too far off (typically by months or years,) then it may prevent Portage from properly downloading source tarballs. This is because some of our sources are downloaded via HTTPS, which use SSL certificates and are marked with an activation and expiration date. However, if your system time is relatively close to correct, you can probably skip this step for now.
Now is a good time to verify the date and time are correctly set to UTC. Use the
date command to verify the date and time:
# date Fri Jul 15 19:47:18 UTC 2011
If the date and/or time need to be corrected, do so using
date MMDDhhmmYYYY, keeping in mind
hhmm are in 24-hour format. The example below changes the date and time to "July 16th, 2011 @ 8:00PM" UTC:
# date 071620002011 Fri Jul 16 20:00:00 UTC 2011
Once you have set the system clock, it's a very good idea to copy the time to the hardware clock, so it persists across reboots:
# hwclock --systohc
Installing the Stage 3 tarball
Now that filesystems are created and your hardware and system clock are set, the next step is downloading the initial Stage 3 tarball. The Stage 3 is a pre-compiled system used as a starting point to install Funtoo Linux.
To download the correct build of Funtoo Linux for your system, head over to the Subarches page. Subarches are builds of Funtoo Linux that are designed to run on a particular type of CPU, to offer the best possible performance. They also take advantage of the instruction sets available for each CPU.
The Subarches page lists all CPU-optimized versions of Funtoo Linux. Find the one that is appropriate for the type of CPU that your system has, and then click on its name in the first column (such as
corei7, for example.) You will then go to a page dedicated to that subarch, and the available stage3's available for download will be listed.
For most subarches, you will have several stage3's available to choose from. This next section will help you understand which one to pick.
If you're not sure, pick
Funtoo Linux has various different 'builds':
|The most commonly-selected build of Funtoo Linux. Receives rapid updates and preferred by desktop users.|
|Emphasizes less-frequent package updates and trusted, reliable versions of packages over the latest versions.|
If you're not sure, pick
Our "regular" stage3's are listed with a variant of
standard. The following variant builds are available:
|The "standard" version of Funtoo Linux|
|A 64-bit build that drops multilib (32-bit compatibility) support. Can be ideal for server systems.|
|Includes PIE/SSP toolchain for enhanced security. PIE does require the use of PaX in the kernel, while SSP works with any kernel, and provides enhanced security in user-space to avoid stack-based exploits. For expert users.|
Download the Stage3
Once you have found the stage3 that you would like to download, use
wget to download the Stage 3 tarball you have chosen to use as the basis for your new Funtoo Linux system. It should be saved to the
/mnt/funtoo directory as follows:
# cd /mnt/funtoo # wget http://build.funtoo.org/funtoo-current/x86-64bit/generic_64/stage3-latest.tar.xz
Note that 64-bit systems can run 32-bit or 64-bit stages, but 32-bit systems can only run 32-bit stages. Make sure that you select a Stage 3 build that is appropriate for your CPU. If you are not certain, it is a safe bet to choose the
generic_32 stage. Consult the Subarches page for more information.
Once the stage is downloaded, extract the contents with the following command, substituting in the actual name of your stage 3 tarball:
# tar xpf stage3-latest.tar.xz
It is very important to use
p" option when extracting the Stage 3 tarball - it tells
tar to preserve any permissions and ownership that exist within the archive. Without this option, your Funtoo Linux filesystem permissions will be incorrect.
Chroot into Funtoo
To install Funtoo Linux, the
chroot command is first used. The chroot command will "switch into" the new Funtoo Linux system, so the commands you execute after running "chroot" will run within your newly-extracted Funtoo Linux system.
Before chrooting, there are a few things that need to be done to set up the chroot environment. You will need to mount
/dev inside your new system. Use the following commands to do so:
# cd /mnt/funtoo # mount -t proc none proc # mount --rbind /sys sys # mount --rbind /dev dev
You'll also want to copy over
resolv.conf in order to have proper resolution of Internet hostnames from inside the chroot:
# cp /etc/resolv.conf etc
Now you can chroot into your new system. Use
chroot to ensure that no environment settings from the installation media are pulled in to your new system:
# env -i HOME=/root TERM=$TERM chroot . bash -l
Users of live CDs with 64-bit kernels installing 32-bit systems: Some software may use
uname -r to check whether the system is 32 or 64-bit. You may want append linux32 to the chroot command as a workaround, but it's generally not needed.
If you receive the error "
chroot: failed to run command `/bin/bash': Exec format error", it is probably because you are running a 32-bit kernel and trying to execute 64-bit code. Make sure that you have selected the proper type of kernel when booting SystemRescueCD.
It's also a good idea to change the default command prompt while inside the chroot. This will avoid confusion if you have to change terminals. Use this command:
# export PS1="(chroot) $PS1"
Congratulations! You are now chrooted inside a Funtoo Linux system. Now it's time to get Funtoo Linux properly configured so that Funtoo Linux will start successfully, without any manual assistance, when your system is restarted.