Format Partition as Ext4
To format a partition as ext4 using fdisk, first create the partition using fdisk, then format it with the mkfs.ext4 command. Begin by identifying the target disk using fdisk -l or lsblk to list available devices Run sudo fdisk /dev/[device] to start the partitioning process, replacing [device] with the target disk (e.g., /dev/sdb) Within fdisk, use n to create a new partition, p to set it as primary, and accept the default start and end sectors to use the available space Confirm the partition table with p, and write the changes to disk with w to exit
After creating the partition, format it as ext4 using the mkfs.ext4 command followed by the partition path (e.g., sudo mkfs.ext4 /dev/sdb1) This command creates the ext4 filesystem on the specified partition Optionally, label the partition using e2label /dev/sdb1 label_name for easier identification Finally, create a mount point with mkdir /mnt/point and mount the partition using mount /dev/sdb1 /mnt/point To ensure the partition mounts automatically after reboot, add an entry to /etc/fstab using the device path or UUID (obtained via blkid)