Difference between revisions of "Partitioning (Русский)"
(Template:i18n is deprecated, use interlanguage links, see Help talk:I18n#"Dummy" interlanguage links and deprecation of Template:i18n)
|Line 1:||Line 1:|
Revision as of 11:08, 2 December 2012
- 1 Обзор
- 2 Инструменты для работы с разделами
- 3 Стратегии разбиения на разделы
- 4 Важные моменты
- 5 Creating new partitions
- 6 Resizing partitions
- 7 Content from BG
- Что такое разделы жёсткого диска?
- Зачем разбивать на разделы жёсткий диск?
Разбиение жёсткого диска позволяет логически разделить всё доступное пространство на части, которые будут независимыми друг от друга. Информация о разделах хранится внутри MBR жёсткого диска.
Существует несколько причин для разбиение диска на разделы:
- на компьютере используется несколько операционных систем (двойная, мультизагрузка)
- есть необходимость использовать раздел подкачки swap
- необходимо разделить данные логически (например, видеоклипы от фонотеки)
- и др.
Все разделы первичные +-------------+-------------+-------------+---------------------------------+ | Первичный 1 | Первичный 2 | Первичный 3 | Первичный 4 | +-------------+-------------+-------------+---------------------------------+ Два первичных раздела и один расширенный, с двумя логическими +----------------+------------------+---------------------------------------+ | Первичный 1 | Первичный 2 | Расширенный | | | | +--------------------+--------------+ | | | | | Логический 1 | Логический 2 | | | | | +-----------------------------------+ | +----------------+------------------+-------------+-------------------------+
Инструменты для работы с разделами
- fdisk & cfdisk
- GNU Parted
- QtParted & GParted
Стратегии разбиения на разделы
- "Всё в одном"
- Отдельный раздел /boot
- Отдельный разделSeparate /home
- Отдельный разделSeparate /var
- Отдельный разделSeparate /usr
- Размеры разделов
- Файловые системы
Creating new partitions
Content from BG
Посмотреть на текущую таблицу разделов можно с помощью программы
/sbin/fdisk с ключом
-l (маленькая L).
Откройте другую виртуальную консоль (<ALT>+F3) и введите:
# fdisk -l
Отметьте для себя все диски/разделы, которые вы будите использовать при установке Arch.
Вернитесь назад в консоль, где запущен скрипт установки <ALT>+F1
Выберете пункт "Prepare Hard Drive".
- Вариант 1: Auto Prepare
Этот пункт поделит диск со следующими параметрами:
- Загрузочный раздел с ФС ext2; точка монтирования: /boot; размер по умолчанию: 32MB. Вам будет предложено изменить размер по своему усмотрению.
- Раздел подкачки swap, размер по умолчанию: 256MB. Вам будет предложено изменить размер по своему усмотрению.
- Отдельные корневой(/) и /home разделы, (размеры тоже можно указать вручную). Возможные файловые системы: ext2, ext3, ext4, reiserfs, xfs and jfs, однако, обратите внимание, что при выборе опции Auto Prepare, файловые системы / и /home будут одного типа.
Будьте внимательны, опция Auto-prepare полностью сотрёт выбранный жёсткий диск. Внимательно прочитайте предупреждение, предоставленное установщиком, и убедитесь,что действия производятся над нужным разделом.
- Вариант 2: (Рекомендуемый) Partition Hard Drives (with cfdisk)
Эта опция предоставит наиболее надёжный и настраиваемый способ разбивки, отвечающий вашим персональным нуждам.
Здесь более продвинутые пользователи GNU/Linux, хорошо знакомые с ручной разбивкой диска, могут сразу перейти к разделу D: Select Packages.
Partition Hard Drives
Partitioning a hard disk drive defines specific areas (the partitions) within the disk, that will each appear and behave as a separate disk and upon which a filesystem may be created (formatted).
- There are 3 types of disk partitions:
Primary partitions can be bootable, and are limited to 4 partitions per disk or raid volume. If a partitioning scheme requires more than 4 partitions, an extended partition which will contain logical partitions will be required.
Extended partitions are not usable by themselves; they are merely a "container" for logical partitions. If required, a hard disk shall contain only one extended partition; which shall then be sub-divided into logical partitions.
When partitioning a disk, one can observe this numbering scheme by creating primary partitions sda1 through sda3 followed by creating an extended partition, sda4, and subsequently creating logical partition(s) within the extended partition; sda5, sda6, and so on.
A swap partition is a place on the drive where virtual ram resides, allowing the kernel to easily use disk storage for data that does not fit into physical RAM.
Historically, the general rule for swap partition size was 2x the amount of physical RAM. Over time, as computers have gained ever larger memory capacities, this rule has become increasingly deprecated. Generally, on machines with up to 512MB RAM, the 2x rule is usually quite sufficient. If the installation machine provides gratuitous amounts of RAM (more than 1024 MB) it may be possible to completely forget a swap partition altogether, since the option to create a swap file is always available later. A 1 GB swap partition will be used in this example.
A disk partitioning scheme is a very personalized preference. Each user's choices will be unique to their own computing habits and requirements. If you would like to dual boot Arch Linux and a Windows operating system please see Windows and Arch Dual Boot.
Filesystem candidates for separate partitions include:
/ (root) The root filesystem is the primary filesystem from which all other filesystems stem; the top of the hierarchy. All files and directories appear under the root directory "/", even if they are stored on different physical devices. The contents of the root filesystem must be adequate to boot, restore, recover, and/or repair the system. Therefore, certain directories under / are not themselves candidates for separate partitions. (See warning below).
/boot This directory contains the kernel and ramdisk images as well as the bootloader configuration file, and bootloader stages. /boot also stores data that is used before the kernel begins executing userspace programs. This may include saved master boot sectors and sector map files. /boot is essential for booting, but is unique in that it may still be kept on its own separate partition (if required).
/home Provides subdirectories, each named for a system user, for miscellaneous personal data storage as well as user-specific configuration files for applications.
/usr While root is the primary filesystem, /usr is the secondary hierarchy for all system users' data, including the majority of multi-user utilities and applications. /usr is shareable, read-only data. This means that /usr shall be shareable between various hosts and must not be written to, except in the case of system update/upgrade. Any information that is host-specific or varies with time is stored elsewhere.
/tmp directory for programs that require temporary files such as '.lck' files, which can be used to prevent multiple instances of their respective program until a task is completed, at which point the '.lck' file will be removed. Programs must not assume that any files or directories in /tmp are preserved between invocations of the program and files and directories located under /tmp will typically be deleted whenever the system is booted.
/var contains variable data; spool directories and files, administrative and logging data, pacman's cache, the ABS tree, etc. /var exists in order to make it possible to mount /usr as read-only. Everything that historically went into /usr that is written to during system operation (as opposed to installation and software maintenance) must reside under /var.
There are several advantages for using discrete filesystems, rather than combining all into one partition:
- Security: Each filesystem may be configured in /etc/fstab as 'nosuid', 'nodev', 'noexec', 'readonly', etc.
- Stability: A user, or malfunctioning program can completely fill a filesystem with garbage if they have write permissions for it. Critical programs, which reside on a different filesystem remain unaffected.
- Speed: A filesystem which gets written to frequently may become somewhat fragmented. (An effective method of avoiding fragmentation is to ensure that each filesystem is never in danger of filling up completely.) Separate filesystems remain unaffected, and each can be defragmented separately as well.
- Integrity: If one filesystem becomes corrupted, separate filesystems remain unaffected.
- Versatility: Sharing data across several systems becomes more expedient when independent filesystems are used. Separate filesystem types may also be chosen based upon the nature of data and usage.
In this example, we shall use separate partitions for /, /var, /home, and a swap partition.
How big should my partitions be?
This question is best answered based upon individual needs. You may wish to simply create one partition for root and one partition for swap or only one root partition without swap or refer to the following examples and consider these guidelines to provide a frame of reference:
- The root filesystem (/) in the example will contain the /usr directory, which can become moderately large, depending upon how much software is installed. 15-20 GB should be sufficient for most users.
- The /var filesystem will contain, among other data, the ABS tree and the pacman cache. Keeping cached packages is useful and versatile; it provides the ability to downgrade packages if needed. /var tends to grow in size; the pacman cache can grow large over long periods of time, but can be safely cleared if needed. If you are using an SSD, you may wish to locate your /var on an HDD and keep the / and /home partitions on your SSD to avoid needless read/writes to the SSD. 8-12 Gigs on a desktop system should be sufficient for /var, depending largely upon how much software you intend to install. Servers tend to have relatively larger /var filesystems.
- The /home filesystem is typically where user data, downloads, and multimedia reside. On a desktop system, /home is typically the largest filesystem on the drive by a large margin. Remember that if you chose to reinstall Arch, all the data on your /home partition will be untouched (so long as you have a separate /home partition).
- An extra 25% of space added to each filesystem will provide a cushion for unforeseen occurrence, expansion, and serve as a preventive against fragmentation.
From the guidelines above, the example system shall contain a ~15GB root (/) partition, ~10GB /var, 1GB swap, and a /home containing the remaining disk space.
Start by creating the primary partition that will contain the root, (/) filesystem.
Choose New -> Primary and enter the desired size for root (/). Put the partition at the beginning of the disk.
Also choose the Type by designating it as '83 Linux'. The created / partition shall appear as sda1 in our example.
Now create a primary partition for /var, designating it as Type 83 Linux. The created /var partition shall appear as sda2
Next, create a partition for swap. Select an appropriate size and specify the Type as 82 (Linux swap / Solaris). The created swap partition shall appear as sda3.
Lastly, create a partition for your /home directory. Choose another primary partition and set the desired size.
Likewise, select the Type as 83 Linux. The created /home partition shall appear as sda4.
Name Flags Part Type FS Type [Label] Size (MB) ------------------------------------------------------------------------- sda1 Primary Linux 15440 #root sda2 Primary Linux 10256 #/var sda3 Primary Linux swap / Solaris 1024 #swap sda4 Primary Linux 140480 #/home
Choose Write and type 'yes'. Beware that this operation may destroy data on your disk. Choose Quit to leave the partitioner. Choose Done to leave this menu and continue with "Set Filesystem Mountpoints".
Set Filesystem Mountpoints
Specify each partition and corresponding mountpoint to your requirements. (Recall that partitions end in a number. Therefore, sda is not itself a partition, but rather, signifies an entire drive)
Again, a filesystem type is a very subjective matter which comes down to personal preference. Each has its own advantages, disadvantages, and unique idiosyncrasies. Here is a very brief overview of supported filesystems:
1. ext2 Second Extended Filesystem- Old, reliable GNU/Linux filesystem. Very stable, but without journaling support. May be inconvenient for root (/) and /home, due to very long fsck's. An ext2 filesystem can easily be converted to ext3. Generally regarded as a good choice for /boot/.
2. ext3 Third Extended Filesystem- Essentially the ext2 system, but with journaling support. ext3 is backward compatible with ext2. Extremely stable, mature, and by far the most widely used, supported and developed GNU/Linux FS.
High Performance Filesystems:
3. ext4 Fourth Extended Filesystem- Backward compatible with ext2 and ext3. Introduces support for volumes with sizes up to 1 exabyte and files with sizes up to 16 terabytes. Increases the 32,000 subdirectory limit in ext3 to 64,000. Offers online defragmentation ability.
4. ReiserFS (V3)- Hans Reiser's high-performance journaling FS uses a very interesting method of data throughput based on an unconventional and creative algorithm. ReiserFS is touted as very fast, especially when dealing with many small files. ReiserFS is fast at formatting, yet comparatively slow at mounting. Quite mature and stable. ReiserFS is not actively developed at this time (Reiser4 is the new Reiser filesystem). Generally regarded as a good choice for /var/.
5. JFS - IBM's Journaled FileSystem- The first filesystem to offer journaling. JFS had many years of use in the IBM AIX® OS before being ported to GNU/Linux. JFS currently uses the least CPU resources of any GNU/Linux filesystem. Very fast at formatting, mounting and fsck's, and very good all-around performance, especially in conjunction with the deadline I/O scheduler. (See JFS.) Not as widely supported as ext or ReiserFS, but very mature and stable.
6. XFS - Another early journaling filesystem originally developed by Silicon Graphics for the IRIX OS and ported to GNU/Linux. XFS offers very fast throughput on large files and large filesystems. Very fast at formatting and mounting. Generally benchmarked as slower with many small files, in comparison to other filesystems. XFS is very mature and offers online defragmentation ability.
- JFS and XFS filesystems cannot be shrunk by disk utilities (such as gparted or parted magic)
A note on Journaling
All above filesystems, except ext2, utilize journaling. Journaling file systems are fault-resilient file systems that use a journal to log changes before they are committed to the file system to avoid metadata corruption in the event of a crash. Note that not all journaling techniques are alike; specifically, only ext3 and ext4 offer data-mode journaling, (though, not by default), which journals both data and meta-data (but with a significant speed penalty). The others only offer ordered-mode journaling, which journals meta-data only. While all will return your filesystem to a valid state after recovering from a crash, data-mode journaling offers the greatest protection against file system corruption and data loss but can suffer from performance degradation, as all data is written twice (first to the journal, then to the disk). Depending upon how important your data is, this may be a consideration in choosing your filesystem type.
Choose and create the filesystem (format the partition) for / by selecting yes. You will now be prompted to add any additional partitions. In our example, sda2 and sda4 remain. For sda2, choose a filesystem type and mount it as /var. Finally, choose the filesystem type for sda4, and mount it as /home. Template:Box Note Return to the main menu.