Difference between revisions of "Partitioning (Русский)"

From ArchWiki
Jump to navigation Jump to search
Line 34: Line 34:
==Partitioning tools==
== Инструменты для работы с разделами ==
* fdisk & cfdisk
* fdisk & cfdisk
* GNU Parted
* GNU Parted

Revision as of 22:06, 30 September 2010


Tango-preferences-desktop-locale.pngThis article or section needs to be translated.Tango-preferences-desktop-locale.png

Notes: please use the first argument of the template to provide more detailed indications. (Discuss in Talk:Partitioning (Русский)#)


Note: В настоящий момент статья переводится. Вы можете помочь завершить перевод скорее :)
Warning: Оригинальная английская статья ещё не завершена, к моменту начала перевода текст может оказаться устаревшим.


  • Что такое разделы жёсткого диска?
  • Зачем разбивать на разделы жёсткий диск?

Разбиение жёсткого диска позволяет логически разделить всё доступное пространство на части, которые будут независимыми друг от друга. Информация о разделах хранится внутри MBR жёсткого диска.

Существует несколько причин для разбиение диска на разделы:

  • на компьютере используется несколько операционных систем (двойная, мультизагрузка)
  • есть необходимость использовать раздел подкачки swap
  • необходимо разделить данные логически (например, видеоклипы от фонотеки)
  • и др.

Template:Box YELLOW

Все разделы первичные
| Первичный 1 | Первичный 2 | Первичный 3 | Первичный 4                     |

Два первичных раздела и один расширенный, с двумя логическими
| Первичный 1    | Первичный 2      | Расширенный                           |
|                |                  | +--------------------+--------------+ |
|                |                  | | Логический 1       | Логический 2 | |
|                |                  | +-----------------------------------+ |

Инструменты для работы с разделами

  • fdisk & cfdisk
  • GNU Parted
  • QtParted & GParted

Partitioning schemes

  • "All-in-one"
  • Separate /boot
  • Separate /home
  • Separate /var
  • Separate /usr


  • Partition sizes
  • File systems
  • LVM

Creating new partitions

Resizing partitions

Content from BG

Warning: Partitioning hard drives can destroy data. You are strongly cautioned and advised to backup your critical data if applicable.
Warning: Choosing the Cancel button in the Prepare Hard Drive menu will not cancel the operations you have selected - see FS#19805. If you must cancel the installation from this menu, press <Control>+C to exit the installer completely and immediately.
Note: Partitioning may be performed before initiating the Arch installation if desired, by utilizing GParted or other available tools. If the installation drive has already been partitioned to the required specifications, continue with Set Filesystem Mountpoints

Verify current disk identities and layout by invoking /sbin/fdisk with the -l (lower-case L) switch.

Open another virtual console (<ALT>+F3) and enter:

# fdisk -l

Take note of the disk(s)/partition(s) to utilize for the Arch installation.

Switch back to the installation script with <ALT>+F1

Select the first menu entry "Prepare Hard Drive".

  • Option 1: Auto Prepare

Auto-Prepare divides the disk into the following configuration:

  • ext2 /boot partition, default size 32MB. You will be prompted to modify the size to your requirement.
  • swap partition, default size 256MB. You will be prompted to modify the size to your requirement.
  • A Separate / and /home partition, (sizes can also be specified). Available filesystems include ext2, ext3, ext4, reiserfs, xfs and jfs, but note that both / and /home shall share the same fs type if choosing the Auto Prepare option.

Be warned that Auto-prepare will completely erase the chosen hard drive. Read the warning presented by the installer very carefully, and make sure the correct device is about to be partitioned.

  • Option 2: (Recommended) Partition Hard Drives (with cfdisk)

This option will allow for the most robust and customized partitioning solution for your personal needs.

At this point, more advanced GNU/Linux users who are familiar and comfortable with manually partitioning may wish to skip down to D: Select Packages below.

Note: If you are installing to a USB flash key, see "Installing Arch Linux on a USB key".

Partition Hard Drives

Partition Info

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:
  1. Primary
  2. Extended
  3. Logical

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.

Swap Partition

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.

Note: If using suspend-to-disk, (hibernate) a swap partition at least equal in size to the amount of physical RAM is required. Some Arch users even recommend oversizing it beyond the amount of physical RAM by 10-15%, to allow for possible bad sectors.
Partition Scheme

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.

Warning: Besides /boot, directories essential for booting are: '/bin', '/etc', '/lib', and '/sbin'. Therefore, they must not reside on a separate partition from /.

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.

Note: /var contains many small files. This should be taken into consideration when choosing a filesystem type for it, (if creating its own separate 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.

Create Partition:cfdisk

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".

Note: Since the latest developments of the Linux kernel which include the libata and PATA modules, all IDE, SATA and SCSI drives have adopted the sdx naming scheme. This is perfectly normal and should not be a concern.

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)

Filesystem Types

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.

Moving on...

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.