What is fdisk? (Explained)

4
48
What is fdisk

What is fdisk?

In simple words, fdisk refers to the external command-line utility of MS-DOS that configures the hard drives of the computers. Technically, it is the manipulator of the partition table on Linux and also writes the Master Boot Record (MBR).

KEY TAKEAWAYS

  • Typically, fdisk is a command-line utility used for partitioning the hard disks on computer systems as well as for writing the Master Boot Record.
  • This specific utility is available in different operating systems including MS-DOS 3.3x, IBM OS/2, DR FlexOS, and several other earlier versions of Windows.
  • It is also used by different ports and was also a part of FreeBSD, NetBSD, OpenBSD, and others as well as macOS.
  • Using the fdisk utility offers some specific benefits such as data protection by hiding the partitions, use in old computer systems, and use as a boot manager as well.
  • The limitations of fdisk include the inability to move an application from one partition to another without uninstalling and reinstalling it or deleting a partition without data loss.

Understanding fdisk

What is fdisk

Ideally, the command-line utility fdisk facilitates disk partitioning and has been an integral part of the Disk Operating System (DOS).

Initially, fdisk was available in different operating systems such as:

  • MS-DOS 3.3x
  • IBM OS/2
  • DR FlexOS
  • Windows 95
  • Windows 98
  • Windows ME

The DOS fdisk utility was however available with the original Windows 95 operating system and could only create File Allocation Table or FAT partitions, especially the FAT12 and FAT16 types of it. The later type, FAT32, came with the Windows 95B versions and higher.

However, in Windows 2000 and its successor, Windows XP, there is a more advanced graphical Windows Disk Management utility and Recovery Console called DiskPart, a logical Disk Manager.

In addition to that, it was also a part of a few specific ports of the following open-source and free Unix-like operating systems:

  • FreeBSD
  • NetBSD
  • OpenBSD
  • DragonFly BSD
  • macOS

This inclusion offered additional compatibility.

The most significant advantage of using the fdisk utility is that it allows hiding the partitions from other users. This ensures that your data is protected.

Moreover, you can use it as a boot manager as well. This will allow you to use more than one operating system most easily.

And, most importantly, if you are using an old computer system, there will be no need to upgrade the Basic Input Output System (BIOS).

However, there are a few limitations to fdisk. One of the most notable drawbacks of it is that it does not allow moving an application from one partition to the other, or from one drive letter to the other, without uninstalling and reinstalling.

Another notable downside of it in this respect is that you will not be able to delete a partition without losing all the data stored in it.

This means that you will have to repeat the whole fdisk process from the beginning and reformat the partition.

Ideally, it is also required to create a number of partitions if you want to make the best use of the full capacity of the hard drive.

Read Also:  What is USB Port? Types, Lifespan, Function, Benefits & More

What is fdisk

Partitioning

The added capabilities of DOS fdisk make it a competent partitioning tool just like the other third-party programs.

It will help you to set up the partition in an ideal manner and it will let more than one operating system to exist on one single system.

However, fdisk shows two DOS partitions only, such as:

  • The primary partition
  • The extended partition

The extended partition is, however, further divided into different logical volumes, each of which acts as an individual partition.

The minimum size of a partition is 1 MB, following the principle of creating partitions by the fdisk in DOS 4.0 or later on numbers of megabytes. The sizes of these partitions are typically restricted to 2 GB.

In comparison, the DOS versions before 4.0 supported a maximum partition size of 32 MB.

However, with the use of the FAT32 file system in different operating systems, such as Windows 95, DOS 7, and others, the maximum size of the partitions was increased up to 2 TB.

This is a huge number of bytes. It can be calculated as:

2 TB

= 2048 GB

= 2,097,152 MB

= 2,147,483,648 KB

= 2,199,023,255,552 bytes.

What is fdisk Used for?

Typically, fdisk is used for preparing and partitioning a new hard disk drive, creating additional hard drives, and even setting the computer to use multiple operating systems or multi-booting.

