Difference between revisions of "Partitioning"

From gr0x0rd
Jump to navigation Jump to search
Line 22: Line 22:
 
  '''Command (m for help):''' n
 
  '''Command (m for help):''' n
 
We are creating a standard partition
 
We are creating a standard partition
  '''Command action
+
  '''Command action'''
  e  extended
+
  '''e  extended'''
  p  primary partition (1-4)''' p
+
  '''p  primary partition (1-4)''' p
 
This will be the first partition
 
This will be the first partition
  '''Command (m for help):''' 1
+
  '''Partition number (1-4):''' 1
We want to start at the first block, so press enter when prompted. Next we set the size of the boot partition to 64 megabytes.
+
We want to start at the first block, so press enter at the next prompt.
  '''Command (m for help):''' +64M
+
'''First cylinder (1-?, default 1): '''
 +
Next we set the size of the boot partition to 64 megabytes.
 +
'''Using default value 1'''
 +
'''Last cylinder, +cylinders or +size{K,M,G} (1-?, default ?): ''' +64M
 +
Since this is our boot partition, we'll need to set it to active.
 +
'''Command (m for help): ''' p
 +
  '''Command (m for help): ''' a
 +
'''Partition number (1-4): ''' 1
 +
We've now created our boot partition. Now we'll set up the swap partition.

Revision as of 12:22, 16 November 2010

Installing Gentoo - Partitioning

Linux has a very simple yet elegant tool to set up the partitions on your hard drive called fdisk. This is similar to the legacy dos-based fdisk.exe application, with the exception that it is very fast, supports almost all hard disk devices, and actually works. In case you didn't read the previous section, make sure you disconnect any drives containing precious data before proceeding.

Before you can start partitioning, you need to determine what the system recognized your hard drive as during bootup. As you are probably aware, there are two primary hard drive types: IDE and SATA. IDE hard drives have a wide ribbon cable about 2 inches wide and a standard power connector, where SATA drives have a smaller cable attachment and different type of power connector. To accommodate multiple hard drives, the Linux kernel enumerates devices using letters. The first drive found on a subsystem is designated as a, the next b, and so on.

Devices detected on the IDE subsystem are prefixed with hd, whereas devices on the SATA subsystem are prefixed with sd. If you are virtualizing Gentoo, chances are the virtual hard disk controller is IDE/ATA, so your virtual hard disk will be recognized as /dev/hda. Most new systems utilize SATA drives so that is what we will use as an example in this guide. The first device detected via a SATA connection would be designated /dev/sda.

A note on partitions

While many partitioning configurations are possible, this guide focuses on partitioning the primary hard disk into three partitions: a boot partition, a swap partition, and a root partition.

The boot partition is a small partition that houses your system boot manager, such as GRUB or LILO, and the Linux kernel. While it is possible to have the boot manager and kernel on the same partition as the root, it isn't advisable since if the partition becomes corrupt, or you overwrite your files, your system can no longer boot. Keeping a small, separate boot partition is an excellent way to ensure you'll be able to boot and perform maintenance on your system no matter what happens.

The swap partition is an area dedicated as a work area for the kernel. Its equivalent in Windows would be the pagefile, otherwise known as "virtual memory", which Windows will expand as it sees fit (often to the point of filling your disk). Obviously, the more swap space available to the kernel, the easier it will be for it to manage the swap space. Choosing the size of the swap partition also depends on how much RAM is installed in your system. If you don't have a lot of RAM, a bigger swap partition is advisable. In this example, we'll use a swap partition size of half a gigabyte: 512M.

The root partition would be the equivalent of your C: drive in Windows. It contains the base Linux system components, and serves as an object to which other partitions can be mounted. Some users like to spread the Linux filesystem over multiple drives and partitions, but in this example we will keep it simple and simply fill the remainder of the space on the disk with the partition we'll use for root.

To start fdisk and being partitioning your hard disk,

# fdisk /dev/sda

...where /dev/sda is the alias the system has assigned for your hard disk. You'll now be greeted by the fdisk shell. You can type m to see the commands that are available to you. If you have existing partitions, you may want to delete them by entering d. Once any existing partitions have been removed from the disk, we will start by creating the boot partition.

Command (m for help): n

We are creating a standard partition

Command action
e   extended
p   primary partition (1-4) p

This will be the first partition

Partition number (1-4):  1

We want to start at the first block, so press enter at the next prompt.

First cylinder (1-?, default 1): 

Next we set the size of the boot partition to 64 megabytes.

Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-?, default ?):  +64M 

Since this is our boot partition, we'll need to set it to active.

Command (m for help):  p
Command (m for help):  a
Partition number (1-4):  1

We've now created our boot partition. Now we'll set up the swap partition.