Difference between revisions of "Handbook:Parts/Installation/Disks"

From Gentoo Wiki
Jump to:navigation Jump to:search
(Fix link to 'Applying a filesystem to a partition' not to point to he networking page)
(Adjust note to create mount point if it's missing within the live environment. Use more "Handbook variables".)
Line 154: Line 154:
  
 
<!--T:45-->
 
<!--T:45-->
{{Tip|Users of non-Gentoo installation media will need to create the mount point by running: <br/>
+
Certain live environments may be missing the {{Path|/mnt/gentoo}} mount point, or mount points for additional partitions created in the partitioning section. Create necessary partitions by running:
{{RootCmd|mkdir --parents /mnt/gentoo}}
+
 
 +
{{RootCmd
 +
|mkdir --parents {{Handbook Variable|root-partition-mount-point}}
 +
|mkdir --parents {{Handbook Variable|root-partition-mount-point}}{{Handbook Variable|esp-mount-point}}
 
}}
 
}}
  
 
<!--T:30-->
 
<!--T:30-->
Now that the partitions have been initialized and are housing a filesystem, it is time to mount those partitions. Use the {{c|mount}} command, but don't forget to create the necessary mount directories for every partition created. As an example we mount the root partition:
+
With partitions defined and housing a filesystem, it is time to make them accessible via {{c|mount}} command. To mount the root partition:
  
 
<!--T:31-->
 
<!--T:31-->
{{RootCmd|mount {{Handbook Variable|root-partition}} /mnt/gentoo}}
+
{{RootCmd|mount {{Handbook Variable|root-partition}} {{Handbook Variable|root-partition-mount-point}}}}
  
 
<!--T:32-->
 
<!--T:32-->
 
{{Note|If {{Path|/tmp/}} needs to reside on a separate partition, be sure to change its permissions after mounting:
 
{{Note|If {{Path|/tmp/}} needs to reside on a separate partition, be sure to change its permissions after mounting:
{{RootCmd|chmod 1777 /mnt/gentoo/tmp}}
+
{{RootCmd|chmod 1777 {{Handbook Variable|root-partition-mount-point}}/tmp}}
 
This also holds for {{Path|/var/tmp}}.}}
 
This also holds for {{Path|/var/tmp}}.}}
  
 
<!--T:33-->
 
<!--T:33-->
Later in the instructions the proc filesystem (a virtual interface with the kernel) as well as other kernel pseudo-filesystems will be mounted. But first we {{HandbookLink|Installation/Stage|install the Gentoo installation files}}.
+
Later in the instructions, the proc filesystem (a virtual interface with the kernel) as well as other kernel pseudo-filesystems will be mounted. But first {{HandbookLink|Installation/Stage|the Gentoo stage file}} must be extracted.
  
 
<!--T:42-->
 
<!--T:42-->

Revision as of 23:26, 17 February 2024


Warning
Readers should not try to follow instructions directly from the Handbook:Parts namespace (which is THIS page!). The sections displayed below are used as a skeleton for transcluding information into the computer architecture specific handbooks and are therefore lacking critical information.

Please visit the Handbook list to read instructions for a relevant computer architecture.
Parts Handbook
Installation
About the installation
Choosing the media
Configuring the network
Preparing the disks
The stage file
Installing base system
Configuring the kernel
Configuring the system
Installing tools
Configuring the bootloader
Finalizing
Working with Gentoo
Portage introduction
USE flags
Portage features
Initscript system
Environment variables
Working with Portage
Files and directories
Variables
Mixing software branches
Additional tools
Custom package repository
Advanced features
OpenRC network configuration
Getting started
Advanced configuration
Modular networking
Wireless
Adding functionality
Dynamic management


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
IDE, 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 typical design intention. Alternatively this storage type could be useful for short-term file backups or snapshots.

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.

Introduction to block devices

Block devices

Note
Placeholder for introduction to block devices specific to the relative architecture.

Designing a partition scheme

Note
Placeholder for designing a partition scheme specific to the relative architecture.

Creating file systems

Warning
If using an SSD or NVMe drive, please check if it needs a firmware upgrade. Some Intel SSDs in particular (600p and 6000p) require a firmware upgrade for critical bug fixes avoid data corruption induced by XFS I/O usage patterns (though not through any fault of the filesystem). smartctl can help check the model and firmware version.

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 stable on the amd64 architecture - it is advised to read up on the filesystems and their support state before selecting a more experimental one for important partitions. XFS is the recommended all-purpose, all-platform filesystem. The below is a non-exhaustive list:

btrfs
Newer generation filesystem. Provides advanced features like 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. RAID 5/6 and quota groups unsafe on all versions of btrfs.
ext4
Ext4 is a reliable, all-purpose all-platform filesystem, although it lacks modern features like reflinks.
f2fs
The Flash-Friendly File System was originally created by Samsung for the use with NAND flash memory. It is a decent choice when installing Gentoo to microSD cards, USB drives, or other flash-based storage devices.
XFS
Filesystem with metadata journaling which comes with a robust feature-set and is optimized for scalability. It has been continuously upgraded to include modern features. The only downside is that XFS partitions cannot yet be shrunk, although this is being worked on. XFS notably supports reflinks and Copy on Write (CoW) which is particularly helpful on Gentoo systems because of the amount of compiles users complete. XFS is the recommended modern all-purpose all-platform filesystem. Requires a partition to be at least 300MB.
VFAT
Also known as FAT32, is supported by Linux but does not support standard UNIX permission settings. It is mostly used for interoperability/interchange with other operating systems (Microsoft Windows or Apple's macOS) but is also a necessity for some system bootloader firmware (like UEFI). Users of UEFI systems will need an EFI System Partition formatted with VFAT in order to boot.
NTFS
This "New Technology" filesystem is the flagship filesystem of Microsoft Windows since Windows NT 3.1. Similarly to VFAT, 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 for most cases. It should only be used for interoperability or data interchange with Microsoft Windows systems (note the emphasis on only).

More extensive information on filesystems can be found in the community maintained Filesystem article.

Applying a filesystem to a partition

Note
Please make sure to emerge the relevant package for the chosen filesystem later on in the handbook, before rebooting at the end of the install process.

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
ext4 mkfs.ext4 Yes sys-fs/e2fsprogs
f2fs mkfs.f2fs Yes sys-fs/f2fs-tools
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 EFI system partition partition (/dev/sda1) as FAT32 and the root partition (/dev/sda3) as xfs as used in the example partition structure, the following commands would be used:

root #mkfs.vfat -F 32 /dev/sda1
root #mkfs.xfs /dev/sda3

If using 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:

root #mkfs.ext4 -T small /dev/<device>

This will generally quadruple the number of inodes for a given file system as its "bytes-per-inode" reduces from one every 16kB to one every 4kB.

Now create the filesystems on the newly created partitions (or logical volumes).

Activating the swap partition

mkswap is the command that is used to initialize swap partitions:

root #mkswap /dev/sda2

To activate the swap partition, use swapon:

root #swapon /dev/sda2

Create and activate the swap with the commands mentioned above.

Mounting the root partition

Certain live environments may be missing the /mnt/gentoo mount point, or mount points for additional partitions created in the partitioning section. Create necessary partitions by running:

root #mkdir --parents /
root #mkdir --parents //efi

With partitions defined and housing a filesystem, it is time to make them accessible via mount command. To mount the root partition:

root #mount /dev/sda3 /
Note
If /tmp/ needs to reside on a separate partition, be sure to change its permissions after mounting:
root #chmod 1777 //tmp
This also holds for /var/tmp.

Later in the instructions, the proc filesystem (a virtual interface with the kernel) as well as other kernel pseudo-filesystems will be mounted. But first the Gentoo stage file must be extracted.