Handbook:PPC/Blocks/Disks

From Gentoo Wiki
Jump to:navigation Jump to:search
This page is a translated version of the page Handbook:PPC/Blocks/Disks and the translation is 52% complete.


Разделы

Несмотря на то, что теоретически возможно использовать весь диск для размещения системы Linux, это почти никогда не делается на практике. Вместо этого, блочное устройство разбивается на меньшие, более управляемые блочные устройства. Во многих системах они называются разделами.

Заметка
In the remainder of the installation instructions, we will use the Pegasos example partition layout. Adjust to personal preference.

Разработка схемы разделов

Сколько разделов и насколько больших?

Расположение разделов на диске сильно зависит от потребностей системы и файловой системы (файловых систем). Если в ней будет много пользователей, рекомендуется разместить /home на отдельном разделе, что улучшит безопасность и значительно упростит резервное копирование (а также другие операции сопровождения). Если Gentoo устанавливается для использования в роли почтового сервера, следует отделить /var, так как вся почта хранится в каталоге /var. Для игровых серверов потребуется отдельный раздел /opt, так как большинство игровых серверов устанавливается туда. Причины выделения те же, что и для каталога /home: безопасность, резервное копирование и сопровождение.

В большинстве случаев /usr и /var должны быть достаточно большого размера. В /usr хранится большинство приложений, доступных системе, а также исходные коды ядра Linux (в каталоге /usr/src). По умолчанию в /var хранится репозиторий пакетов Gentoo (расположенный в /var/db/repos/gentoo), который, в зависимости от файловой системы, занимает около 650 МиБ дискового пространства. Оценка этого пространства не включает каталоги /var/cache/distfiles и /var/cache/binpkgs, в которых будут скапливаться архивы исходных кодов и (не обязательно) двоичных пакетов, которые будут формироваться в самой системе.

Сколько именно и какого объёма разделов нужно системе — всё зависит от сочетания различных факторов, которые необходимо принимать во внимание. Наличие отдельных разделов или томов имеет следующие плюсы:

  • Можно выбрать наиболее подходящую файловую систему для каждого раздела или тома.
  • Свободное место во всей системе не закончится внезапно из-за того, что одна-единственная сбойная программа постоянно записывает файлы в раздел или том.
  • Необходимая проверка файловых систем будет занимать меньше времени, так как проверка разных разделов может выполняться параллельно (хотя это это преимущество относится больше к нескольким дискам, чем к нескольким разделам).
  • Можно повысить безопасность системы, монтируя часть разделов в режиме только для чтения, nosuid (игнорируется бит setuid), noexec (игнорируется бит исполнения) и так далее.


Однако у множества разделов также есть недостатки:

  • Если они не настроены правильно, может получиться так, что будет огромное количество свободного места на одном разделе и нехватка на другом.
  • Отдельный раздел для /usr/ может потребовать загрузки с initramfs, чтобы смонтировать раздел прежде, чем запустятся другие загрузочные сценарии. Так как сборка initramfs выходит за рамки данного руководства, мы рекомендуем новичкам не создавать отдельный раздел для /usr/.
  • Также существует лимит в 15 разделов для SCSI и SATA, если только на диске не используются метки GPT.
Заметка
Если планируется использовать systemd в качестве системы инициализации и управления службами, то при загрузке системы должен быть доступен каталог /usr, либо как часть корневой файловой системы, либо смонтированный через initramfs.

Что по поводу пространства подкачки?

Не существует идеального значения для раздела подкачки. Целью пространства подкачки является предоставление дискового пространства ядру в условиях активного использования оперативной памяти. Пространство подкачки позволяет ядру переносить на диск страницы оперативной памяти, которые не будут использоваться в ближайшее время, освобождая её (swap или page-out). Конечно, если эта память вдруг неожиданно понадобится, эти страницы должны быть помещены обратно в память (page-in), что займет намного больше времени, чем чтение с оперативной памяти (так как диски — это очень медленные устройства по сравнению с оперативной памятью).

Если на системе не требуется запускать приложения, требовательные к памяти, либо изначально доступно очень много памяти, то, скорее всего, необходимости в пространстве подкачки нет. Однако раздел подкачки также используется для сохранения всей памяти в случае перехода системы в спящий режим (более вероятно на ноутбуках и десктопах, чем на серверах). Если планируется использовать этот режим, нужно пространство подкачки, равное или больше чем количеству оперативной памяти.

