Handbook:AMD64/Blocks/Disks/pt-br

Partições
Although it is theoretically possible to use a full 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. On systems, these are called partitions. There are currently two standard partitioning technologies in use: MBR and GPT.

MBR
A configuração MBR ("Master Boot Record" - Registro Mestre de Iniciliazação) usa identificadores de 32 bits para o setor de início e o tamanho das partições e suporta três tipos de partições: primária, estendida e lógica. Partições primárias têm suas informações armazenadas no MBR em si - um local muito pequeno (normalmente 512 bytes) bem no começo do disco. Devido a esse espaço pequeno, apenas quatro partições primárias são suportadas (ou seja, de a ).

Para suportar mais partições, uma das partições primárias pode ser marcada como uma partição estendida. Essa partição pode então conter partições lógicas (com partições dentro de uma partição).

Cada partição é limitada em tamanho a 2 TB (devido aos identificadores de 32 bits). Também, a configuração MBR não provê nenhuma cópia da MBR, assim, se uma aplicação ou usuário sobrescreve a MBR, toda as informações sobre as partições são perdidas.

GPT
A configuração GPT ("GUID Partition Table" - Tabela de Partição GUID) usa identificadores de 64 bits para as partições. O local onde é armazenada a informação sobre as partições é muito maior que os 512 bytes da MBR e não há limite no número de partições. Também o tamanho de uma partição tem um limite muito maior (quase 8 ZB - sim, zetabytes).

Quando a interface do software de sistema entre o sistema operacional e o firmware é a UEFI (em vez da BIOS), o GPT é praticamente mandatório uma vez que surgirão problemas de compatibilidade com a MBR.

A GPT também tem a vantagem de ter uma GPT backup no final do disco, que pode ser usada para recuperar a GPT primária do início. A GPT também inclui somas de checagem CRC32 para detectar erros no cabeçalho e tabelas de partição.

GPT ou MBR
Pela descrição acima, alguém pode imaginar que usar GPT é sempre o caminho recomendado. Mas há alguns problemas com isso.

Usar GPT em um computador baseado em BIOS funciona, mas com isso não é possível fazer dual boot com um sistema operacional Microsoft Windows. A razão é que o Microsoft Windows irá inicializar em modo EFI se ele detectar uma etiqueta de partição GPT.

Some buggy BIOSes or EFIs configured to boot in BIOS/CSM/legacy mode might also have problems with booting from GPT labeled disks. If that is the case, it might be possible to work around the problem by adding the boot/active flag on the protective MBR partition which has to be done through with the   option to force it to read the partition table using the MBR format.

In this case, launch and toggle the flag using the  key. Press to select the first partition, then press the  key to write the changes to the disk and exit the  application:

Usando UEFI
When installing Gentoo on a system that uses UEFI to boot the operating system (instead of BIOS), then it is important that an EFI system partition is created. The instructions for below contain the necessary pointers for this.

A partição de sistema EFI precisa também ser uma partição FAT32 (ou "vfat", como é como é mostrada em sistemas Linux). As instruções no final deste capítulo usa o ext2 como exemplo de sistema de arquivos para a partição. Tenha certeza de usar "vfat", assim:

Armazenamento avançado
The Installation CDs provide support for LVM2. LVM2 increases the flexibility offered by the partitioning setup. During the installation instructions, we will focus on "regular" partitions, but it is still good to know LVM2 is supported as well.

Esquema de particionamento default
Throughout the remainder of the handbook, the following partitioning scheme is used. If this suffices, then the reader can immediately jump to Default: Using parted to partition the disk or Alternative: Using fdisk to partition the disk. Both are partitioning tools, is well known and stable and recommended for the MBR partition layout, while  is more recent and recommended for GPT layouts.

Antes das instruções para criação das partições, o primeiro conjunto de seções descreverá em mais detalhes como os esquemas de particionamento podem ser criados e quais são as dificuldades mais comuns.

O que é a partição de boot da BIOS?
A partição de boot da BIOS é uma partição muito pequena (de 1 a 2 MB) na qual os gerenciadores de inicialização como o GRUB2 podem gravar dados adicionais que não couberem no espaço alocado (umas poucas centenas de bytes no caso da MBR) e que não puderem ser colocados em outro lugar.

Tais partições nem sempre são necessárias mas, considerando o baixo consumo de espaço e a dificuldade que teríamos documentando a pletora de diferentes particionamentos caso não a criássemos, é recomendável criá-la de qualquer forma.

Para ficar claro, a partição de inicialização da BIOS é necessária quando o layout de partições GPT é usado com o GRUB2, ou quando o layout de partições MBR é usado com o GRUB2 e a primeira partição inicia antes do primeiro 1MB do disco.

Default: Usando parted para particionar o disco
Neste capítulo, o exemplo de layout de partições mencionado anteriormente será usado:

Altere o layout de particionamento de acordo com suas preferências pessoais.

