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 fdiskcommand line. The following fdisk commands may be helpful:| Options | Description |
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
- Start a terminal.
- Start
fdiskusing the following command:/sbin/fdisk /dev/hdawhere/dev/hdastands for the hard drive that you want to partition. - In
fdisk, to create a new partition, type the following command:n- When prompted to specify the Partition type, type
pto create a primary partition oreto 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
3because 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,fdiskcreates a partition with a System ID of83. If you’re unsure of the partition’s System ID, use thelcommand to check it. - Use thewcommand to write the changes to the partition table.
- Restart the virtual machine by entering therebootcommand.
- 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
Ext3orReiserFSfile system. For example, to create theExt3file system, enter the following command:/sbin/mkfs -t ext3 /dev/hda3 - Create a directory that will be a mount point for the new partition. For example, to name it
data, enter:mkdir /data - Mount the new partition to the directory you have just created by using the following command:mount /dev/hda3 /data
- Make changes in your static file system information by editing the
/etc/fstabfile in any of the available text editors. For example, add the following string to this file:/dev/hda3 /data ext3 defaults 0 0In this string/dev/hda3is the partition you have just created,/datais a mount point for the new partition,Ext3is the file type of the new partition. For the exact meaning of other items in this string, consult the Linux documentation for themountandfstabcommands. - Save the
/etc/fstabfile.

No comments:
Post a Comment