the above command is used to view all partitions in the system
fdisk -l
view partition on a specific disk
fdisk -l /dev/etc
it check size of the partition of the partitonn
fdisk -s /dev/sda
This lists all available disks, partitions, their sizes, and filesystem types.
sudo fdisk -l
This displays partition details only for /dev/sda.
sudo fdisk -l /dev/sda
This opens /dev/sdb in fdisk interactive mode for partitioning.
sudo fdisk /dev/sdb
Inside the fdisk prompt:
n (new partition)p for primary, e for extended)1)w to save changessudo fdisk /dev/sdb
Inside the fdisk prompt:
d (delete partition)w to save changessudo fdisk /dev/sdb
Inside the fdisk prompt:
t (change type)83 for Linux, 82 for swap)w to save changessudo fdisk /dev/sdb
fdisk, press p to print the partition table.w to save changes.q to quit without saving.sudo fdisk /dev/sdb
This formats partition /dev/sdb1 as an ext4 filesystem.
sudo mkfs.ext4 /dev/sdb1
This turns /dev/sdb2 into a swap partition and enables it.
sudo mkswap /dev/sdb2
sudo swapon /dev/sdb2
Run fdisk to Delete and Recreate Partition with the Same Start Sector:
sudo fdisk /dev/sdb
Inside fdisk:
d to delete the partition.n to create a new partition.w to save changes.Resize the Filesystem:
sudo resize2fs /dev/sdb1
sudo umount /dev/sdb1
A tool to manipulate disk partitions.
sudo fdisk /dev/sda