Format Hard Drive in Linux: Complete Guide
In a Linux system, the fdisk command and mkfs command can be used to format the entire hard drive.
- First, open the terminal and log in as an administrator.
- Run one of the following commands to view the list of hard drives in the system:
- show the disk information
- Choose the hard drive you want to format and make note of its device name (ex: /dev/sda).
- Run the following command to partition the entire hard drive:
- Partition the device /dev/sdX.
- sdX is the device name of the hard drive that needs to be formatted.
- Press the “m” key in the fdisk interactive interface to display the command help list.
- Create a new partition using the n command.
- Select the main partition using the command “p”.
- Enter the partition number, starting sector, and ending sector according to the prompts (or use default values).
- Save the partition table and exit fdisk using the w command.
- Execute the following command to format the newly created partition:
- Format the device as ext4.
- – sdX1 is the newly created partition device name.
- To confirm that you want to continue, type ‘y’ and press Enter.
- After the formatting process is completed, the entire hard drive is formatted.
Please note that formatting the hard drive will delete all data on it, so please make sure to back up important data beforehand.