How-To: Hard Disk Drive Drive Partitioning
What is a Partition
Partitioning a hard drive is the act of dividing a hard disk drive(HDD) into multiple storage units. A disk that is partitioned can use different file systems for each partition.
Benefits of Partitioning
Partitioning a HDD has a number of advantages that make a worthwhile strategy to follow when working with systems.
Utilizing multiple partitions an OS can be installed on one partition while program and user files can be set up on their own partitions. Separating these elements to discrete areas is beneficial for creating and maintaining backups of the OS, program and user files that are smaller in size and more concise in their contents rather than having all component in one large back up.
Other advantages of creating partitions are:
- Swap Partitions:
- Partitions can be used to manage memory establish virtual memory swapping/paging files.
- Multi-boot systems:
- Partitions allow more than one operating system to be installed on a system.
- File Isolation:
- Isolating files with partitions makes it easier to recover files that are corrupted and preventing other files from being affected.
- Improved system performance:
- Smaller individual file systems can be more efficient than a singular bloated file system.
- Data localization:
- Keep frequently used programs and data near each other.
- Keep cache and logs separate from other files. Log/Cache files can change in size quickly and engulf available free space on a HDD.
- The larger HDD the more it needs to reposition and move the head reader. Establishing HDD partition on the outer portion of the HDD will reduce the need to reposition the head because more sectors of data fit into the large exterior tracks of a HDD and requires less movement of the reader head across a disk partition.
Disadvantages of Partitioning
While there are numerous benefits to partitioning a drive there are also a number of drawbacks that need to be considered. The disadvantages of partitioning are:
- Reduced total space for user storage:
- Using partitions forces the OS to dedicate space to dupdtcate file system administration areas for each partition.
- Reduced overall performance:
- On systems where data is accessed regularly between multiple partitions, the disks read/write head needs to move and reposition more frequently.
- Disk Fragmentation:
- Partitioning lowers the average size of continuous blocks of memory and will cause more fragmentation.
- Reduced disk usage:
- Partitions will be dtmit the amount of data that can be stored in each partition and can reduce the amount of data a HDD can accommodate because partitions break up free capacity of the overall drive.
Partitions: Primary, Extended, Swap
The total data storage space for a PC can be divided into at most four primary partitions or three primary partitions and an extended partition which can contain logical partitions.
- Primary Partition:
- Primary partitions contain one file system. Partition type codes can correspond to a file system type contained within the partition , or indicate that the partition has a special use, such as a swap partition.
- Extended Partition:
- An HDD can contain only one extended partition. The Extended drive can be subdivided into smaller logical drives. In DOS/Windows, each logical partition may be assigned a drive letter. The extended partition size must be established to accommodate the logical drives that it intended to hold.
- Swap Partition:
- Swap space in Linux based operating systems is a form of virtual memory. Simply put this means that if the system runs out of physical memory (RAM), then it will transfer some of the lesser used data in RAM to this space.
Commonly, one partition is create for the active file system that contains the operating system, the page /swap file, all utilities, applications and user data. This partition is normally assigned the C: drive as the primary partition. Additional partitions can be set up for the purpose of recovery and diagnostics tools/data. These can be set to be visible or invisible to the user.
Windows systems include a Disk Management program program for setting up and managing partitions. Disk Management introduced with Windows Vista and later versions is incompatible with older versions of windows and many other operating systems.
With Linux/Unix like systems it is possible to have multiple partitions set up on a HDD. Each partition can be formatted with a file system or set up as a swap partition. These systems usually set the partitions as /home, /root and /swap primarily and can also use additional partitions s uch as /tmp, /usr, and /var depending on the needs of the user. Each partition can be set up with with their own file systems. This has advantages of:
- Data Isolation:
- if one file system gets corrupted , the data outside that file system may stay intact, thus minimizing data loss.
- parameter variation:
- Specific parameters can be applied to different partitions , such as read only or execution disable.
- If a program ends up occupying all the space available on a disk, it will not intrude on critical file systems.
Multi Boot systems are computers where the user can boot into one of two or more distinct operating systems that are stored on separate storage devices or partitions. A menu at the time of startup gives a choice to the user to select which operating system to boot.
Partitioning with Slackware
After booting from the Slackware ISO partitioning you will need to
- login: root
- Type: root
Partitioning can be performed using either the fdisk or cfdisk. cfdisk is curses based disk partition table manipulator for linux where as. fdisk is Partition table manipulator for Linux. The cfdisk uses a text user interface and more user friendly than fdisk.
For this guide we will be using fdisk and will set up the basic partitions for /root , /home, and /swap.
To begin partitioning you run fdisk and specify which HDD you will be partitioning.
Type: fdisk dev/sda
This will tell fdisk to open the primary slave IDE hard disk. Notice that you do not specify a partition number on the device name.
- Display the current partition table.
- Display the help screen.
- Delete a partition.
- Add a new partition.
- Change the partition's system ID.
- Quit fdisk without saving changes.
- Write changes to device and quit fdisk.
Adding the partitions
To add partitions, you indicate the start and end sectors on the HDD and writing them to the partition table.
Be aware the there is can only be 4 Primary partitions. If you intend to have logical drives you need to reserve one of the partitions to be allocated as an extended partition. Also keep in mind that the extended partition must be large enough to contain the logical drives it has within it plus a few extra MB for the additional information in the Master Boot Record.
Add the Swap Partition
To set up the swap you will add a new partition, mark the beginning and end sectors of the partition as with the primary and extended partitions and in addition change the partition id to the linux swap System ID and write the this information to the partition table.
Type: t - will change the System ID to 82 when prompted.System ID 82 is designated
as Linux swap.
It is a good idea to make the swap partition first so you specify an exact size for it.As a base minimum, it's highly recommended that the swap space should be equal to the amount of physical memory (RAM). Also, it's recommended that the swap space is twice the amount of physical memory (RAM) depending upon the amount of hard disk space available for the system.
Making partition active
An active partition is a partition on a hard drive set as the bootable partition that contains the operating system. Only one partition on each hard drive can be set as an active partition or bootable partition.
It is vital that a partition is made active. Without an active partition the system will not boot.
a from the fdisk primary menu to set the active partition and
select the appropriate partition, in most cases this is the 1st Partition after
the swap partition.
Remember to save any and all changes by writing to the MBR
Partitioning the HDD is complete once the swap , primary and extended partitions are established, the active partition is marked and the changes are saved to the partition table. It is now time to set-up and Install Slackware to the system.