The tool allows changing the partitioning of the hard drive on different types of operating systems apart from the common ones already mentioned above, such as:

  • Linux
  • Windows NT
  • BeOS and lots more

In summary, when you use the fdisk utility, you can do a lot of things, such as:

  • Create or delete the primary DOS partition
  • Activate or deactivate the primary DOS partition
  • Delete non-DOS partitions
  • Create or delete logical drives
  • Create or delete an extended DOS partition
  • Change fixed disk
  • Create or delete one FAT12 partition
  • Change the active partition
  • Display partition data
  • Write or repair the Master Boot Record

fdisk in Linux

In all Linux distributions, you will find fdisk already pre-installed as it is the standard package of the Linux kernel. This tool allows resizing, viewing, deleting, copying, changing, and moving partitions on the hard drive by using different commands.

You can create as many as four new primary partitions along with many logical partitions, depending on the size of the hard disk in the system.

Typically, using the fdisk command in Linux will help you to manipulate the hard disk in a lot of different ways such as:

  • It will help you in reorganizing the old archives.
  • It will allow moving or copying data to the new hard drives.
  • It will facilitate creating more space or organizing the existing space to accommodate new partitions.

All these can be done by using a few specific commands on Linux.

To use fdisk on Linux, the syntax is very simple, which is fdisk <options> <disk>.

You will be provided with a lot of different options that are necessary to use with the fdisk command in Linux. Take a look at these options:

  • -b: This option denotes the physical and logical size of the sector.
  • -B: This option does not allow erasing boot bits while creating a new label.
  • -L: This option colors the outputs.
  • -l: This option displays the partitions of the disks.
  • -o / –output <lists>: This option displays the specified columns.
  • -t: This option helps in recognizing only the specific partition table.
  • -u: This option displays the β€˜cylinders’ or β€˜sectors’ units.
  • -s: This option shows the size of the device in 512-byte sectors.
  • -w: This option will wipe off the signatures.
  • -W: This option will also wipe the signatures, but from the new partition.
  • -C: This option denotes the number of cylinders.
  • -H: This option stipulates the number of heads.
  • -S: This option tells the number of sectors present in each track.
  • -h: This option will open the help document regarding fdisk.
  • -V: This option shows the version of the fdisk being used.
Read Also:  What is Scratch Space? (Explained)

A few common commands to use fdisk in Linux are as follows:

  • To view partitions of all the disks – sudo fdisk – l.
  • To view partitions of a particular disk – sudo fdisk – l /dev/<name>.
  • To enter command mode to tinker with a specific disk name, say, /dev/sda, – sudo fdisk /dev/sda.
  • To see all the commands in the command mode – Press β€˜m’ while in the command mode.
  • To view a partition table or print it – Press the letter β€˜p’ while in the command mode.
  • To delete a partition of a particular disk – Type the letter β€˜d’ and enter the partition number you want to delete when prompted.
  • To create a new partition on a particular disk – Press the letter β€˜n’ and the partition number in the command mode.
  • To format a partition created say, 5, – sudo mkfs. ext5 /dev/sda5.
  • To check the size of a particular partition, say, 2, – sudo fdisk -s /dev/sda2.
  • To disable the boot flag (*) of a partition – Press the letter β€˜a’ in command mode and enter the partition number when prompted.
  • To fix the partition table order – Press the letter β€˜x’ in the command mode, enter the expert command β€˜f’ to fix the order and then the letter β€˜w’ to save and exit.

If you are stuck anywhere at any point during the process, you should use the manual of the tool. In such times, instead of using the traditional fdisk command, sudo fdisk–help, you should run β€˜man fdisk.’

fdisk Command in DOS

The fdisk command in DOS will allow you to create new partitions or delete an existing partition on a hard drive.

The commonly used command line parameter is FDISK [/STATUS] /X, where the status displays the information of the partition and β€˜x’ will ignore Logical Block Addressing (LBA) or extended disk support.

