Linux hard disk partition

Final preparation for the Linux Installation

It is important to prepare yourself with some documentations before starting the Linux installation. This is because Linux need extra informations during setup process. Start with gathering your computer hardware's manual, such as your CPU, RAM, VGA, monitor, keyboard, mouse and so on. If you are reading from the beginning of this Linux basic tutorials, then you should already completed the gathering information part which is called the pre-installation checklist.

Again, please check that you have all the lists below before doing the actual installation::

  1. Pre-installation checklist - Make sure to complete the checklist.
  2. Installation manual - This page can be a reference manual. However, better have the actual installation manual from your Linux distribution website.
  3. Installation media - The Linux cd or dvd installer, floppy or usb drive boot disk, or any installation method you choose. If you not sure, here's what you should check first: Linux installation methods tutorial.

If you have completed all the lists above, then it's time to put your Linux installer in and begin the installation journey. The crucial part in Linux installation is doing the Linux hard disk partition. Most Linux distributions today offer a menu driven hard disk partition tool which makes it easier for a new user. Although it's not as easier as partitioning hard disk in Windows XP, but with the right documentation, user can get through it.

The great partition tool from the beginning of Linux is fdisk. Many distributions still using it such as Slackware. The example of using Slackware fdisk is included in this tutorial. There is also an example of Ubuntu hard disk partition with screenshots example in Ubuntu manual partition help.

Linux partition size

In Linux, there are many mount point or system directory such as /boot, /home, /usr/, /var, etc (like a drive, in Windows we have drive C). User can create a different partitions for each system directory. But in order to do that, user needs to know the characteristics of each system directory. Each system directory in Linux holds specific Linux file. For example the /home mount point keeps user account home directory. The /var mount point keeps system logs. The /etc mount point keeps configuration files. More information about Linux mount point or system directory can be found in Linux file system overview tutorial.

You don't have to provide a large hard disk space for Linux. The minimum size of Linux partition can be:

  • / - 35 MB
  • /boot - 5 MB
  • /home - 100 MB
  • /tmp - 30 MB
  • /usr/local - 232 MB
  • /var - 25 MB
  • /swap - 2 x RAM

Linux hard disk partition size is really depends on your system. What do you want it to be? A DNS server, mail server, FTP server, firewall, router, desktop, whatever. If you you are a beginner and want to learn everything on Linux, then install all. For an example, on a 20 GB hard disk, you can set a partition of:

  • /swap - 2 x RAM
  • / - Remaining

All other Linux partitions such as /usr, /bin, /sbin, /etc, /var and so on will be under / (root) automatically. This is the most simple and basic Linux hard disk partition size. You can choose this kind of partition for a desktop Linux or a laptop.

If you are planning to create a File Transfer Protocol (FTP) server, you need extra large hard disk partition for /home directory because all shared data will be kept in /home/ftp directory (default Slackware Linux). I already mentioned that /home directory will automatically put under / directory but it's a good idea to create separate hard disk partition for /home mount point. The advantage is that, when you upgrade Linux, you don't have to worry about screw up all the ftp data.

Linux fdisk command

In Slackware Linux, there are two programs which you can use to create partitions. You can use either fdisk(8) or cfdisk(8). If you are familiar with fdisk program in windows 9x, then you are on the track.

The first IDE hard disk in Linux is known as hda, the second hard disk is hdb, and so on. For a SCSI hard disk it’s called sda, sdb, and so on. Linux detects SATA hard disk the same as scsi, first hard disk as sda, second hard disk as sdb and so on.The hard disks are located in /dev directory. In this example, the Linux partition is done by using fdisk tool in Slackware Linux.

At the shell prompt, type fdisk /dev/hda and press ENTER.

# fdisk /dev/hda

The program begins. The fdiskgives you a prompt. If you never use fdisk before, press m for help.

Command (m for help): m

This will display all the options that you can use with fdisk. Press p to view the partition table on the hard disk.

Command (m for help): p

You can see a partition number, the size of the partition, and its type. Let's assume that you already backup your vital data in the hard disk. Now we are free to use fdisk to delete and create partitions for Linux. ENTER the d command to delete partition:

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

Continue this process until you delete all the partitions in the hard disk. In this example we are going to create two partitions, the root (/) partitions and swap partitions.

Now enter n to create a new partition and press ENTER:

Command (m for help):n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4):1
First cylinder (0-1060, default 0):0
Last cylinder or +size or +sizeM or +sizeK (0-1060, default 1060):+256M

Enter p for primary partition. This is our first partition, so enter 1 and leave the First cylinder to 0 default). Let's create this partition for swap partition. The size of swap partition depends on the size of RAM in the computer. Normally the swap space is double size of the RAM. If you have 128 MB RAM, then put 256 MB as your swap partition. Key in the size for our first partition in +sizeM or +sizeK format.

When you finished with the first partition, repeat the steps above to create the second partition (Partition number 2). Choose default value for the First cylinder. This is going to be the root (/) partition so just give all the remaining space unless you are planning differently.

Press ENTER when you finish.

Command (m for help):n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4):2
First cylinder (255-1060, default 255):255
Last cylinder or +size or +sizeM or +sizeK (266-1060, default 1060):1060

You can check your new partitions by entering p character and press ENTER. Note that you have two partitions that you have just created.

Before writing this data into the hard disk, you must set the partition type to this partition. Type t to change the partition type. For the first partition, which is swap space, change the partition type to 82 in Hex (Linux swap). The Linux native partition type is 83 in Hex. Now we are done. Enter w to write everything we have done and quit fdisk.

If you are looking for Slackware 12.1 fdisk partition screenshots, check it in Slackware partitioning with fdisk screenshots gallery.

Continue to Linux installation guide.

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.