Module – 3 Linux Standard Partition

UNIX Disk Partition?

Disk partitioning is the creation of separate divisions of a hard disk drive using partition editors such as fdisk. Once a disk is divided into several partitions, directories and files of different categories may be stored in different partitions.

Purposes for Disk Partitioning

An operating system like Windows / Linux can be installed on a single, unpartitioned hard disk. However, the ability to divide a hard disk into multiple partitions offers some important advantages. If you are running Linux on server consider following facts:

  • Ease of use – Make it easier to recover a corrupted file system or operating system installation.
  • Performance – Smaller file systems are more efficient. You can tune file system as per application such as log or cache files. Dedicated swap partition can also improve the performance (this may not be true with latest Linux kernel 2.6).
  • Security – Separation of the operating system files from user files may result into a better and secure system. Restrict the growth of certain file systems is possible using various techniques.
  • Backup and Recovery – Easier backup and recovery.
  • Stability and efficiency – You can increase disk space efficiency by formatting disk with various block sizes. It depends upon usage. For example, if the data is lots of small files, it is better to use small block size.
  • Testing – Boot multiple operating systems such as Linux, Windows and FreeBSD from a single hard disk.
File systems that need their own partitions
Partition Purpose
/usr This is where most executable binaries, the kernel source tree and much documentation go.
/var This is where spool directories such as those for mail and printing go. In addition, it contains the error log directory.
/tmp This is where most temporary data files stored by apps.
/boot This is where your kernel images and boot loader configuration go.
/home This is where users home directories go.


Let us assume you have 100 GB SCSI hard disk with / (root) and swap partitions only. One of user (may be internal or external or cracker ) runs something which eats up all your hard disk space (DoS attack).

For example, consider following tiny script that user can run in /tmp directory:

Type of partition in Linux:

  • Primary (or standard) partition (1-4) : Maximum 4 partitions allowed
  • Extended partition : Depends on the size of the disk, you can go up to 128 Partitions.

Today’s class we will learn how to create standard partition in RHEL 6.4:

Step:1 Add 2 GB disk to your VM 

If you use Oracle virtual box or VMWARE workstation follow the console procedure what was discussed in class

Step:2  Verify the 2 GB disk

# fdisk -l| grep Disk
Disk /dev/sda: 8589 MB, 8589934592 bytes  —–Always /dev/sda is OS disk
Disk identifier: 0x000b7315
Disk /dev/sdb: 2048 MB, 8589934592 bytes—- Next disk will be /dev/sdb, /dev/sdc…
Disk identifier: 0x78a443dc
So, we have 2nd disk available inside OS. /dev/sdb is our 2nd disk.

Step:3 Create “1st” partitions 1 GB from our 2 GB disk

# fdisk /dev/sdb
WARNING: DOS-compatible mode is deprecated. It’s strongly recommended to
switch off the mode (command ‘c’) and change display units to
sectors (command ‘u’).
Command (m for help): n     (Here “n” is to create new partitions)
Command action
e   extended
p   primary partition (1-4)    —-> We are going to practice primary partition, so give “p”

Partition number (1-4): 1      —> To create 1st primary partition
First cylinder (1-261, default 1):
Using default value 1          —->  Start from 1st cylinder (like 1st page of your note)
Last cylinder, +cylinders or +size{K,M,G} (1-132, default 132): +1G   –> (upto 1 GB)

Command (m for help): w    —-> will save our work.

Step:4 Let us verify the partition

# fdisk -l /dev/sdb
Disk /dev/sdb: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders —-> it is like total pages in note book
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x20bb1a1b

Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         132     1060258+  83  Linux  —> this confirms 1st partition is ok.

Step: 5 Create file system

# mkfs -t ext4 /dev/sdb1   ( you should see the following output)
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
66384 inodes, 265064 blocks
13253 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=272629760
9 block groups
32768 blocks per group, 32768 fragments per group
7376 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376
Writing inode tables: done                            
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 25 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

Step: 5 Create label (empty directory) to mount  your file system

# mkdir /app01 

Step: 6  Mount  the file system to label (directory)

# mount -t ext4 /dev/sdb1 /app01

Step:7  Verify partition & file system is mounted properly

# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_rhel02-lv_root   5.5G  1.9G  3.4G  36% /
tmpfs                 972M     0  972M   0% /dev/shm
/dev/sda1             485M   37M  423M   9% /boot
/dev/sdb1            1020M   34M  935M   4% /app01

….Let us try creating 2nd partition & mount it on ” /app02″

Step:8  Update in /etc/fstab file

vi /etc/fstab

/dev/sdb1    /mountpoint    ext4  defaults 0 0


Leave a Comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>