Как правило, рекомендуется создавать пространство подкачки с размером в два раза больше оперативной памяти (ОЗУ). Для систем с несколькими дисками, целесообразно создать по одному разделу подкачки на каждом диске, чтобы их можно было использовать для параллельных операций чтения/записи. Чем быстрее диск может подкачивать, тем быстрее система будет работать, когда ей необходимо прочитать данные с пространства подкачки. При выборе между жестким диском и твердотельным накопителем, с точки зрения производительности лучше создать пространство подкачки на SSD. Также вы можете использовать файлы подкачки вместо разделов подкачки; в основном это необходимо для систем с очень ограниченным дисковым пространством.


Apple New World

Apple New World machines are fairly straightforward to configure. The first partition is always an Apple Partition Map (APM). This partition keeps track of the layout of the disk. It is not possible to remove this partition. The next partition should always be a bootstrap partition. This partition contains a small (800KiB) HFS filesystem that holds a copy of the bootloader Yaboot and its configuration file. This partition is not the same as a /boot partition as found on other architectures. After the boot partition, the usual Linux filesystems are placed, according to the scheme below. The swap partition is a temporary storage place for when the system runs out of physical memory. The root partition will contain the filesystem that Gentoo is installed on. To dual boot, the OSX partition can go anywhere after the bootstrap partition to insure that yaboot starts first.

Заметка
There may be "Disk Driver" partitions on the disk such as Apple_Driver63, Apple_Driver_ATA, Apple_FWDriver, Apple_Driver_IOKit, and Apple_Patches. These are used to boot MacOS, so if there is no need for this, they can be removed by initializing the disk with mac-fdisk's i option. Be careful, this will completely erase the disk! If in doubt do not remove them.
Заметка
If the disk is partitioned with Apple's Disk Utility, there may be 128 MiB spaces between partitions which Apple reserves for "future use". These can be safely removed.
Раздел Размер Файловая система Описание
/dev/sda1 32 КиБ Нет. Apple Partition Map (APM).
/dev/sda2 800 КиБ HFS Apple bootstrap.
/dev/sda3 512 МиБ swap Раздел подкачки Linux (тип 0x82).
/dev/sda4 Оставшееся пространство диска. ext4, xfs и т.д. Корневой раздел Linux.

Apple Old World

Apple Old World machines are a bit more complicated to configure. The first partition is always an Apple Partition Map (APM). This partition keeps track of the layout of the disk. It is not possible to remove this partition. When using BootX, the configuration below assumes that MacOS is installed on a separate disk. If this is not the case, there will be additional partitions for "Apple Disk Drivers" such as Apple_Driver63, Apple_Driver_ATA, Apple_FWDriver, Apple_Driver_IOKit, Apple_Patches and the MacOS install. When using Quik, it is necessary to create a boot partition to hold the kernel, unlike other Apple boot methods. After the boot partition, the usual Linux filesystems are placed, according to the scheme below. The swap partition is a temporary storage place for when the system runs out of physical memory. The root partition will contain the filesystem that Gentoo is installed on.

Заметка
When using an Old World machine, it is necessary to keep MacOS available. The layout here assumes MacOS is installed on a separate drive.

Пример схемы разбивки диска для систем Old World:

Раздел Размер Файловая система Описание
/dev/sda1 32 КиБ Нет. Apple Partition Map (APM).
/dev/sda2 32 КиБ ext2 Загрузочный раздел Quik (только для quik).
/dev/sda3 512 МиБ swap Раздел подкачки Linux (тип 0x82).
/dev/sda4 Оставшееся пространство диска. ext4, xfs и т.д. Корневой раздел Linux.

Pegasos

The Pegasos partition layout is quite simple compared to the Apple layouts. The first partition is a boot partition, which contains kernels to be booted along with an Open Firmware script that presents a menu on boot. After the boot partition, the usual Linux filesystems are placed, according to the scheme below. The swap partition is a temporary storage place for when the system runs out of physical memory. The root partition will contain the filesystem that Gentoo is installed on.

Пример схемы разбивки диска для систем Pegasos:

Раздел Размер Файловая система Описание
/dev/sda1 32 МиБ affs1 или ext2 Загрузочный раздел.
/dev/sda2 512 МиБ swap Раздел подкачки Linux (тип 0x82).
/dev/sda3 Оставшееся пространство диска. ext4, xfs и т.д. Корневой раздел Linux.

