Template:Article summary start Template:Article summary text Template:Article summary heading Template:Article summary wiki Template:Article summary wiki Template:Article summary wiki Template:Article summary end
Disk partitioning is the act of dividing a hard disk drive into multiple virtual hard disk drives, referred to as partitions, to treat one physical disk drive as if it were multiple disks.
- 1 Panoramica
- 2 Strumenti di partizionamento
- 3 Schemi di partizionamento
- 4 Considerations
- 5 Creating new partitions
- 6 Resizing partitions
- 7 Content from Beginners' Guide
- Cosa è il partizionamento?
- Perchè partizionare?
Partizionare un disco consente di dividere lo spazio disponibile in diverse sezioni a cui sarà possibile accedere indipendentemente l'una dall'altra. Le informazioni sulle partizioni risiedono sul MBR del disco.
Un disco può essere allocato in una singola partizione, oppre può essere diviso in diverse partizioni. In diverse condizioni è necessaria la creazioni di partizioni multiple: sistemi dual- o multi-boot, oppure per avere una partizione di swap. In altri casi, il partizionamento è usato per suddividere in maniera logica i dati, come la creazioni di partizioni dedicate per i file audio e i file video. Gli schemi di partizionamento più comuni saranno discussi più avanti.
Sarà possibile creare fino a quattro partizioni primarie per ogni disco. Se sarà necessario creare un numero maggiore di partizioni è possibile creare una partizione estesa (avremo quindi fino a tre partizioni primarie ed una partizione estesa). Una partizione estesa può essere suddivisa a sua volta in un numero non limitato di partizioni logiche.
Strumenti di partizionamento
- fdisk - Lo strumento di partizionamento di Linux(da terminale). Contenuto nel pacchetto Template:Package Official.
- cfdisk - Uno strumento di partizionamento per Linux scritto con le librerie curse(da terminale). Contenuto nel pacchetto Template:Package Official.
- GNU Parted - Un altro strumento di partizionamento per Linux, esso consente anche il ridimensionamento e la copia delle partizioni.
- Partitionmanager - uno strumento grafico scritto con le Qt
- QtParted - uno strumento grafico scritto con le Qt, alternativa a Partitionmanager reperibile su AUR.
- GParted - uno strumento grafico scritto in GTK
Schemi di partizionamento
Di seguito verranno elencate le cartelle che comunemente vengono separate, ed le relative motivazioni e caratteristiche. Per ulteriori informazioni riguardo alla struttura del filesystem ed alle funzioni delle varie cartelle consultare Filesystem Hierarchy Standard
- Una unica partizione per l'intero disco.
Partizione /boot separata
- Questa partizione è necessaria solo durante la fase di boot (e durante la rigenerazione del ramdisk)
- Non è richiesta per le normali operazioni di sistema.
- L'uso del journaling non è necessario.
- Può essere necessario averla separata se si effettua il boot di un sistema installato su un RAID0(stripe).
Partizione /home separata
- Semplifica le procedure di backup l'uso di sistemi multi-boot(ad. esempio si può utilizzare la partizone Template:Filename per due distribuzioni diverse, anche se non è consigliato utilizzare il solito utente, dato che le versioni dei software e le loro configurazioni potrebbero differire).
- La partizione Template:Filename spesso richiede molto spazio(per gli utenti desktop) e può essere necessario espanderla in un secondo momento.
Partizione /var separata
- Questa partizione subisce molti accessi in lettura/scrittura(vi risiedono i log e la cache)
- Impedisce di riempire il disco a causa di log malfuznionanti, ecc.
- A volte può essere utile anche per motivi di sicurezza, impedendo l'esecuzione di programmi dall'interno di essa(questa cartella può essere scritta da tutti gli utenti).
Partizione /usr separata
- Può essere condivisa da più sistemi.
- Partition sizes
- File systems
Creating new partitions
Content from Beginners' Guide
(See the Beginners' Guide for up-to-date content.)
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.
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.