- Gentoo Linux sparc Handbook: Installing Gentoo
- Contents
- Introduction
- Welcome
- How the installation is structured
- Installation options for Gentoo
- Troubles
- Hardware requirements
- Installation method
- Gentoo Linux installation media
- Minimal installation CD
- The occasional Gentoo LiveDVD
- What are stages then?
- Downloading
- Obtain the media
- Verifying the downloaded files
- Microsoft Windows based verification
- Linux based verification
- Burning a disk
- Burning with Microsoft Windows 7 and above
- Burning with Linux
- Booting
- Booting the installation CD
- Extra hardware configuration
- Optional: User accounts
- Optional: Viewing documentation while installing
- GNU Screen
- Optional: Starting the SSH daemon
- Automatic network detection
- Determine interface names
- ifconfig command
- ip command
- Optional: Configure any proxies
- Testing the network
- Automatic network configuration
- Default: Using net-setup
- Alternative: Using PPP
- Alternative: Using PPTP
- Manual network configuration
- Loading the appropriate network modules
- Using DHCP
- Preparing for wireless access
- Understanding network terminology
- Using ifconfig and route
- Introduction to block devices
- Block devices
- Partitions
- Designing a partition scheme
- How many partitions and how big?
- What about swap space?
- Default partition scheme
- Using fdisk to partition the disk
- Firing up fdisk
- Deleting existing partitions
- Creating the root partition
- Creating a swap partition
- Creating the usr, var and home partitions
- Save and exit
- Creating file systems
- Introduction
- Filesystems
- Applying a filesystem to a partition
Gentoo Linux sparc Handbook: Installing Gentoo
Contents
Introduction
Welcome
First of all, welcome to Gentoo! You are about to enter the world of choices and performance. Gentoo is all about choices. When installing Gentoo, this is made clear several times — users can choose how much they want to compile themselves, how to install Gentoo, what system logger to use, etc.
Gentoo is a fast, modern meta-distribution with a clean and flexible design. It is built on an ecosystem of free software and does not hide what is beneath the hood from its users. Portage, the package maintenance system which Gentoo uses, is written in Python, meaning the user can easily view and modify the source code. Gentoo’s packaging system uses source code (although support for pre-compiled packages is included too) and configuring Gentoo happens through regular text files. In other words, openness everywhere.
It is very important that everyone understands that choices are what makes Gentoo run. We try not to force users into anything they do not like. If anyone believes otherwise, please file a bug report.
How the installation is structured
The Gentoo Installation can be seen as a 10-step procedure, corresponding to the next set of chapters. Each step results in a certain state:
Step | Result |
---|---|
1 | The user is in a working environment ready to install Gentoo. |
2 | The Internet connection is ready to install Gentoo. |
3 | The hard disks are initialized to host the Gentoo installation. |
4 | The installation environment is prepared and the user is ready to chroot into the new environment. |
5 | Core packages, which are the same on all Gentoo installations, are installed. |
6 | The Linux kernel is installed. |
7 | Most of the Gentoo system configuration files are created. |
8 | The necessary system tools are installed. |
9 | The proper boot loader has been installed and configured. |
10 | The freshly installed Gentoo Linux environment is ready to be explored. |
Whenever a certain choice is presented the handbook will try to explain the pros and cons of each choice. Although the text then continues with a default choice (identified by «Default: » in the title), the other possibilities will be documented as well (marked by «Alternative: » in the title). Do not think that the default is what Gentoo recommends. It is, however, the choice that Gentoo believes most users will make.
Sometimes an optional step can be followed. Such steps are marked as «Optional: » and are therefore not needed to install Gentoo. However, some optional steps are dependent on a previously made decision. The instructions will inform the reader when this happens, both when the decision is made, and right before the optional step is described.
Installation options for Gentoo
Gentoo can be installed in many different ways. It can be downloaded and installed from official Gentoo installation media such as our bootable ISO images. The installation media can be installed on a USB stick or accessed via a netbooted environment. Alternatively, Gentoo can be installed from non-official media such as an already installed distribution or a non-Gentoo bootable disk (such as Knoppix).
This document covers the installation using official Gentoo Installation media or, in certain cases, netbooting.
We also provide a Gentoo installation tips and tricks document that might be useful.
Troubles
If a problem is found in the installation (or in the installation documentation), please visit our bug tracking system and check if the bug is known. If not, please create a bug report for it so we can take care of it. Do not be afraid of the developers who are assigned to the bugs — they (generally) don’t eat people.
Although this document is architecture-specific, it may contain references to other architectures as well, because large parts of the Gentoo Handbook use text that is identical for all architectures (to avoid duplication of effort). Such references have been kept to a minimum, to avoid confusion.
If there is some uncertainty whether or not the problem is a user-problem (some error made despite having read the documentation carefully) or a software-problem (some error we made despite having tested the installation/documentation carefully) everybody is welcome to join the #gentoo ( webchat ) channel on irc.libera.chat. Of course, everyone is welcome otherwise too as our chat channel covers the broad Gentoo spectrum.
Speaking of which, if there are any additional questions regarding Gentoo, check out the Frequently Asked Questions article. There are also FAQs on the Gentoo Forums.
Hardware requirements
Before we start, we first list what hardware requirements are needed to successfully install Gentoo on a sparc box.
Sparc System | Please check the Gentoo Linux/SPARC64 compatibility list or the UltraLinux FAQ |
---|---|
CPU | Currently support is limited to SPARC64 CPUs |
Memory | 64 MB |
Disk space | 1.5 GB (excluding swap space) |
Swap space | At least 256 MB |
Installation method
Below we cover how to install Gentoo Linux on a sparc system using the minimal installation CD. Gentoo also supports installation from a TFTP netboot image. For more information, please see the Sparc/Netboot article for setting up a netboot server, and find the TFTPBoot images on the Gentoo mirrors under experimental/sparc/tftpboot/sparc64/ .
Gentoo Linux installation media
Minimal installation CD
The Gentoo minimal installation CD is a bootable image: a self-contained Gentoo environment. It allows the user to boot Linux from the CD or other installation media. During the boot process the hardware is detected and the appropriate drivers are loaded. The image is maintained by Gentoo developers and allows anyone to install Gentoo if an active Internet connection is available.
The Minimal Installation CD is called install-sparc-minimal- .iso .
The occasional Gentoo LiveDVD
Occasionally, a special DVD image is crafted which can be used to install Gentoo. The instructions in this chapter target the Minimal Installation CD, so things might be a bit different when booting from the LiveDVD. However, the LiveDVD (or any other bootable Linux environment) supports getting a root prompt by just invoking sudo su — or sudo -i in a terminal.
What are stages then?
A stage3 tarball is an archive containing a profile specific minimal Gentoo environment. Stage3 tarballs are suitable to continue the Gentoo installation using the instructions in this handbook. Previously, the handbook described the installation using one of three stage tarballs. Gentoo does not offer stage1 and stage2 tarballs for download any more since these are mostly for internal use and for bootstrapping Gentoo on new architectures.
Stage3 tarballs can be downloaded from releases/sparc/autobuilds/ on any of the official Gentoo mirrors. Stage files update frequently and are not included in official installation images.
Downloading
Obtain the media
The default installation media that Gentoo Linux uses are the minimal installation CDs, which host a bootable, very small Gentoo Linux environment. This environment contains all the right tools to install Gentoo. The CD images themselves can be downloaded from the downloads page (recommended) or by manually browsing to the ISO location on one of the many available mirrors.
If downloading from a mirror, the minimal installation CDs can be found as follows:
- Go to the releases/ directory.
- Select the directory for the relevant target architecture (such as sparc/ ).
- Select the autobuilds/ directory.
- For amd64 and x86 architectures select either the current-install-amd64-minimal/ or current-install-x86-minimal/ directory (respectively). For all other architectures navigate to the current-iso/ directory.
Inside this location, the installation media file is the file with the .iso suffix. For instance, take a look at the following listing:
In the above example, the install-sparc-minimal-20141204.iso file is the minimal installation CD itself. But as can be seen, other related files exist as well:
- A .CONTENTS file which is a text file listing all files available on the installation media. This file can be useful to verify if particular firmware or drivers are available on the installation media before downloading it.
- A .DIGESTS file which contains the hash of the ISO file itself, in various hashing formats/algorithms. This file can be used to verify if the downloaded ISO file is corrupt or not.
- A .DIGESTS.asc file which not only contains the hash of the ISO file (like the .DIGESTS file), but also a cryptographic signature of that file. This can be used to both verify if the downloaded ISO file is corrupt or not, as well as verify that the download is indeed provided by the Gentoo Release Engineering team and has not been tampered with.
Ignore the other files available at this location for now — those will come back when the installation has proceeded further. Download the .iso file and, if verification of the download is wanted, download the .DIGESTS.asc file for the .iso file as well. The .CONTENTS file does not need to be downloaded as the installation instructions will not refer to this file anymore, and the .DIGESTS file should contain the same information as the .DIGESTS.asc file, except that the latter also contains a signature on top of it.
Verifying the downloaded files
Through the .DIGESTS and .DIGESTS.asc files, the validity of the ISO file can be confirmed using the right set of tools. This verification is usually done in two steps:
- First, the cryptographic signature is validated to make sure that the installation file is provided by the Gentoo Release Engineering team
- If the cryptographic signature validates, then the checksum is verified to make sure that the downloaded file itself is not corrupted
Microsoft Windows based verification
On a Microsoft Windows system, chances are low that the right set of tools to verify checksums and cryptographic signatures are in place.
To first verify the cryptographic signature, tools such as GPG4Win can be used. After installation, the public keys of the Gentoo Release Engineering team need to be imported. The list of keys is available on the signatures page. Once imported, the user can then verify the signature of the .DIGESTS.asc file.
The checksum itself can be verified using the Hashcalc application, although many others exist as well. Most of the time, these tools will show the user the calculated checksum, and the user is requested to verify this checksum with the value that is inside the .DIGESTS.asc file.
Linux based verification
On a Linux system, the most common method for verifying the cryptographic signature is to use the app-crypt/gnupg software. With this package installed, the following commands can be used to verify the cryptographic signature of the .DIGESTS.asc file.
First, download the right set of keys as made available on the signatures page:
Alternatively you can use instead the WKD to download the key:
Next verify the cryptographic signature of the .DIGESTS.asc file:
To be absolutely certain that everything is valid, verify the fingerprint shown with the fingerprint on the Gentoo signatures page.
With the cryptographic signature validated, next verify the checksum to make sure the downloaded ISO file is not corrupted. The .DIGESTS.asc file contains multiple hashing algorithms, so one of the methods to validate the right one is to first look at the checksum registered in the .DIGESTS.asc file. For instance, to get the SHA512 checksum:
In the above output, two SHA512 checksums are shown — one for the install-sparc-minimal-20141204.iso file and one for its accompanying .CONTENTS file. Only the first checksum is of interest, as it needs to be compared with the calculated SHA512 checksum which can be generated as follows:
As both checksums match, the file is not corrupted and the installation can continue.
Burning a disk
Of course, with just an ISO file downloaded, the Gentoo Linux installation cannot be started. The ISO file needs to be burned on a CD to boot from, and in such a way that its content is burned on the CD, not just the file itself. Below a few common methods are described — a more elaborate set of instructions can be found in Our FAQ on burning an ISO file.
Burning with Microsoft Windows 7 and above
Versions of Microsoft Windows 7 and above can both mount and burn ISO images to optical media without the requirement for third-party software. Simply insert a burnable disk, browse to the downloaded ISO files, right click the file in Windows Explorer, and select «Burn disk image».
Burning with Linux
The cdrecord utility from the package app-cdr/cdrtools can burn ISO images on Linux.
To burn the ISO file on the CD in the /dev/sr0 device (this is the first CD device on the system — substitute with the right device file if necessary):
Users that prefer a graphical user interface can use K3B, part of the kde-apps/k3b package. In K3B, go to Tools and use Burn CD Image .
Booting
Booting the installation CD
Insert the Gentoo installation CD in the CD-ROM and boot the system. During startup, press Stop + A to enter OpenBootPROM (OBP). Once in the OBP, boot from the CD-ROM:
The SILO boot manager (on the installation CD) is then started. Hit Enter for more help. Type in gentoo and press Enter to continue booting the system:
Once the Installation CD is booted, a root («#») prompt will be displayed on the current console. There will also be a root prompt on the serial console ( ttyS0 ).
Extra hardware configuration
When the Installation medium boots, it tries to detect all the hardware devices and loads the appropriate kernel modules to support the hardware. In the vast majority of cases, it does a very good job. However, in some cases it may not auto-load the kernel modules needed by the system. If the PCI auto-detection missed some of the system’s hardware, the appropriate kernel modules have to be loaded manually.
In the next example the 8139too module (which supports certain kinds of network interfaces) is loaded:
Optional: User accounts
If other people need access to the installation environment, or there is need to run commands as a non-root user on the installation medium (such as to chat using irssi without root privileges for security reasons), then an additional user account needs to be created and the root password set to a strong password.
To change the root password, use the passwd utility:
To create a user account, first enter their credentials, followed by the account’s password. The useradd and passwd commands are used for these tasks.
In the next example, a user called john is created:
To switch from the (current) root user to the newly created user account, use the su command:
Optional: Viewing documentation while installing
To view the Gentoo handbook during the installation, first create a user account as described above. Then press Alt + F2 to go to a new terminal.
During the installation, the links command can be used to browse the Gentoo handbook — of course only from the moment that the Internet connection is working.
To go back to the original terminal, press Alt + F1 .
GNU Screen
The Screen utility is installed by default on official Gentoo installation media. It may be more efficient for the seasoned Linux enthusiast to use screen to view installation instructions via split panes rather than the multiple TTY method mentioned above.
Optional: Starting the SSH daemon
To allow other users to access the system during the installation (perhaps to support during an installation, or even do it remotely), a user account needs to be created (as was documented earlier on) and the SSH daemon needs to be started.
To fire up the SSH daemon on an OpenRC init, execute the following command:
To be able to use sshd, the network needs to function properly. Continue with the chapter on Configuring the network.
Automatic network detection
Maybe it just works?
If the system is plugged into an Ethernet network with a DHCP server, it is very likely that the networking configuration has already been set up automatically. If so, then the many included network-aware commands on the installation CD such as ssh , scp , ping , irssi , wget , and links , among others, will work immediately.
Determine interface names
ifconfig command
If networking has been configured, the ifconfig command should list one or more network interfaces (besides lo ). In the example below eth0 shows up:
As a result of the shift towards predictable network interface names, the interface name on the system can be quite different from the old eth0 naming convention. Recent installation media might show regular network interfaces names like eno0 , ens1 , or enp5s0 . Look for the interface in the ifconfig output that has an IP address related to the local network.
ip command
As an alternative to ifconfig , the ip command can be used to determine interface names. The following example shows the output of ip addr (of another system so the information shown is different from the previous example):
The output above may be a bit more complicated to read than alternative. The interface name in the above example directly follows the number; it is eno1 .
In the remainder of this document, the handbook will assume that the operating network interface is called eth0 .
Optional: Configure any proxies
If the Internet is accessed through a proxy, then it is necessary to set up proxy information during the installation. It is very easy to define a proxy: just define a variable which contains the proxy server information.
In most cases, it is sufficient to define the variables using the server hostname. As an example, we assume the proxy is called proxy.gentoo.org and the port is 8080.
To set up an HTTP proxy (for HTTP and HTTPS traffic):
To set up an FTP proxy:
To set up an RSYNC proxy:
If the proxy requires a username and password, use the following syntax for the variable:
Testing the network
Try pinging your ISP’s DNS server (found in /etc/resolv.conf ) and a web site of choice. This ensures that the network is functioning properly and that the network packets are reaching the net, DNS name resolution is working correctly, etc.
If this all works, then the remainder of this chapter can be skipped to jump right to the next step of the installation instructions (Preparing the disks).
Automatic network configuration
If the network doesn’t work immediately, some installation media allow the user to use net-setup (for regular or wireless networks), pppoe-setup (for ADSL users) or pptp (for PPTP users).
If the installation medium does not contain any of these tools, continue with the Manual network configuration.
- Regular Ethernet users should continue with Default: Using net-setup
- ADSL users should continue with Alternative: Using PPP
- PPTP users should continue with Alternative: Using PPTP
Default: Using net-setup
The simplest way to set up networking if it didn’t get configured automatically is to run the net-setup script:
net-setup will ask some questions about the network environment. When all is done, the network connection should work. Test the network connection as stated before. If the tests are positive, congratulations! Skip the rest of this section and continue with Preparing the disks.
If the network still doesn’t work, continue with Manual network configuration.
Alternative: Using PPP
Assuming PPPoE is needed to connect to the Internet, the installation CD (any version) has made things easier by including ppp. Use the provided pppoe-setup script to configure the connection. During the setup the Ethernet device that is connected to your ADSL modem, the username and password, the IPs of the DNS servers and if a basic firewall is needed or not will be asked.
If something goes wrong, double-check that the username and password are correct by looking at etc/ppp/pap-secrets or /etc/ppp/chap-secrets and make sure to use the right Ethernet device. If the Ethernet device does not exist, the appropriate network modules need to be loaded. In that case continue with Manual network configuration as it will explain how to load the appropriate network modules there.
If everything worked, continue with Preparing the disks.
Alternative: Using PPTP
If PPTP support is needed, use pptpclient which is provided by the installation CDs. But first make sure that the configuration is correct. Edit /etc/ppp/pap-secrets or /etc/ppp/chap-secrets so it contains the correct username/password combination:
Then adjust /etc/ppp/options.pptp if necessary:
When all that is done, run pptp (along with the options that couldn’t be set in options.pptp ) to connect the server:
Manual network configuration
Loading the appropriate network modules
When the Installation CD boots, it tries to detect all the hardware devices and loads the appropriate kernel modules (drivers) to support the hardware. In the vast majority of cases, it does a very good job. However, in some cases, it may not auto-load the kernel modules needed to communicate properly with the present network hardware.
If net-setup or pppoe-setup failed, then it is possible that the network card wasn’t found immediately. This means users may have to load the appropriate kernel modules manually.
To find out what kernel modules are provided for networking, use the ls command:
If a driver is found for the network device, use modprobe to load the kernel module. For instance, to load the pcnet32 module:
To check if the network card is now detected, use ifconfig . A detected network card would result in something like this (again, eth0 here is just an example):
If however the following error is shown, the network card is not detected:
The available network interface names on the system can be listed through the /sys file system:
In the above example, 6 interfaces are found. The eth0 one is most likely the (wired) Ethernet adapter whereas wlan0 is the wireless one.
Assuming that the network card is now detected, retry net-setup or pppoe-setup again (which should work now), but for the hardcore people we explain how to configure the network manually as well.
Select one of the following sections based on your network setup:
- Using DHCP for automatic IP retrieval
- Preparing for wireless access if a wireless network is used
- Understanding network terminology explains the basics about networking
- Using ifconfig and route explains how to set up networking manually
Using DHCP
DHCP (Dynamic Host Configuration Protocol) makes it possible to automatically receive networking information (IP address, netmask, broadcast address, gateway, nameservers etc.). This only works if a DHCP server is in the network (or if the ISP provider provides a DHCP service). To have a network interface receive this information automatically, use dhcpcd :
Some network administrators require that the hostname and domainname provided by the DHCP server is used by the system. In that case, use:
If this works (try pinging some Internet server, like Google’s 8.8.8.8 or Cloudflare’s 1.1.1.1), then everything is set and ready to continue. Skip the rest of this section and continue with Preparing the disks.
Preparing for wireless access
When using a wireless (802.11) card, the wireless settings need to be configured before going any further. To see the current wireless settings on the card, one can use iw . Running iw might show something like:
To check for a current connection:
For most users, there are only two settings needed to connect, the ESSID (aka wireless network name) and, optionally, the WEP key.
- First, ensure the interface is active:
- To connect to an open network with the name GentooNode:
- To connect with a hex WEP key, prefix the key with d: :
- To connect with an ASCII WEP key:
Confirm the wireless settings by using iw dev wlp9s0 link . Once wireless is working, continue configuring the IP level networking options as described in the next section (Understanding network terminology) or use the net-setup tool as described previously.
Understanding network terminology
If all of the above fails, the network will need to be configured manually. This is not difficult at all. However, some knowledge of network terminology and basic concepts might be necessary. After reading this section, users will know what a gateway is, what a netmask serves for, how a broadcast address is formed and why systems need nameservers.
In a network, hosts are identified by their IP address (Internet Protocol address). Such an address is perceived as a combination of four numbers between 0 and 255. Well, at least when using IPv4 (IP version 4). In reality, such an IPv4 address consists of 32 bits (ones and zeros). Let’s view an example:
Such an IP address is unique to a host as far as all accessible networks are concerned (i.e. every host that one wants to be able to reach must have a unique IP address). In order to distinguish between hosts inside and outside a network, the IP address is divided in two parts: the network part and the host part.
The separation is written down with the netmask, a collection of ones followed by a collection of zeros. The part of the IP that can be mapped on the ones is the network-part, the other one is the host-part. As usual, the netmask can be written down as an IP address.
In other words, 192.168.0.14 is part of the example network, but 192.168.1.2 is not.
The broadcast address is an IP address with the same network-part as the network, but with only ones as host-part. Every host on the network listens to this IP address. It is truly meant for broadcasting packets.
To be able to surf on the Internet, each computer in the network must know which host shares the Internet connection. This host is called the gateway. Since it is a regular host, it has a regular IP address (for instance 192.168.0.1).
Previously we stated that every host has its own IP address. To be able to reach this host by a name (instead of an IP address) we need a service that translates a name (such as dev.gentoo.org) to an IP address (such as 64.5.62.82). Such a service is called a name service. To use such a service, the necessary name servers need to be defined in /etc/resolv.conf .
In some cases, the gateway also serves as a nameserver. Otherwise the nameservers provided by the ISP need to be entered in this file.
To summarize, the following information is needed before continuing:
Network item | Example |
---|---|
The system IP address | 192.168.0.2 |
Netmask | 255.255.255.0 |
Broadcast | 192.168.0.255 |
Gateway | 192.168.0.1 |
Nameserver(s) | 195.130.130.5, 195.130.130.133 |
Using ifconfig and route
Employing tools from the sys-apps/net-tools package, setting up the network manually generally consists of three steps:
- Assign an IP address using the ifconfig command.
- Set up routing to the gateway using the route command.
- Finish up by placing valid nameserver IPs in the /etc/resolv.conf file.
To assign an IP address, the IP address, broadcast address, and netmask are needed. Execute the following command, substituting $
To configure routing using route , substitute the $
Now open the /etc/resolv.conf file using a text editor:
Fill in the nameserver(s) using the following as a template substituting $
Now test the network by pinging an Internet server (like Google’s 8.8.8.8 or Cloudflare’s 1.1.1.1). Once connected, continue with Preparing the disks.
Introduction to block devices
Block devices
Let’s take a good look at disk-oriented aspects of Gentoo Linux and Linux in general, including block devices, partitions, and Linux filesystems. Once the ins and outs of disks are understood, partitions and filesystems can be established for installation.
To begin, let’s look at block devices. SCSI and Serial ATA drives are both labeled under device handles such as: /dev/sda , /dev/sdb , /dev/sdc , etc. On more modern machines, PCI Express based NVMe solid state disks have device handles such as /dev/nvme0n1 , /dev/nvme0n2 , etc.
The following table will help readers determine where to find a certain type of block device on the system:
Type of device | Default device handle | Editorial notes and considerations |
---|---|---|
SATA, SAS, SCSI, or USB flash | /dev/sda | Found on hardware from roughly 2007 until the present, this device handle is perhaps the most commonly used in Linux. These types of devices can be connected via the SATA bus, SCSI, USB bus as block storage. As example, the first partition on the first SATA device is called /dev/sda1 . |
NVM Express (NVMe) | /dev/nvme0n1 | The latest in solid state technology, NVMe drives are connected to the PCI Express bus and have the fastest transfer block speeds on the market. Systems from around 2014 and newer may have support for NVMe hardware. The first partition on the first NVMe device is called /dev/nvme0n1p1 . |
MMC, eMMC, and SD | /dev/mmcblk0 | embedded MMC devices, SD cards, and other types of memory cards can be useful for data storage. That said, many systems may not permit booting from these types of devices. It is suggested to not use these devices for active Linux installations; rather consider using them to transfer files, which is their design goal. Alternatively they could be useful for short-term backups. |
The block devices above represent an abstract interface to the disk. User programs can use these block devices to interact with the disk without worrying about whether the drives are SATA, SCSI, or something else. The program can simply address the storage on the disk as a bunch of contiguous, randomly-accessible 4096-byte (4K) blocks.
Partitions
Although it is theoretically possible to use the entire disk to house a Linux system, this is almost never done in practice. Instead, full disk block devices are split up in smaller, more manageable block devices. These are known as partitions or slices.
The first partition on the first SCSI disk is /dev/sda1 , the second /dev/sda2 and so on.
The third partition on Sun systems is set aside as a special «whole disk» slice. This partition must not contain a file system.
Users who are used to the DOS partitioning scheme should note that Sun disklabels do not have «primary» and «extended» partitions. Instead, up to eight partitions are available per drive, with the third of these being reserved.
Designing a partition scheme
How many partitions and how big?
The design of disk partition layout is highly dependent on the demands of the system and the file system(s) applied to the device. If there are lots of users, then it is advised to have /home on a separate partition which will increase security and make backups and other types of maintenance easier. If Gentoo is being installed to perform as a mail server, then /var should be a separate partition as all mails are stored inside the /var directory. Game servers may have a separate /opt partition since most gaming server software is installed therein. The reason for these recommendations is similar to the /home directory: security, backups, and maintenance.
In most situations on Gentoo, /usr and /var should be kept relatively large in size. /usr hosts the majority of applications available on the system and the Linux kernel sources (under /usr/src ). By default, /var hosts the Gentoo ebuild repository (located at /var/db/repos/gentoo ) which, depending on the file system, generally consumes around 650 MiB of disk space. This space estimate excludes the /var/cache/distfiles and /var/cache/binpkgs directories, which will gradually fill with source files and (optionally) binary packages respectively as they are added to the system.
How many partitions and how big very much depends on considering the trade-offs and choosing the best option for the circumstance. Separate partitions or volumes have the following advantages:
- Choose the best performing filesystem for each partition or volume.
- The entire system cannot run out of free space if one defunct tool is continuously writing files to a partition or volume.
- If necessary, file system checks are reduced in time, as multiple checks can be done in parallel (although this advantage is realized more with multiple disks than it is with multiple partitions).
- Security can be enhanced by mounting some partitions or volumes read-only, nosuid (setuid bits are ignored), noexec (executable bits are ignored), etc.
However, multiple partitions have certain disadvantages as well:
- If not configured properly, the system might have lots of free space on one partition and little free space on another.
- A separate partition for /usr/ may require the administrator to boot with an initramfs to mount the partition before other boot scripts start. Since the generation and maintenance of an initramfs is beyond the scope of this handbook, we recommend that newcomers do not use a separate partition for /usr/ .
- There is also a 15-partition limit for SCSI and SATA unless the disk uses GPT labels.
What about swap space?
There is no perfect value for swap space size. The purpose of the space is to provide disk storage to the kernel when internal memory (RAM) is under pressure. A swap space allows for the kernel to move memory pages that are not likely to be accessed soon to disk (swap or page-out), which will free memory in RAM for the current task. Of course, if the pages swapped to disk are suddenly needed, they will need to be put back in memory (page-in) which will take considerably longer than reading from RAM (as disks are very slow compared to internal memory).
When a system is not going to run memory intensive applications or has lots of RAM available, then it probably does not need much swap space. However do note in case of hibernation that swap space is used to store the entire contents of memory (likely on desktop and laptop systems rather than on server systems). If the system requires support for hibernation, then swap space larger than or equal to the amount of memory is necessary.
As a general rule, the swap space size is recommended to be twice the internal memory (RAM). For systems with multiple hard disks, it is wise to create one swap partition on each disk so that they can be utilized for parallel read/write operations. The faster a disk can swap, the faster the system will run when data in swap space must be accessed. When choosing between rotational and solid state disks, it is better for performance to put swap on the SSD. Also, swap files can be used as an alternative to swap partitions; this is mostly interesting for systems with very limited disk space.
Default partition scheme
The table below suggests a suitable starting point for most systems. Note that this is only an example, so feel free to use different partitioning schemes.
Partition | Filesystem | Size | Mount Point | Description |
---|---|---|---|---|
/dev/sda1 | ext4 | / | Root partition. For SPARC64 systems with OBP versions 3 or less, this must be less than 2 GB in size, and the first partition on the disk. More recent OBP versions can deal with larger root partitions and, as such, can support having /usr, /var and other locations on the same partition. | |
/dev/sda2 | swap | 512 MB | none | Swap partition. For bootstrap and certain larger compiles, at least 512 MB of RAM (including swap) is required. |
/dev/sda3 | none | Whole disk | none | Whole disk partition. This is required on SPARC systems. |
/dev/sda4 | ext4 | at least 2 GB | /usr | /usr partition. Applications are installed here. By default this partition is also used for Portage data (which takes around 500 MB excluding source code). |
/dev/sda5 | ext4 | at least 1 GB | /var | /var partition. Used for program-generated data. By default Portage uses this partition for temporary space whilst compiling. Certain larger applications such as Mozilla and LibreOffice.org can require over 1 GB of temporary space here when building. |
/dev/sda6 | ext4 | remaining space | /home | /home partition. Used for users’ home directories. |
Using fdisk to partition the disk
The following parts explain how to create the example partition layout described previously, namely:
Partition | Description |
---|---|
/dev/sda1 | / |
/dev/sda2 | swap |
/dev/sda3 | whole disk slice |
/dev/sda4 | /usr |
/dev/sda5 | /var |
/dev/sda6 | /home |
Change the partition layout as required. Remember to keep the root partition entirely within the first 2 GB of the disk for older systems. There is also a 15-partition limit for SCSI and SATA.
Firing up fdisk
Start fdisk with the disk as argument:
To view the available partitions, type in p :
Note the Sun disk label in the output. If this is missing, the disk is using the DOS-partitioning, not the Sun partitioning. In this case, use s to ensure that the disk has a Sun partition table:
The right values can be found in the documentation of the hard disk itself. The ‘auto configure’ option does not usually work.
Deleting existing partitions
It’s time to delete any existing partitions. To do this, type d and hit Enter . Give the partition number to delete. To delete a pre-existing /dev/sda1 , type:
Do not delete partition 3 (whole disk). This is required. If this partition does not exist, follow the «Creating a Sun Disklabel» instructions above.
After deleting all partitions except the Whole disk slice,a partition layout similar to the following should show up:
Creating the root partition
Next create the root partition. To do this, type n to create a new partition, then type 1 to create the partition. When prompted for the first cylinder, hit Enter . When prompted for the last cylinder, type +512M to create a partition 512 MB in size. Make sure that the entire root partition fits within the first 2 GB of the disk. The output of these steps is as follows:
When listing the partitions (through p ), the following partition printout is shown:
Creating a swap partition
Next, let’s create the swap partition. To do this, type n to create a new partition, then 2 to create the second partition, /dev/sda2 in our case. When prompted for the first cylinder, hit Enter . When prompted for the last cylinder, type +512M to create a partition 512 MB in size. After this, type t to set the partition type, 2 to select the partition just created and then type in 82 to set the partition type to «Linux Swap». After completing these steps, typing p should display a partition table that looks similar to this:
Creating the usr, var and home partitions
Finally, let’s create the /usr , /var and /home partitions. As before, type n to create a new partition, then type 4 to create the third partition (we do not count the whole disk as being a partition), /dev/sda4 in our case. When prompted for the first cylinder, hit Enter . When prompted for the last cylinder, enter +2048M to create a partition 2 GB in size. Repeat this process for /dev/sda5 and sda6 , using the desired sizes. When finished, the partition table will look similar to the following:
Save and exit
Save the partition layout and exit fdisk by typing w :
Creating file systems
Introduction
Now that the partitions have been created, it is time to place a filesystem on them. In the next section the various file systems that Linux supports are described. Readers that already know which filesystem to use can continue with Applying a filesystem to a partition. The others should read on to learn about the available filesystems.
Filesystems
Linux supports several dozen filesystems, although many of them are only wise to deploy for specific purposes. Only certain filesystems may be found found stable on the sparc architecture — it is advised to read up on the filesystems and their support state before selecting a more experimental one for important partitions. ext4 is the recommended all-purpose all-platform filesystem.
btrfs A next generation filesystem that provides many advanced features such as snapshotting, self-healing through checksums, transparent compression, subvolumes, and integrated RAID. Kernels prior to 5.4.y are not guaranteed to be safe to use with btrfs in production because fixes for serious issues are only present in the more recent releases of the LTS kernel branches. Filesystem corruption issues are common on older kernel branches, with anything older than 4.4.y being especially unsafe and prone to corruption. Corruption is more likely on older kernels (than 5.4.y) when compression is enabled. RAID 5/6 and quota groups unsafe on all versions of btrfs. Furthermore, btrfs can counter-intuitively fail filesystem operations with ENOSPC when df reports free space due to internal fragmentation (free space pinned by DATA + SYSTEM chunks, but needed in METADATA chunks). Additionally, a single 4K reference to a 128M extent inside btrfs can cause free space to be present, but unavailable for allocations. This can also cause btrfs to return ENOSPC when free space is reported by df. Installing sys-fs/btrfsmaintenance and configuring the scripts to run periodically can help to reduce the possibility of ENOSPC issues by rebalancing btrfs, but it will not eliminate the risk of ENOSPC when free space is present. Some workloads will never hit ENOSPC while others will. If the risk of ENOSPC in production is unacceptable, you should use something else. If using btrfs, be certain to avoid configurations known to have issues. With the exception of ENOSPC, information on the issues present in btrfs in the latest kernel branches is available at the btrfs wiki status page. ext2 This is the tried and true Linux filesystem but doesn’t have metadata journaling, which means that routine ext2 filesystem checks at startup time can be quite time-consuming. There is now quite a selection of newer-generation journaled filesystems that can be checked for consistency very quickly and are thus generally preferred over their non-journaled counterparts. Journaled filesystems prevent long delays when the system is booted and the filesystem happens to be in an inconsistent state. ext3 The journaled version of the ext2 filesystem, providing metadata journaling for fast recovery in addition to other enhanced journaling modes like full data and ordered data journaling. It uses an HTree index that enables high performance in almost all situations. In short, ext3 is a very good and reliable filesystem. ext4 Initially created as a fork of ext3, ext4 brings new features, performance improvements, and removal of size limits with moderate changes to the on-disk format. It can span volumes up to 1 EB and with maximum file size of 16TB. Instead of the classic ext2/3 bitmap block allocation ext4 uses extents, which improve large file performance and reduce fragmentation. Ext4 also provides more sophisticated block allocation algorithms (delayed allocation and multiblock allocation) giving the filesystem driver more ways to optimize the layout of data on the disk. Ext4 is the recommended all-purpose all-platform filesystem. f2fs The Flash-Friendly File System was originally created by Samsung for the use with NAND flash memory. As of Q2, 2016, this filesystem is still considered immature, but it is a decent choice when installing Gentoo to microSD cards, USB drives, or other flash-based storage devices. JFS IBM’s high-performance journaling filesystem. JFS is a light, fast, and reliable B+tree-based filesystem with good performance in various conditions. ReiserFS A B+tree-based journaled filesystem that has good overall performance, especially when dealing with many tiny files at the cost of more CPU cycles. ReiserFS version 3 is included in the mainline Linux kernel, but is not recommended to be used when initially installing a Gentoo system. Newer versions of the ReiserFS filesystem exist, however they require additional patching of the mainline kernel to be utilized. XFS A filesystem with metadata journaling which comes with a robust feature-set and is optimized for scalability. XFS seems to be less forgiving to various hardware problems, but has been continuously upgraded to include modern features. VFAT Also known as FAT32, is supported by Linux but does not support standard UNIX permission settings. It is mostly used for interoperability with other operating systems (Microsoft Windows or Apple’s OSX) but is also a necessity for some system bootloader firmware (like UEFI). NTFS This «New Technology» filesystem is the flagship filesystem of Microsoft Windows since Windows NT 3.1. Similar to vfat above it does not store UNIX permission settings or extended attributes necessary for BSD or Linux to function properly, therefore it should not be used as a root filesystem. It should only be used for interoperability with Microsoft Windows systems (note the emphasis on only).
Applying a filesystem to a partition
To create a filesystem on a partition or volume, there are user space utilities available for each possible filesystem. Click the filesystem’s name in the table below for additional information on each filesystem:
Filesystem | Creation command | On minimal CD? | Package |
---|---|---|---|
btrfs | mkfs.btrfs | Yes | sys-fs/btrfs-progs |
ext2 | mkfs.ext2 | Yes | sys-fs/e2fsprogs |
ext3 | mkfs.ext3 | Yes | sys-fs/e2fsprogs |
ext4 | mkfs.ext4 | Yes | sys-fs/e2fsprogs |
f2fs | mkfs.f2fs | Yes | sys-fs/f2fs-tools |
jfs | mkfs.jfs | Yes | sys-fs/jfsutils |
reiserfs | mkfs.reiserfs | Yes | sys-fs/reiserfsprogs |
xfs | mkfs.xfs | Yes | sys-fs/xfsprogs |
vfat | mkfs.vfat | Yes | sys-fs/dosfstools |
NTFS | mkfs.ntfs | Yes | sys-fs/ntfs3g |
For instance, to have the root partition ( /dev/sda1 ) as ext4 as used in the example partition structure, the following commands would be used:
When using ext2, ext3, or ext4 on a small partition (less than 8 GiB), then the file system must be created with the proper options to reserve enough inodes. This can be done using one of the following commands, respectively:
Источник