IBM PReP (RS/6000)

The IBM PowerPC Reference Platform (PReP) requires a small PReP boot partition on the disk's first partition, followed by the swap and root partitions.

Пример схемы разбивки диска для систем IBM PReP:

Раздел Размер Файловая система Описание
/dev/sda1 800 КиБ нет Загрузочный раздел PReP (тип 0x41).
/dev/sda2 512 МиБ swap Раздел подкачки Linux (тип 0x82).
/dev/sda3 Оставшееся пространство диска. ext4, xfs и т.д. Корневой раздел Linux (тип 0x83).
Предупреждение
parted is able to resize partitions including HFS+. Unfortunately there may be issues with resizing HFS+ journaled filesystems, so, for the best results, switch off journaling in Mac OS X before resizing. Remember that any resizing operation is dangerous, so attempt at own risk! Be sure to always have a backup of all data before resizing!

Использование mac-fdisk (Apple)

Для начала создайте разделы с помощью mac-fdisk:

root #mac-fdisk /dev/sda

If Apple's Disk Utility was used prior to leave space for Linux, first delete the partitions that might have been created previously to make room for the new install. Use d in mac-fdisk to delete those partition(s). It will ask for the partition number to delete. Usually the first partition on NewWorld machines (Apple_partition_map) cannot be deleted. To start with a clean disk, simply initialize the disk by pressing i. This will completely erase the disk, so use this with caution.

Second, create an Apple_Bootstrap partition by using b. It will ask for what block to start. Enter the number of the first free partition, followed by a p. For instance this is 2p.

Заметка
This partition is not a /boot partition. It is not used by Linux at all; there is no need to place any filesystem on it and it should never be mounted. Apple users don't need an extra partition for /boot.

Now create a swap partition by pressing c. Again mac-fdisk will ask for what block to start this partition from. As we used 2 before to create the Apple_Bootstrap partition, now enter 3p. When sked for the size, enter 512M (or whatever size needed - a minimum of 512MiB is recommended, but 2 times the physical memory is the generally accepted size). When asked for a name, enter swap.

To create the root partition, enter c, followed by 4p to select from what block the root partition should start. When asked for the size, enter 4p again. mac-fdisk will interpret this as "Use all available space". When asked for the name, enter root.

To finish up, write the partition to the disk using w and q to quit mac-fdisk.

Заметка
To make sure everything is okay, run mac-fdisk -l and check whether all the partitions are there. If not all partitions created previously are shown, or the changes made are not reflected in the output, reinitialize the partitions by pressing i in mac-fdisk. Note that this will recreate the partition map and thus remove all existing partitions.

Использование parted (Pegasos и RS/6000)

parted, the partition editor, can now handle HFS+ partitions used by Mac OS and Mac OS X. With this tool it is possible to resize the Mac partitions and create space for the Linux partitions. Nevertheless, the example below describes partitioning for Pegasos machines only.

Чтобы продолжить, давайте запустим parted:

root #parted /dev/sda

If the drive is unpartitioned, run mklabel amiga to create a new disklabel for the drive.

It is possible to type print at any time in parted to display the current partition table. To abort parted, press Ctrl+c.

If next to Linux, the system is also meant to have MorphOS installed, then create an affs1 filesystem at the start of the drive. 32MB should be more than enough to store the MorphOS kernel. With a Pegasos I, or when Linux will use any filesystem besides ext2 or ext3, then it is necessary to also store the Linux kernel on this partition (the Pegasos II can only boot from ext2/ext3 or affs1 partitions). To create the partition run mkpart primary affs1 START END where START and END should be replaced with the megabyte range (e.g. 0 32) which creates a 32 MB partition starting at 0MB and ending at 32MB. When creating an ext2 or ext3 partition instead, substitute ext2 or ext3 for affs1 in the mkpart command.

Create two partitions for Linux, one root filesystem and one swap partition. Run mkpart primary START END to create each partition, replacing START and END with the desired megabyte boundaries.

It is generally recommended to create a swap partition that is two times bigger than the amount of RAM in the computer, but at least 512MiB is recommended. To create the swap partition, run mkpart primary linux-swap START END with START and END again denoting the partition boundaries.

Просто введите quit, когда закончите с parted.