Introduction to Disk Partitioning with fdisk and lsblk


 Introduction

Disk partitioning is the process of dividing a hard drive into sections that the operating system can manage. In Linux, tools like fdisk and lsblk help you view and manage partitions.


Step 1: List All Disks and Partitions


lsblk


➡️ Displays disks, partitions, and mount points in a tree view.


Step 2: Check Disk Information


sudo fdisk -l


➡️ Lists all partitions and their details (size, type, boot flag).


Step 3: Start fdisk on a Disk


sudo fdisk /dev/sda


➡️ Replace /dev/sda with the disk you want to manage.


Step 4: Create a New Partition

Inside fdisk:


Press n → new partition


Choose partition type (primary/extended)


Select start and end sectors


Press w to save changes


Step 5: Format the New Partition


sudo mkfs.ext4 /dev/sdaX


➡️ Replace /dev/sdaX with the partition name.


Step 6: Mount the Partition


sudo mount /dev/sdaX /mnt


➡️ The partition is now accessible under /mnt.


Conclusion

Using lsblk and fdisk, you can manage disk partitions effectively. Next, we’ll cover file search commands like find, locate, and which.

Comments