In addition to that, there are also a few other undocumented or secret fdisk switches to use such as:

  • FDISK /MBR – This is the command for rewriting the Master Boot Record (MBR).
  • FDISK /CMBR – This command recreates the MBR or a specific disk. It is similar to the above with the only difference that it can be used on other drives.
  • FDISK 1/PRI:100 – This command creates a 100 MB DOS partition on the hard drive 1.
  • FDISK 1/EXT:500 – This command creates a 500 MB extended DOS partition on hard drive 1.
  • FDISK 1/LOG:250 – This command creates a 250 MB logical drive on the hard disk drive.
  • FDISK /PARTN – This command saves the partition to the PARTSAV.FIL file.
  • FDISK /Q – This command will disable fdisk from booting the computer automatically after exiting from fdisk.
  • FDISK /STATUS – This command will show the current status of the hard drives.
  • FDISK /ACTOK – This command will not allow fdisk to check the integrity of the disk and allow creating drives much faster.
  • FDISK /FPRMT – This command will force fdisk to use FAT32 support by getting the prompt for it on drives less than 540 MB since fdisk does not use FAT32 by default on any drive less than 540 MB.
Read Also:  What is PATA (Parallel ATA)? Features, Pros, Cons & More

You can use an additional command and follow these steps for using an fdisk script file from an external file. This will also allow creating and deleting partitions faster.

To do this, first you will have to create a file with the help of the DOS edit command and then do the following:

Edit fdisk.scr – This is the edit screen. You will need to enter the commands to run in fdisk here, and display the information of the partition.

Here are the additional steps to follow:

  • Make your selection
  • Press Enter
  • Press Ctrl+P
  • Press Ctrl+M

This will act as a carriage return. Just make sure that all the input commands are on one line to run fdisk.

When the script file is created, type fdisk < fdisk.scr to execute the file.

fdisk Vs gdisk

  • Ideally, the fdisk utility is used for MBR partitioning, while, in comparison, the gdisk utility is its equivalent for Globally Unique Identifier or GUID Partition Table (GPT) partitions.
  • The fdisk utility will show the disk label, but in comparison, the gdisk utility will show the partition table type.

Conclusion

So, coming to the end of the article, you now must have a fair idea about fdisk, how it works and how to use it to your advantage.

It is a very useful utility to configure the hard drive in your computer.

However, before you go ahead with the process, make sure that you take a backup of everything in your system first.

About Puja Chatterjee

AvatarPuja Chatterjee, a distinguished technical writer, boasts an extensive and nuanced understanding of computer technology. She is an esteemed graduate of the Bengal Institute of Management Studies (BIMS), where she honed her skills and knowledge in the tech domain. Over the span of more than 12 years, Puja has developed a deep expertise that encompasses not only technology writing, where she articulates complex technical concepts with clarity and precision, but also in the realm of client relationship management. Her experience in this area is characterized by her ability to effectively communicate and engage with clients, ensuring their needs are met with the highest level of professionalism and understanding of their technical requirements. Puja's career is marked by a commitment to excellence in both written communication within the tech industry and fostering strong, productive relationships with clients.

Previous articleWhat is File Allocation Table (FAT)? Types, Uses & More
Next articleWhat is Free Space? (Explained)
Puja Chatterjee
Puja Chatterjee, a distinguished technical writer, boasts an extensive and nuanced understanding of computer technology. She is an esteemed graduate of the Bengal Institute of Management Studies (BIMS), where she honed her skills and knowledge in the tech domain. Over the span of more than 12 years, Puja has developed a deep expertise that encompasses not only technology writing, where she articulates complex technical concepts with clarity and precision, but also in the realm of client relationship management. Her experience in this area is characterized by her ability to effectively communicate and engage with clients, ensuring their needs are met with the highest level of professionalism and understanding of their technical requirements. Puja's career is marked by a commitment to excellence in both written communication within the tech industry and fostering strong, productive relationships with clients.
4 Comments
Oldest
Newest
Inline Feedbacks
View all comments