How to Create Partition in Linux

In this tutorial, let's learn how to create a partition on Linux using fdisk commands. Fdisk is a command line utility that provides disk partitioning functions for various operating systems. It was originally developed by IBM in 1983 and since then it was used on most operating systems from DOS to Windows and to Unix-based systems.

Table of Contents

1) Create a new partition

Here I’m trying to create a partition on the disk (ProLiant SmartArray RAID controller - /dev/cciss) using fdisk. You can choose the option “n” to create the new partition and “p” to list available partitions. On the below output (7253-8920, default 8920) mean cylinder 7253 up to 8920 is available now. In the end, you will also need to use the “w” to write the changes to disk; remember that as long as you don’t use the “w” options all changes are kept in memory and are not written to disk.

# fdisk /dev/cciss/c0d0

The number of cylinders for this disk is set to 8920.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs

Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition’s system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)

Command (m for help): n
First cylinder (7253-8920, default 7253): ==> PRESS ENTER TO ACCEPT DEFAULT
Using default value 7253
Last cylinder or +size or +sizeM or +sizeK (7253-8920, default 8920): +5G

Command (m for help): p

Disk /dev/cciss/c0d0: 73.3 GB, 73372631040 bytes
255 heads, 63 sectors/track, 8920 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/cciss/c0d0p1 * 1 12 96358+ 83 Linux
/dev/cciss/c0d0p2 13 2101 16779892+ 83 Linux
/dev/cciss/c0d0p3 2102 4190 16779892+ 82 Linux swap
/dev/cciss/c0d0p4 4191 8920 37993725 5 Extended
/dev/cciss/c0d0p5 4191 5234 8385898+ 83 Linux
/dev/cciss/c0d0p6 5235 5756 4192933+ 83 Linux
/dev/cciss/c0d0p7 5757 5881 1004031 83 Linux
/dev/cciss/c0d0p8 5882 6006 1004031 83 Linux
/dev/cciss/c0d0p9 6007 7252 10008463+ 83 Linux
/dev/cciss/c0d0p10 7253 7861 4891761 83 Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.

fdisk m

fdisk p

The partprobe command will inform the operating system kernel of partition table changes. So no need for reboot. /* CAREFUL: partprobe MAY CAUSE A REBOOT (Not Always, only precaution) – Arrange downtime on live systems */

# partprobe /dev/cciss/c0d0

To see the available disk partitions you can check the /proc/partitions file, so the newly created partitions should be there. You can run this command before and after the disk partition.

# cat /proc/partitions
major minor #blocks name

104 0 71652960 cciss/c0d0
104 1 96358 cciss/c0d0p1
104 2 16779892 cciss/c0d0p2
104 3 16779892 cciss/c0d0p3
104 5 8385898 cciss/c0d0p5
104 6 4192933 cciss/c0d0p6
104 7 1004031 cciss/c0d0p7
104 8 1004031 cciss/c0d0p8
104 9 10008463 cciss/c0d0p9
104 10 4891761 cciss/c0d0p10

2) Creating filesystem

Even though the space for the new partition has been allocated and written to disk you still need to create a filesystem on that newly available space, so the next step is formatting the partition with the required filesystem. In our example, we’ll be using ext3.

# /sbin/mkfs -t ext3 /dev/cciss/c0d0p10
mke2fs 1.35 (28-Feb-2004)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
611648 inodes, 1222940 blocks
61147 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1254096896
38 block groups
32768 blocks per group, 32768 fragments per group
16096 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736

Writing inode tables: done

Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 33 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.


You can set new label name for the filesystem using the e2label command.

# e2label /dev/cciss/c0d0p10 /mydatadisk

You can edit fstab file to update new label (filesystem) information.

# vi /etc/fstab
# This file is edited by fstab-sync – see ‘man fstab-sync’ for details
LABEL=/ / ext3 defaults 1 1
LABEL=/boot /boot ext3 defaults 1 2
none /dev/pts devpts gid=5,mode=620 0 0
none /dev/shm tmpfs defaults 0 0
LABEL=/mlextras /mlextras ext3 defaults 1 2
none /proc proc defaults 0 0
none /sys sysfs defaults 0 0
LABEL=/var /var ext3 defaults 1 2
LABEL=SW-cciss/c0d0p3 swap swap defaults 0 0
LABEL=/itrs /itrs ext3 defaults 1 2
LABEL=/mqmsw /mqmsw ext3 defaults 1 2
LABEL=/mktdata /mktdata ext3 defaults 1 2
LABEL=/mydatadisk /tools ext3 defaults 1 2
/dev/vx/dsk/dg_apps/apps /apps vxfs suid 1 2
/dev/hda /media/cdrecorder auto pamconsole,exec,noauto,managed 0 0

3) Mounting new partition

Now that we have created a new partition and formatted it, we need to mount it in a specific location so that we can start using it. To do this, we will first create a folder to use as a mount point for that partition and then use the mount command to actually mount the partition.

# mkdir /tools

# mount /dev/cciss/c0d0p10 /tools

To confirm we can list the mount points with below commands

# df -h /tools
Filesystem Size Used Avail Use% Mounted on
/dev/cciss/c0d0p10 4.6G 42M 4.4G 1% /tools

# mount -l | grep tools

/dev/cciss/c0d0p10 on /tools type ext3 (rw) [/tools]


Read Also:

Bobbin Zachariah 9:09 pm


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

All comments are subject to moderation.


  1. While attempting to write partition changes to disk for the initial Debian jessie install I receive an Input/Output error /dev/cciss/c0d0

    System is a HP ProLiant G4 with a Smart Array P400 controller.