Disk Partition Using Fdisk Command
fdisk is a dialog-driven program for creation and manipulation of partition tables. It understands GPT, MBR, Sun, SGI and BSD partition tables.
Fdisk can create a partition, delete a partition, change the partition type.
This example shows how to add new hard disk on Virtual box and then partition this hard disk.
- Open Virtual box, right click on virtual machine and click setting.
2. Click on Storage, on Controller: SATA click Add HDD.
3. Click on create
4. Select the HDD you have just create and click OK.
5. Now start the Virtual Machine.
6. Start Terminal,
7. View all Disk Partitions:
[root@localhost ~]# fdisk -l
- Delete a partition — Type d and you are asked to enter a partition number on the current hard disk. Type the partition number and press Enter. For example, /dev/sda2 would be partition number 2. (The deletion won’t take effect until you write the change. Until then, it’s not too late to back out.
- Create a partition — If you have free space, you can add a new partition. Type n and you are asked to enter l for a logical partition (5 or over) or p for a primary partition (1–4). Enter a partition number from the available range. Then choose the first cylinder number from those available. (The output from fdisk –l shown earlier will show you cylinders being used under the Start and End columns.)
Next, enter the cylinder number the partition will end with (or type the specific number of megabytes or kilobytes you want: for example, +50M or +1024K). You just created an ext3 Linux partition. Again, this change isn’t permanent until you write the changes. - Change the partition type — Press t to choose the type of file system. Enter the partition number of the partition number you want to change. Type the number representing the file system type you want to use in hexadecimal code. (Type L at this point to see a list of file system types and codes.) For a Linux file system, use the number 83; use 82 for a Linux swap partition. For a windows FAT32 file system, you can use the letter b.
Display the partition table — Throughout this process, feel free to type p to display (print on the screen) the partition table as it now stands.
Saving and quitting — If you don’t like a change you make to your partitions, press q to exit without saving. Nothing will have changed on your partition table.