To format an external USB hard disk partition on a Linux system, you can use the fdisk
or parted
command.
Before formatting the partition, you need to make sure that the necessary drivers are installed and the hard disk is properly configured. You can check the status of your hard disk by running the following command:
lsblk
This will list all the block devices detected on your system, including the hard disk.
To format the partition using fdisk
, follow these steps:
fdisk
command:sudo fdisk /dev/sda
Note: The device name (e.g., /dev/sda) may vary depending on your system configuration. You can use the lsblk
command to check the device name of your hard disk.
Press d
to delete the partition.
Press n
to create a new partition.
Press p
to create a primary partition.
Press 1
to create the first partition.
Press Enter
to accept the default first sector.
Press Enter
to accept the default last sector.
Press w
to write the changes to the partition table.
To format the partition using parted
, follow these steps:
parted
command:sudo parted /dev/sda
Type rm 1
to delete the partition.
Type mkpart primary 0% 100%
to create a new primary partition using the entire disk.
Type q
to quit parted
.
Once the partition has been created, you can format it with a desired filesystem using the mkfs
command. For example, to format the partition with the ext4 filesystem, you can use the following command:
sudo mkfs.ext4 /dev/sda1
Note: Before formatting the partition, make sure to back up any important data on the partition, as the formatting process will erase all data on the partition.