Visualizando o layout de particionamento atual com o parted
The application offers a simple interface for partitioning the disks and supports very large partitions (more than 2 TB). Fire up against the disk (in our example, we use ). It is recommended to ask to use optimal partition alignment:

Alignment means that partitions are started on well-known boundaries within the disk, ensuring that operations on the disk from the operating system level (retrieve pages from the disk) use the least amount of internal disk operations. Misaligned partitions might require the disk to fetch two pages instead of one even if the operating system asked for a single page.

To find out about all options supported by parted, type and press return.

Setting the GPT label
Most disks on the or  architectures are prepared using an msdos label. Using, the command to put a GPT label on the disk is :

To have the disk with MBR layout, use.

Removing all partitions with parted
If this isn't done yet (for instance through the operation earlier, or because the disk is a freshly formatted one), first remove all existing partitions from the disk. Type to view the current partitions, and  where NUMBER is the partition to remove.

Do the same for all other partitions that aren't needed. However, make sure to not make any mistakes here - parted executes the changes immediately (unlike which stages them, allowing a user to "undo" his changes before saving or exiting fdisk).

Criando as partições
Now create the partitions. Creating partitions with isn't very difficult - all we need to do is inform parted about the following settings:


 * The partition type to use. This usually is primary. If the msdos partition label is used, keep in mind that there can be no more than 4 primary partitions. If more than 4 partitions are needed, make one of the first four partitions extended and create logical partitions inside it.
 * The start location of a partition (which can be expressed in MB, GB, ...)
 * The end location of the partition (which can be expressed in MB, GB, ...)

First, tell parted that the size unit we work with is megabytes (actually mebibytes, abbreviated as MiB which is the "standard" notation, but we will use MB in the text throughout as it is much more common):

Now create a 2 MB partition that will be used by the GRUB2 boot loader later. Use the command for this, and inform  to start from 1 MB and end at 3 MB (creating a partition of 2 MB in size).

Do the same for the boot partition (128 MB), swap partition (in the example, 512 MB) and the root partition that spans the remaining disk (for which the end location is marked as -1, meaning the end of the disk minus one MB, which is the farthest a partition can go).

When using the UEFI interface to boot the system (instead of BIOS), mark the boot partition as the EFI System Partition. Parted does this automatically when the boot option is set on the partition:

The end result looks like so:

Use the command to exit parted.

Alternative: Using fdisk to partition the disk
The following parts explain how to create the example partition layout using. The example partition layout was mentioned earlier:

Change the partition layout according to personal preference.

Viewing the current partition layout
is a popular and powerful tool to split a disk into partitions. Fire up against the disk (in our example, we use ):

Use the key to display the disk's current partition configuration:

This particular disk is configured to house seven Linux filesystems (each with a corresponding partition listed as "Linux") as well as a swap partition (listed as "Linux swap").

Removing all partitions with fdisk
First remove all existing partitions from the disk. Type to delete a partition. For instance, to delete an existing :

The partition has now been scheduled for deletion. It will no longer show up when printing the list of partitions (, but it will not be erased until the changes have been saved. This allows users to abort the operation if a mistake was made - in that case, type immediately and hit enter and the partition will not be deleted.

Repeatedly type to print out a partition listing and then type  and the number of the partition to delete it. Eventually, the partition table will be empty:

Now that the in-memory partition table is empty, we're ready to create the partitions.

Creating the BIOS boot partition
First create a very small BIOS boot partition. Type to create a new partition, then  to select a primary partition, followed by  to select the first primary partition. When prompted for the first sector, make sure it starts from 2048 (which is needed for the boot loader) and hit enter. When prompted for the last sector, type +2M to create a partition 2 Mbyte in size:

Mark the partition for EFI purposes:

Creating the boot partition
Now create a small boot partition. Type to create a new partition, then  to select a primary partition, followed by  to select the second primary partition. When prompted for the first sector, accept the default by hitting. When prompted for the last sector, type +128M to create a partition 128 Mbyte in size:

Now, when pressing, the following partition printout is displayed:

Type to toggle the bootable flag on a partition and select. After pressing again, notice that an * is placed in the "Boot" column.

Creating the swap partition
To create the swap partition, type to create a new partition, then  to tell fdisk to create a primary partition. Then type to create the third primary partition,. When prompted for the first sector, hit. When prompted for the last sector, type +512M (or any other size needed for the swap space) to create a partition 512MB in size.

After all this is done, type to set the partition type,  to select the partition just created and then type in 82 to set the partition type to "Linux Swap".

Creating the root partition
Finally, to create the root partition, type to create a new partition, then  to tell  to create a primary partition. Then type to create the fourth primary partition,. When prompted for the first sector, hit. When prompted for the last sector, hit to create a partition that takes up the rest of the remaining space on the disk. After completing these steps, typing should display a partition table that looks similar to this:

Saving the partition layout
To save the partition layout and exit, type.

With the partitions created, it is now time to put filesystems on them.