In most Linux systems, you can use the fdisk utility to create a new partition and to do other disk management operations.
Note: To be able to execute the commands necessary to create a new partition on Linux, you must have the root privileges.
As a tool with a text interface, fdisk requires typing the commands on the fdisk command line. The following fdisk
commands may be helpful:
m Displays the available commands.
p Displays the list of existing partitions on your hda drive. Unpartitioned
space is not listed.
n Creates a new partition.
q Exits fdisk without saving your changes.
l Lists partition types.
w Writes changes to the partition table.
To create a new partition on Linux
1. Start a terminal.
Start fdisk using the following command:
where /dev/hda stands for the hard drive that you want to partition.
2. In fdisk, to create a new partition, type the following command:
When prompted to specify the Partition type, type p to create a primary partition or e to create an extended one. There may be up to four primary partitions. If you want to create more than four partitions, make the last partition extended, and it will be a container for other logical partitions. When prompted for the Number, in most cases, type 3 because a typical Linux virtual machine has two partitions by default. When prompted for the Start cylinder, type a starting cylinder number or press Return to use the first cylinder available. When prompted for the Last cylinder, press Return to allocate all the available space or specify the size of a new partition in cylinders if you do not want to use all the available space. By default, fdisk creates a partition with a System ID of 83. If you’re unsure of the partition’s System ID, use the l command to check it.
3. Use the
4. Creating a New Partition in Linux
command to write the changes to the partition table.
Restart the virtual machine by entering the reboot command.
5. When restarted, create a file system on the new partition. We recommend that you use the same file system as on the other partitions. In most cases it will be either the Ext3 or ReiserFS file system. For example, to create the Ext3 file system, enter the following command:
/sbin/mkfs -t ext3 /dev/hda3
6. Create a directory that will be a mount point for the new partition. For example, to name it data, enter:
7. Mount the new partition to the directory you have just created by using the following command:
mount /dev/hda3 /data
8. Make changes in your static file system information by editing the /etc/fstab file in any of the available text editors. For example, add the following string to this file:
/dev/hda3 /data ext3 defaults 0 0
In this string /dev/hda3 is the partition you have just created, /data is a mount point for the new partition, Ext3 is the file type of the new partition. For the exact meaning of other items in this string, consult the Linux documentation for the mount and fstab commands.
9. Save the /etc/fstab file.
————- Thanks everyone