Disk Partitioning in Linux
Partitions are slices of the hard drive.Typically an installation of Linux will create these slices or partitions of a hard drive. These partitions create separate areas of the disk to hold multiple operating systems or to separate programs and data to aid in back-up. The first sector 0 is reserved for the master boot record. The master boot record on the Primary Boot Drive, contains the mapping for all partitions on all drives.
Linux provides for the following partition options:
Primary Partition – set active for boot loader
Extended Partition – subdivide an extended partition into logical partitions
Logical Partitions – you can create as many logical partitions as you need
The Primary partitions are numbered 1,2,3 and 4. However, if you use an Extended partition number 4 will be replaced by number 5 and all logical partitions will follow number 5. For example a drive hda1 is a Primary partition while hda11 is the 7th logical partition (since 5 is the first logical) on the IDE drive. Linux will support 63 partitions on an IDE hard drive and 15 partitions on a SCSI hard drive.
Common partitions are listed here, notice that these partitions may or may not be the same as the directories.
/boot files and commands required for boot
/etc basic configuration files
/home home directories of all users except root
/mnt mount point for removable media, i.e. floppies, CDROM, Zip
/opt applications like OpenOffice
/root root user directory
/tmp temporary storage
/usr programs and data for users
/var variable data like log files, print spools
In addition to the partitions listed here a user may want to create their own partitions when the system is installed. Here are a few examples, anything is possible.
/music create a partition that is reserved for music
/bk create a partition that only hold back-ups
/www create a partition for the web server
/ftp create a partition for ftp
/data create a partition for information
Clearly you are able to configure your hard drive in ways that it will benefit you most.
The advantage of creating partitions that are the same as file system directories is when things go bad on your system or when you upgrade the system. Here is an example that many users will appreciate. A user installs a new distribution on a computer and uses 6 major partitions (slices of the hard drive) and uses those 6 partitions to represent the file system:
With this basic configuration it provides options when the system is updated or there is any kind of hard drive failure. Each partition is independent so that if one partition goes bad for example, you will not lose all of the data on the other partitions. For example, if the /var partition failed because of hardware failure, your important data in the /home partition would still be usable and could be retrieved. If it was just one large partition you would lose all of the data. Another example would be during an upgrade, which is important since many distributions release new versions every 6 months. During an upgrade or a new installation you would not need to format the /home partition that contains user data, even if you changed distributions, as long as the file type was consistent. So, there are major advantages to having separate partitions for each file system directory. However, most users who are new to Linux will take the default installation which does not follow this pattern but still works fine and is a much easier installation.